# 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, 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.

  * ##### 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>.

  * ##### 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\_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-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. Pass a string literal to select an algorithm, or an `HttpCompressor` instance for finer-grained control.

  #### 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>.

  * ##### 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: [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.
