The `zyte-api` Python client provides an asynchronous interface to the Zyte API, enabling programmatic access to web scraping functionalities such as smart browser rendering, automatic content extraction, and HTTP requests. It handles API communication, retries, and result parsing. Currently at version 0.9.0, it sees active development with frequent minor releases.
pip install zyte-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `ZyteAPI` client with an API key (preferably from an environment variable) and make an asynchronous `request_render` call to fetch HTML, a screenshot, and page data for a given URL. It uses `asyncio.run()` to execute the asynchronous operation.
Update your code to use attribute access for `RequestResult` objects, e.g., `result.field_name`.
Wrap your API calls in an `async` function and use `await` for each call. Execute the main `async` function using `asyncio.run()`.
Ensure `os.environ['ZYTE_API_KEY']` is set with your valid Zyte API key, or instantiate the client as `api = ZyteAPI(api_key='YOUR_KEY')`.
Upgrade your Python environment to 3.8 or newer, or specify `zyte-api<0.7.0` in your `requirements.txt`.