Metadata-Version: 2.4
Name: zyte-api
Version: 0.10.0
Summary: Python interface to Zyte API
Project-URL: Homepage, https://github.com/zytedata/python-zyte-api
Project-URL: Documentation, https://python-zyte-api.readthedocs.io/en/stable/
Author-email: Zyte Group Ltd <opensource@zyte.com>
License: Copyright (c) Zyte Group Ltd
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without modification,
        are permitted provided that the following conditions are met:
        
            1. Redistributions of source code must retain the above copyright notice,
               this list of conditions and the following disclaimer.
        
            2. Redistributions in binary form must reproduce the above copyright
               notice, this list of conditions and the following disclaimer in the
               documentation and/or other materials provided with the distribution.
        
            3. Neither the name of Zyte nor the names of its contributors may be used
               to endorse or promote products derived from this software without
               specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: attrs>=20.1.0
Requires-Dist: brotli>=0.5.2
Requires-Dist: runstats>=0.0.1
Requires-Dist: tenacity>=8.2.0
Requires-Dist: tqdm>=4.16.0
Requires-Dist: w3lib>=2.1.1
Provides-Extra: x402
Requires-Dist: eth-account>=0.13.7; extra == 'x402'
Requires-Dist: x402<2.0.0,>=0.1.1; extra == 'x402'
Description-Content-Type: text/x-rst

===============
python-zyte-api
===============

.. image:: https://img.shields.io/pypi/v/zyte-api.svg
   :target: https://pypi.python.org/pypi/zyte-api
   :alt: PyPI Version

.. image:: https://img.shields.io/pypi/pyversions/zyte-api.svg
   :target: https://pypi.python.org/pypi/zyte-api
   :alt: Supported Python Versions

.. image:: https://github.com/zytedata/python-zyte-api/actions/workflows/test.yml/badge.svg
   :target: https://github.com/zytedata/python-zyte-api/actions/workflows/test.yml
   :alt: Build Status

.. image:: https://codecov.io/github/zytedata/zyte-api/coverage.svg?branch=master
   :target: https://codecov.io/gh/zytedata/zyte-api
   :alt: Coverage report

.. description-start

Command-line client and Python client library for `Zyte API`_.

.. _Zyte API: https://docs.zyte.com/zyte-api/get-started.html

.. description-end

Installation
============

.. install-start

.. code-block:: shell

    pip install zyte-api

Or, to use x402_:

.. _x402: https://www.x402.org/

.. code-block:: shell

    pip install zyte-api[x402]

.. note:: Python 3.10+ is required.

.. install-end

Basic usage
===========

.. basic-key-start

Set your API key
----------------

.. key-get-start

After you `sign up for a Zyte API account
<https://app.zyte.com/account/signup/zyteapi>`_, copy `your API key
<https://app.zyte.com/o/zyte-api/api-access>`_.

.. key-get-end
.. basic-key-end

.. basic-start


Use the command-line client
---------------------------

Then you can use the zyte-api command-line client to send Zyte API requests.
First create a text file with a list of URLs:

.. code-block:: none

    https://books.toscrape.com
    https://quotes.toscrape.com

And then call ``zyte-api`` from your shell:

.. code-block:: shell

    zyte-api url-list.txt --api-key YOUR_API_KEY --output results.jsonl


Use the Python sync API
-----------------------

For very basic Python scripts, use the sync API:

.. code-block:: python

    from zyte_api import ZyteAPI

    client = ZyteAPI(api_key="YOUR_API_KEY")
    response = client.get({"url": "https://toscrape.com", "httpResponseBody": True})


Use the Python async API
------------------------

For asyncio code, use the async API:

.. code-block:: python

    import asyncio

    from zyte_api import AsyncZyteAPI


    async def main():
        client = AsyncZyteAPI(api_key="YOUR_API_KEY")
        response = await client.get(
            {"url": "https://toscrape.com", "httpResponseBody": True}
        )


    asyncio.run(main())

.. basic-end

Read the `documentation <https://python-zyte-api.readthedocs.io>`_  for more
information.

* Documentation: https://python-zyte-api.readthedocs.io
* Source code: https://github.com/zytedata/python-zyte-api
* Issue tracker: https://github.com/zytedata/python-zyte-api/issues
