The Apify Client for Python allows users to interact with the Apify platform, managing actors, datasets, key-value stores, and more. It provides both synchronous and asynchronous interfaces for web scraping and automation tasks. The current stable version is 2.5.0, with regular updates.
pip install apify-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Apify client, run a 'Hello World' actor, and retrieve its results from the default dataset. It emphasizes secure API token handling via environment variables.
Replace `ApifyClientSync(token='...')` or `ApifyClientAsync(token='...')` with `ApifyClient(token='...')`.
Update resource access calls. For example, `client.actors().get('id')` becomes `client.actor('id').get()`.Set the `APIFY_TOKEN` environment variable or pass `token='YOUR_APIFY_TOKEN'` directly to `ApifyClient()`.
Use `list_items()` with `limit` and `offset` parameters or, preferably, `iterate_items()` for efficient, paginated access to large datasets.
Ensure that the Docker container is using Python 3.10 or higher, as 'apify-client' requires Python 3.10 or higher. ([docs.apify.com](https://docs.apify.com/api/client/python/?utm_source=openai))
Verify that the Actor ID is correct and that the Actor exists on the Apify platform. ([docs.apify.com](https://docs.apify.com/api/client/python/docs/concepts/error-handling?utm_source=openai))
Implement exponential backoff and retry logic to handle rate limit errors. ([docs.apify.com](https://docs.apify.com/api/client/python/docs/concepts/retries?utm_source=openai))
Run `pip install apify-client` in your terminal to install the library.
Initialize the ApifyClient with a valid API token: `apify_client = ApifyClient('YOUR_API_TOKEN')`. You can find your API token in the Apify Console under 'Integrations'.