# ApifyClientAsync<!-- -->

Asynchronous client for the Apify API.

This is the main entry point for interacting with the Apify platform using async/await. 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

```
import asyncio



from apify_client import ApifyClientAsync





async def main() -> None:

    client = ApifyClientAsync(token='MY-APIFY-TOKEN')



    # Start an Actor and wait for it to finish.

    actor_client = client.actor('apify/python-example')

    run = await actor_client.call(run_input={'first_number': 1, 'second_number': 2})



    # Fetch results from the run's default dataset.

    if run is not None:

        dataset_client = client.dataset(run.default_dataset_id)

        items = (await dataset_client.list_items()).items

        for item in items:

            print(item)





asyncio.run(main())
```

## Index[](#Index)

### Methods

* [\_\_init\_\_](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#__init__)
* [actor](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#actor)
* [actors](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#actors)
* [build](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#build)
* [builds](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#builds)
* [dataset](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#dataset)
* [datasets](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#datasets)
* [key_value_store](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#key_value_store)
* [key_value_stores](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#key_value_stores)
* [log](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#log)
* [request_queue](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#request_queue)
* [request_queues](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#request_queues)
* [run](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#run)
* [runs](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#runs)
* [schedule](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#schedule)
* [schedules](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#schedules)
* [store](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#store)
* [task](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#task)
* [tasks](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#tasks)
* [user](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#user)
* [webhook](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#webhook)
* [webhook_dispatch](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#webhook_dispatch)
* [webhook_dispatches](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#webhook_dispatches)
* [webhooks](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#webhooks)
* [with_custom_http_client](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#with_custom_http_client)

### Properties

* [http_client](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#http_client)
* [token](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md#token)

## Methods<!-- -->[](#Methods)

### [](#__init__)\_\_init\_\_

* **\_\_init\_\_**(token, \*, api_url, api_public_url, max_retries, min_delay_between_retries, timeout_short, timeout_medium, timeout_long, timeout_max, headers, user_agent_suffix, compression): None

- Initialize the Apify API client.

  To use a custom HTTP client, use the `with_custom_http_client` class method instead.

  ***

  #### Parameters

  * ##### optionaltoken: str | None = <!-- -->None

    The Apify API token. You can find your token on the [Integrations](https://console.apify.com/account/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_url` should be set as well. The `/v2` API version segment is appended unless the URL path already ends with it.

  * ##### optionalkeyword-onlyapi_public_url: str | None = <!-- -->DEFAULT_API_URL

    The globally accessible URL of the Apify API server. Should be set only if `api_url` is an internal URL that is not globally accessible. Defaults to <https://api.apify.com>. The `/v2` API version segment is appended unless the URL path already ends with it.

  * ##### optionalkeyword-onlymax_retries: int = <!-- -->DEFAULT_MAX_RETRIES

    How many times to retry a failed request at most. Set to 0 to disable retries.

  * ##### 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_short: timedelta = <!-- -->DEFAULT_TIMEOUT_SHORT

    Default timeout for short-duration API operations (simple CRUD operations, ...).

  * ##### optionalkeyword-onlytimeout_medium: timedelta = <!-- -->DEFAULT_TIMEOUT_MEDIUM

    Default timeout for medium-duration API operations (batch operations, listing, ...).

  * ##### optionalkeyword-onlytimeout_long: timedelta = <!-- -->DEFAULT_TIMEOUT_LONG

    Default timeout for long-duration API operations (long-polling, streaming, ...).

  * ##### optionalkeyword-onlytimeout_max: timedelta = <!-- -->DEFAULT_TIMEOUT_MAX

    Maximum timeout cap for any single request attempt, including tier and per-call timeouts.

  * ##### optionalkeyword-onlyheaders: dict\[str, str] | None = <!-- -->None

    Additional HTTP headers to include in all API requests.

  * ##### optionalkeyword-onlyuser_agent_suffix: (str | [list](https://docs.apify.com/api/client/python/reference/class/ActorCollectionClient.md#list)\[str]) | None = <!-- -->None

    Extra part or parts appended to the default `User-Agent` header, separated by `; `, for example to identify the tool built on top of the client. With `with_custom_http_client`, pass it to the HTTP client's constructor.

  * ##### optionalkeyword-onlycompression: [HttpCompressionAlgorithm](https://docs.apify.com/api/client/python/reference.md#HttpCompressionAlgorithm) | [HttpCompressor](https://docs.apify.com/api/client/python/reference/class/HttpCompressor.md) = <!-- -->'gzip'

    Compression algorithm for request bodies. Defaults to `'gzip'`. Pass a string literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control. `'brotli'` needs the `brotli` extra (`pip install "apify-client[brotli]"`). It is not the default because the `brotli` package is a C extension, while gzip support is part of the Python standard library.

  #### Returns None

### [](#actor)actor

* **actor**(actor_id): [ActorClientAsync](https://docs.apify.com/api/client/python/reference/class/ActorClientAsync.md)

- Get the sub-client for a specific Actor.

  ***

  #### Parameters

  * ##### actor_id: str

    ID of the Actor to be manipulated.

  #### Returns [ActorClientAsync](https://docs.apify.com/api/client/python/reference/class/ActorClientAsync.md)

### [](#actors)actors

* **actors**(): [ActorCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/ActorCollectionClientAsync.md)

- Get the sub-client for the Actor collection, allowing to list and create Actors.

  ***

  #### Returns [ActorCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/ActorCollectionClientAsync.md)

### [](#build)build

* **build**(build_id): [BuildClientAsync](https://docs.apify.com/api/client/python/reference/class/BuildClientAsync.md)

- Get the sub-client for a specific Actor build.

  ***

  #### Parameters

  * ##### build_id: str

    ID of the Actor build to be manipulated.

  #### Returns [BuildClientAsync](https://docs.apify.com/api/client/python/reference/class/BuildClientAsync.md)

### [](#builds)builds

* **builds**(): [BuildCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/BuildCollectionClientAsync.md)

- Get the sub-client for the build collection, allowing to list builds.

  ***

  #### Returns [BuildCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/BuildCollectionClientAsync.md)

### [](#dataset)dataset

* **dataset**(dataset_id): [DatasetClientAsync](https://docs.apify.com/api/client/python/reference/class/DatasetClientAsync.md)

- Get the sub-client for a specific dataset.

  ***

  #### Parameters

  * ##### dataset_id: str

    ID of the dataset to be manipulated.

  #### Returns [DatasetClientAsync](https://docs.apify.com/api/client/python/reference/class/DatasetClientAsync.md)

### [](#datasets)datasets

* **datasets**(): [DatasetCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/DatasetCollectionClientAsync.md)

- Get the sub-client for the dataset collection, allowing to list and create datasets.

  ***

  #### Returns [DatasetCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/DatasetCollectionClientAsync.md)

### [](#key_value_store)key_value_store

* **key_value_store**(key_value_store_id): [KeyValueStoreClientAsync](https://docs.apify.com/api/client/python/reference/class/KeyValueStoreClientAsync.md)

- 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 [KeyValueStoreClientAsync](https://docs.apify.com/api/client/python/reference/class/KeyValueStoreClientAsync.md)

### [](#key_value_stores)key_value_stores

* **key_value_stores**(): [KeyValueStoreCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/KeyValueStoreCollectionClientAsync.md)

- Get the sub-client for the key-value store collection, allowing to list and create key-value stores.

  ***

  #### Returns [KeyValueStoreCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/KeyValueStoreCollectionClientAsync.md)

### [](#log)log

* **log**(build_or_run_id): [LogClientAsync](https://docs.apify.com/api/client/python/reference/class/LogClientAsync.md)

- 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 [LogClientAsync](https://docs.apify.com/api/client/python/reference/class/LogClientAsync.md)

### [](#request_queue)request_queue

* **request_queue**(request_queue_id, \*, client_key): [RequestQueueClientAsync](https://docs.apify.com/api/client/python/reference/class/RequestQueueClientAsync.md)

- 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 [RequestQueueClientAsync](https://docs.apify.com/api/client/python/reference/class/RequestQueueClientAsync.md)

### [](#request_queues)request_queues

* **request_queues**(): [RequestQueueCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/RequestQueueCollectionClientAsync.md)

- Get the sub-client for the request queue collection, allowing to list and create request queues.

  ***

  #### Returns [RequestQueueCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/RequestQueueCollectionClientAsync.md)

### [](#run)run

* **run**(run_id): [RunClientAsync](https://docs.apify.com/api/client/python/reference/class/RunClientAsync.md)

- Get the sub-client for a specific Actor run.

  ***

  #### Parameters

  * ##### run_id: str

    ID of the Actor run to be manipulated.

  #### Returns [RunClientAsync](https://docs.apify.com/api/client/python/reference/class/RunClientAsync.md)

### [](#runs)runs

* **runs**(): [RunCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/RunCollectionClientAsync.md)

- Get the sub-client for the run collection, allowing to list Actor runs.

  ***

  #### Returns [RunCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/RunCollectionClientAsync.md)

### [](#schedule)schedule

* **schedule**(schedule_id): [ScheduleClientAsync](https://docs.apify.com/api/client/python/reference/class/ScheduleClientAsync.md)

- Get the sub-client for a specific schedule.

  ***

  #### Parameters

  * ##### schedule_id: str

    ID of the schedule to be manipulated.

  #### Returns [ScheduleClientAsync](https://docs.apify.com/api/client/python/reference/class/ScheduleClientAsync.md)

### [](#schedules)schedules

* **schedules**(): [ScheduleCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/ScheduleCollectionClientAsync.md)

- Get the sub-client for the schedule collection, allowing to list and create schedules.

  ***

  #### Returns [ScheduleCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/ScheduleCollectionClientAsync.md)

### [](#store)store

* **store**(): [StoreCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/StoreCollectionClientAsync.md)

- Get the sub-client for the Apify Store, allowing to list Actors published in the store.

  ***

  #### Returns [StoreCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/StoreCollectionClientAsync.md)

### [](#task)task

* **task**(task_id): [TaskClientAsync](https://docs.apify.com/api/client/python/reference/class/TaskClientAsync.md)

- Get the sub-client for a specific Actor task.

  ***

  #### Parameters

  * ##### task_id: str

    ID of the task to be manipulated.

  #### Returns [TaskClientAsync](https://docs.apify.com/api/client/python/reference/class/TaskClientAsync.md)

### [](#tasks)tasks

* **tasks**(): [TaskCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/TaskCollectionClientAsync.md)

- Get the sub-client for the task collection, allowing to list and create Actor tasks.

  ***

  #### Returns [TaskCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/TaskCollectionClientAsync.md)

### [](#user)user

* **user**(user_id): [UserClientAsync](https://docs.apify.com/api/client/python/reference/class/UserClientAsync.md)

- 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 [UserClientAsync](https://docs.apify.com/api/client/python/reference/class/UserClientAsync.md)

### [](#webhook)webhook

* **webhook**(webhook_id): [WebhookClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookClientAsync.md)

- Get the sub-client for a specific webhook.

  ***

  #### Parameters

  * ##### webhook_id: str

    ID of the webhook to be manipulated.

  #### Returns [WebhookClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookClientAsync.md)

### [](#webhook_dispatch)webhook_dispatch

* **webhook_dispatch**(webhook_dispatch_id): [WebhookDispatchClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookDispatchClientAsync.md)

- Get the sub-client for a specific webhook dispatch.

  ***

  #### Parameters

  * ##### webhook_dispatch_id: str

    ID of the webhook dispatch to access.

  #### Returns [WebhookDispatchClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookDispatchClientAsync.md)

### [](#webhook_dispatches)webhook_dispatches

* **webhook_dispatches**(): [WebhookDispatchCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookDispatchCollectionClientAsync.md)

- Get the sub-client for the webhook dispatch collection, allowing to list webhook dispatches.

  ***

  #### Returns [WebhookDispatchCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookDispatchCollectionClientAsync.md)

### [](#webhooks)webhooks

* **webhooks**(): [WebhookCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookCollectionClientAsync.md)

- Get the sub-client for the webhook collection, allowing to list and create webhooks.

  ***

  #### Returns [WebhookCollectionClientAsync](https://docs.apify.com/api/client/python/reference/class/WebhookCollectionClientAsync.md)

### [](#with_custom_http_client)with_custom_http_client

* **with_custom_http_client**(token, \*, api_url, api_public_url, http_client): [ApifyClientAsync](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md)

- Create an `ApifyClientAsync` instance 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 controls its transport configuration; the shared `HttpClientAsync` pipeline handles request preparation, retries, timeouts, and API errors unless overridden.

  ### Usage

  ```
  from apify_client import ApifyClientAsync

  from apify_client.http_clients import HttpClientAsync, HttpResponse





  class MyHttpClientAsync(HttpClientAsync):

      async def send_request(self, *, method, url, headers, content, timeout, stream) -> HttpResponse:

          ...





  client = ApifyClientAsync.with_custom_http_client(

      token='MY-APIFY-TOKEN',

      http_client=MyHttpClientAsync(),

  )
  ```

  ***

  #### Parameters

  * ##### optionaltoken: str | None = <!-- -->None

    The Apify API token. It is set as the `Authorization` header on the custom client, unless the client already has one configured.

  * ##### optionalkeyword-onlyapi_url: str = <!-- -->DEFAULT_API_URL

    The URL of the Apify API server to connect to. Defaults to <https://api.apify.com>. The `/v2` API version segment is appended unless the URL path already ends with it.

  * ##### optionalkeyword-onlyapi_public_url: str | None = <!-- -->DEFAULT_API_URL

    The globally accessible URL of the Apify API server. Defaults to <https://api.apify.com>. The `/v2` API version segment is appended unless the URL path already ends with it.

  * ##### keyword-onlyhttp_client: [HttpClientAsync](https://docs.apify.com/api/client/python/reference/class/HttpClientAsync.md)

    A custom HTTP client instance extending `HttpClientAsync`.

  #### Returns [ApifyClientAsync](https://docs.apify.com/api/client/python/reference/class/ApifyClientAsync.md)

## Properties<!-- -->[](#Properties)

### [](#http_client)http_client

http_client: [HttpClientAsync](https://docs.apify.com/api/client/python/reference/class/HttpClientAsync.md)

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 `ImpitHttpClientAsync` otherwise (lazily created on first access).

### [](#token)token

token: str | None

The Apify API token used by the client.
