| id | introduction |
|---|---|
| title | Overview |
| slug | / |
| description | The official Python library to access the Apify API, with automatic retries, async support, and comprehensive API coverage. |
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock';
import UsageAsyncExample from '!!raw-loader!./code/01_usage_async.py'; import UsageSyncExample from '!!raw-loader!./code/01_usage_sync.py';
The Apify API client for Python is the official library to access the Apify REST API from your Python applications. It provides useful features like automatic retries and convenience functions that improve the experience of using the Apify API.
The client simplifies interaction with the Apify platform by providing:
- Intuitive methods for working with Actors, Datasets, Key-value stores, and other Apify resources
- Both synchronous and asynchronous interfaces for flexible integration
- Built-in retries with exponential backoff for failed requests
- Comprehensive API coverage with JSON encoding (UTF-8) for all requests and responses
apify-client requires Python 3.11 or higher. Python is available for download on the official website. Check your current Python version by running:
python --versionThe Apify client is available as the apify-client package on PyPI or on conda-forge.
For better request-body compression, opt in to brotli, which compresses better than gzip, especially for large payloads. Install the optional extra:
For details, see HTTP compression.
The client uses Impit as its default HTTP transport. To use the built-in HTTPX2 transport, install the optional httpx2 extra, which provides Pydantic's maintained continuation of HTTPX:
For synchronous and asynchronous examples and details about the shared architecture, see HTTP clients.
The following example shows how to run an Actor and retrieve its results:
{UsageAsyncExample} {UsageSyncExample}You can find your API token in the Integrations section of Apify Console. See the Quick start guide for more details on authentication.