ApifyClient
Index
Methods
__init__
Initialize the Apify API client.
To use a custom HTTP client, use the
with_custom_http_clientclass method instead.Parameters
optionaltoken: str | None = None
The Apify API token. You can find your token on the Integrations page in the Apify Console.
optionalkeyword-onlyapi_url: str = DEFAULT_API_URL
The URL of the Apify API server to connect to. Defaults to https://api.apify.com. It can be an internal URL that is not globally accessible, in which case
api_public_urlshould be set as well.optionalkeyword-onlyapi_public_url: str | None = DEFAULT_API_URL
The globally accessible URL of the Apify API server. Should be set only if
api_urlis an internal URL that is not globally accessible. Defaults to https://api.apify.com.optionalkeyword-onlymax_retries: int = DEFAULT_MAX_RETRIES
How many times to retry a failed request at most.
optionalkeyword-onlymin_delay_between_retries: timedelta = DEFAULT_MIN_DELAY_BETWEEN_RETRIES
How long will the client wait between retrying requests (increases exponentially from this value).
optionalkeyword-onlytimeout: timedelta = DEFAULT_TIMEOUT
The socket timeout of the HTTP requests sent to the Apify API.
optionalkeyword-onlyheaders: dict[str, str] | None = None
Additional HTTP headers to include in all API requests.
Returns None
actor
Get the sub-client for a specific Actor.
Parameters
actor_id: str
ID of the Actor to be manipulated.
Returns ActorClient
actors
Get the sub-client for the Actor collection, allowing to list and create Actors.
Returns ActorCollectionClient
build
Get the sub-client for a specific Actor build.
Parameters
build_id: str
ID of the Actor build to be manipulated.
Returns BuildClient
builds
Get the sub-client for the build collection, allowing to list builds.
Returns BuildCollectionClient
dataset
Get the sub-client for a specific dataset.
Parameters
dataset_id: str
ID of the dataset to be manipulated.
Returns DatasetClient
datasets
Get the sub-client for the dataset collection, allowing to list and create datasets.
Returns DatasetCollectionClient
key_value_store
Get the sub-client for a specific key-value store.
Parameters
key_value_store_id: str
ID of the key-value store to be manipulated.
Returns KeyValueStoreClient
key_value_stores
Get the sub-client for the key-value store collection, allowing to list and create key-value stores.
Returns KeyValueStoreCollectionClient
log
Get the sub-client for retrieving logs of an Actor build or run.
Parameters
build_or_run_id: str
ID of the Actor build or run for which to access the log.
Returns LogClient
request_queue
Get the sub-client for a specific request queue.
Parameters
request_queue_id: str
ID of the request queue to be manipulated.
optionalkeyword-onlyclient_key: str | None = None
A unique identifier of the client accessing the request queue.
Returns RequestQueueClient
request_queues
Get the sub-client for the request queue collection, allowing to list and create request queues.
Returns RequestQueueCollectionClient
run
Get the sub-client for a specific Actor run.
Parameters
run_id: str
ID of the Actor run to be manipulated.
Returns RunClient
runs
Get the sub-client for the run collection, allowing to list Actor runs.
Returns RunCollectionClient
schedule
Get the sub-client for a specific schedule.
Parameters
schedule_id: str
ID of the schedule to be manipulated.
Returns ScheduleClient
schedules
Get the sub-client for the schedule collection, allowing to list and create schedules.
Returns ScheduleCollectionClient
store
Get the sub-client for the Apify Store, allowing to list Actors published in the store.
Returns StoreCollectionClient
task
Get the sub-client for a specific Actor task.
Parameters
task_id: str
ID of the task to be manipulated.
Returns TaskClient
tasks
Get the sub-client for the task collection, allowing to list and create Actor tasks.
Returns TaskCollectionClient
user
Get the sub-client for querying user data.
Parameters
optionaluser_id: str | None = None
ID of user to be queried. If None, queries the user belonging to the token supplied to the client.
Returns UserClient
webhook
Get the sub-client for a specific webhook.
Parameters
webhook_id: str
ID of the webhook to be manipulated.
Returns WebhookClient
webhook_dispatch
Get the sub-client for a specific webhook dispatch.
Parameters
webhook_dispatch_id: str
ID of the webhook dispatch to access.
Returns WebhookDispatchClient
webhook_dispatches
Get the sub-client for the webhook dispatch collection, allowing to list webhook dispatches.
Returns WebhookDispatchCollectionClient
webhooks
Get the sub-client for the webhook collection, allowing to list and create webhooks.
Returns WebhookCollectionClient
with_custom_http_client
Create an
ApifyClientinstance with a custom HTTP client.Use this alternative constructor when you want to provide your own HTTP client implementation instead of the default one. The custom client is responsible for its own configuration (retries, timeouts, headers, etc.).
Usage
from apify_client import ApifyClient, HttpClient, HttpResponse
class MyHttpClient(HttpClient):
def call(self, *, method, url, **kwargs) -> HttpResponse:
...
client = ApifyClient.with_custom_http_client(
token='MY-APIFY-TOKEN',
http_client=MyHttpClient(),
)Parameters
optionaltoken: str | None = None
The Apify API token.
optionalkeyword-onlyapi_url: str = DEFAULT_API_URL
The URL of the Apify API server to connect to. Defaults to https://api.apify.com.
optionalkeyword-onlyapi_public_url: str | None = DEFAULT_API_URL
The globally accessible URL of the Apify API server. Defaults to https://api.apify.com.
keyword-onlyhttp_client: HttpClient
A custom HTTP client instance extending
HttpClient.
Returns ApifyClient
Properties
http_client
The HTTP client instance used for API communication.
Returns the custom HTTP client if one was provided via with_custom_http_client,
or the default ImpitHttpClient otherwise (lazily created on first access).
token
The Apify API token used by the client.
Synchronous client for the Apify API.
This is the main entry point for interacting with the Apify platform. It provides methods to access resource-specific sub-clients for managing Actors, runs, datasets, key-value stores, request queues, schedules, webhooks, and more.
The client automatically handles retries with exponential backoff for failed or rate-limited requests.
Usage