Command-line client and Python client library for Zyte API.
pip install zyte-api
Note
Python 3.9+ is required.
After you sign up for a Zyte API account, copy your API key.
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
For very basic Python scripts, use the sync API:
from zyte_api import ZyteAPI
client = ZyteAPI(api_key="YOUR_API_KEY")
response = client.get({"url": "https://toscrape.com", "httpResponseBody": True})
For asyncio code, use the async API:
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())
Read the documentation 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