Skip to content

Repository files navigation

python-zyte-api

PyPI VersionSupported Python VersionsBuild StatusCoverage report

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

Installation

pip install zyte-api

Or, to use x402:

pip install zyte-api[x402]

Note

Python 3.10+ is required.

Basic usage

Set your API key

After you sign up for a Zyte API account, copy your API key.

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:

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

And then call zyte-api from your 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:

fromzyte_apiimportZyteAPIclient=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:

importasynciofromzyte_apiimportAsyncZyteAPIasyncdefmain():
client=AsyncZyteAPI(api_key="YOUR_API_KEY")
response=awaitclient.get(
{"url": "https://toscrape.com", "httpResponseBody": True}
)
asyncio.run(main())

Read the documentation for more information.

About

Python client for Zyte API

Topics

Resources

Contributing

Stars

30 stars

Watchers

12 watching

Forks

Releases

Packages

Used by

Contributors

Languages