Skip to main content

Apify API client for Python

Apify API client for Python.

The Apify API Client for Python is the official library to access Apify API from your Python applications. It provides useful features like automatic retries and convenience functions to improve your experience with the Apify API.

pip install apify-client

For example, the Apify API Client for Python makes it easy to run your own Actors or Actors from the Apify Store by simply using the .call() method to start an Actor and wait for it to finish.

from apify_client import ApifyClientAsync


async def main() -> None:
apify_client = ApifyClientAsync('MY-APIFY-TOKEN')

# Start an Actor and wait for it to finish.
actor_client = apify_client.actor('john-doe/my-cool-actor')
call_result = await actor_client.call()

if call_result is None:
print('Actor run failed.')
return

# Fetch results from the Actor run's default dataset.
dataset_client = apify_client.dataset(call_result['defaultDatasetId'])
list_items_result = await dataset_client.list_items()
print(f'Dataset: {list_items_result}')