{"id":7890,"library":"zyte-api","title":"Zyte API Python Client","description":"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.","status":"active","version":"0.9.0","language":"python","source_language":"en","source_url":"https://github.com/zytedata/python-zyte-api","tags":["web scraping","api client","async","zyte api","rendering","headless browser"],"install":[{"cmd":"pip install zyte-api","lang":"bash","label":"Install `zyte-api`"}],"dependencies":[{"reason":"Provides asynchronous HTTP client capabilities for API communication.","package":"aiohttp"},{"reason":"Used for defining data classes for API request and response models.","package":"attrs"}],"imports":[{"wrong":"from zyte_api.zyte_api import ZyteAPI","symbol":"ZyteAPI","correct":"from zyte_api import ZyteAPI"},{"symbol":"AsyncZyteAPI","correct":"from zyte_api import AsyncZyteAPI"},{"symbol":"AggressiveRetryFactory","correct":"from zyte_api import AggressiveRetryFactory"}],"quickstart":{"code":"import os\nimport asyncio\nfrom zyte_api.zyte_api import ZyteAPI\n\napi_key = os.environ.get('ZYTE_API_KEY', '') # Set ZYTE_API_KEY environment variable or replace with your key\n\nasync def main():\n    if not api_key:\n        print(\"ZYTE_API_KEY environment variable not set. Skipping quickstart example.\")\n        return\n\n    api = ZyteAPI(api_key=api_key)\n    try:\n        print(\"Making a request to Zyte API for www.zyte.com...\")\n        result = await api.request_render(\n            url=\"https://www.zyte.com/\",\n            browserHtml=True,\n            screenshot=True,\n            httpResponseBody=True,\n            javascript=True\n        )\n\n        print(f\"Request Status: {result.status}\")\n        if result.browserData:\n            print(f\"Page title: {result.browserData.title}\")\n        if result.browserHtml:\n            print(f\"HTML (first 100 chars): {result.browserHtml[:100]}...\")\n        if result.screenshot:\n            print(f\"Screenshot (base64, first 50 chars): {result.screenshot[:50]}...\")\n        print(\"Successfully received Zyte API response.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"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."},"warnings":[{"fix":"Update your code to use attribute access for `RequestResult` objects, e.g., `result.field_name`.","message":"Starting from version 0.6.0, `ZyteAPI` methods (e.g., `request_render`) return a `RequestResult` object instead of a dictionary. Access data using dot notation (e.g., `result.browserData.title`) instead of dictionary-like square brackets (`result['browserData']['title']`).","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Wrap your API calls in an `async` function and use `await` for each call. Execute the main `async` function using `asyncio.run()`.","message":"The `ZyteAPI` client is primarily asynchronous. All API request methods (e.g., `request_render`) are coroutines and must be `await`ed within an `async` function. Running directly without `await` will result in `RuntimeWarning: coroutine was never awaited`.","severity":"gotcha","affected_versions":"all"},{"fix":"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')`.","message":"The Zyte API key is mandatory for authentication. It must be provided either via the `ZYTE_API_KEY` environment variable or passed directly to the `ZyteAPI` constructor as the `api_key` argument. Failure to do so will result in authentication errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade your Python environment to 3.8 or newer, or specify `zyte-api<0.7.0` in your `requirements.txt`.","message":"Support for Python 3.7 was dropped in version 0.7.0. If you are using Python 3.7, you must either upgrade your Python version to 3.8 or higher, or pin your `zyte-api` dependency to a version less than 0.7.0 (e.g., `zyte-api<0.7.0`).","severity":"breaking","affected_versions":">=0.7.0"}],"env_vars":null,"search_vec":"'0.9.0':48 'access':21 'activ':51 'api':2,8,18,39,59,63 'async':61 'asynchron':13 'automat':31 'browser':29,66 'client':4,10,60 'communic':40 'content':32 'current':45 'develop':52 'enabl':19 'extract':33 'frequent':54 'function':25 'handl':38 'headless':65 'http':35 'interfac':14 'minor':55 'pars':44 'programmat':20 'provid':11 'python':3,9 'releas':56 'render':30,64 'request':36 'result':43 'retri':41 'scrape':24,58 'see':50 'smart':28 'version':47 'web':23,57 'zyte':1,7,17,62 'zyte-api':6","created_at":"2026-04-16T14:17:48.126611+00:00","updated_at":"2026-04-16T14:17:48.126611+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.10.0","cli_name":"zyte-api","cli_version":"usage: zyte-api [-h] [--intype {txt,jl}] [--limit LIMIT] [--output OUTPUT]","type":"library","homepage":"https://www.zyte.com","github":"https://github.com/zytedata/python-zyte-api","docs":"https://python-zyte-api.readthedocs.io/en/stable/","changelog":null,"pypi":"https://pypi.org/project/zyte-api/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}