# ActorServerClientAsync<!-- -->

Sub-client for the server interface of a specific Actor.

Provides methods to work with the web server of a Server Actor, e.g. send it requests or get its OpenAPI specification. Obtain an instance via an appropriate method on the `ActorClientAsync` class.

### Hierarchy

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

## Index[](#Index)

### Methods

* [\_\_init\_\_](https://docs.apify.com/api/client/python/reference/class/ActorServerClientAsync.md#__init__)
* [get_openapi_spec](https://docs.apify.com/api/client/python/reference/class/ActorServerClientAsync.md#get_openapi_spec)
* [get_url](https://docs.apify.com/api/client/python/reference/class/ActorServerClientAsync.md#get_url)
* [request](https://docs.apify.com/api/client/python/reference/class/ActorServerClientAsync.md#request)

### Properties

* [resource_id](https://docs.apify.com/api/client/python/reference/class/ActorServerClientAsync.md#resource_id)

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

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

* **\_\_init\_\_**(\*, base_url, public_base_url, http_client, resource_path, client_registry, resource_id, params, api_base_url): None

- Overrides [ResourceClientAsync.\_\_init\_\_](https://docs.apify.com/api/client/python/reference/class/ResourceClientAsync.md#__init__)

  Initialize the resource client.

  ***

  #### Parameters

  * ##### keyword-onlybase_url: str

    API base URL.

  * ##### keyword-onlypublic_base_url: str

    Public CDN base URL.

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

    HTTP client for making requests.

  * ##### keyword-onlyresource_path: str

    Resource endpoint path (e.g., 'actors', 'datasets').

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

    Bundle of client classes for dependency injection.

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

    Optional resource ID for single-resource clients.

  * ##### optionalkeyword-onlyparams: [QueryParams](https://docs.apify.com/api/client/python/reference.md#QueryParams) | None = <!-- -->None

    Optional default parameters for all requests.

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

    Base URL of the API itself, for clients of top-level resources. Defaults to `base_url`.

  #### Returns None

### [](#get_openapi_spec)get_openapi_spec

* async **get_openapi_spec**(\*, timeout): dict\[str, Any] | None

- Return the OpenAPI specification of the Actor's server.

  The specification is the web server schema from the Actor's definition, taken from the build that serves the server interface: the build set in `actor_standby.build`, or `latest` if none is set. Use it to generate an HTTP client for the server, and point that client at the URL returned by `get_url`.

  <https://docs.apify.com/platform/actors/development/actor-definition/web-server-schema>

  ***

  #### Parameters

  * ##### optionalkeyword-onlytimeout: [Timeout](https://docs.apify.com/api/client/python/reference.md#Timeout) = <!-- -->'short'

    Timeout for each API HTTP request.

  #### Returns dict\[str, Any] | None

  The OpenAPI specification of the Actor's server, or `None` if the Actor's definition doesn't include one.

### [](#get_url)get_url

* async **get_url**(\*, timeout): str

- Return the URL of the Actor's server.

  The URL is the Actor's `standby_url`, fetched from the API by the first call of this method or `get_openapi_spec` and reused by later calls on this client. Use it to call the server with another HTTP client, for example one generated from the server's OpenAPI specification.

  <https://docs.apify.com/platform/actors/running/standby>

  ***

  #### Parameters

  * ##### optionalkeyword-onlytimeout: [Timeout](https://docs.apify.com/api/client/python/reference.md#Timeout) = <!-- -->'short'

    Timeout for the API HTTP request.

  #### Returns str

  The URL of the Actor's server.

### [](#request)request

* async **request**(path, \*, method, params, headers, data, json, compression, stream, timeout): [HttpResponse](https://docs.apify.com/api/client/python/reference/class/HttpResponse.md)

- Send an HTTP request to the Actor's server.

  The request goes to the URL returned by `get_url` and carries the client's token in the `X-Apify-Authorization` header, which the platform consumes, so it never reaches the Actor's code. Headers you pass, `Authorization` included, reach the Actor's server as they are. The first request to an idle Actor waits for the platform to start a server run, which is why the timeout defaults to `long`.

  The method returns any response of the server, error statuses included. A rate-limit (429) or Service Unavailable (503) response is retried with the client's retry settings, and the last one is returned once the retries run out. The Actor's code can return these statuses too, and then it gets the request again. A redirect is returned as it is, since following it would send the token to a host the Actor's code picked. Request bodies are sent uncompressed unless `compression` is set, since the Actor's server may not decode a compressed body.

  <https://docs.apify.com/platform/actors/running/standby>

  ***

  #### Parameters

  * ##### optionalpath: str = <!-- -->'/'

    The path on the Actor's server, for example `/search`. It is always resolved against the server URL, so the request, and the token with it, cannot be sent to another host. Pass the query in `params`. A fragment (`#...`) is dropped, since it is never sent to the server.

  * ##### optionalkeyword-onlymethod: [HttpMethod](https://docs.apify.com/api/client/python/reference.md#HttpMethod) = <!-- -->'GET'

    HTTP method of the request.

  * ##### optionalkeyword-onlyparams: [QueryParams](https://docs.apify.com/api/client/python/reference.md#QueryParams) | None = <!-- -->None

    Query parameters of the request, converted the same way as for API calls: booleans become `true` or `false`, a list of strings becomes one comma-separated value, a datetime becomes an ISO 8601 string in UTC, and `None` values are left out.

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

    Additional headers of the request.

  * ##### optionalkeyword-onlydata: (str | bytes) | None = <!-- -->None

    Raw request body. Cannot be used together with `json`.

  * ##### optionalkeyword-onlyjson: [JsonSerializable](https://docs.apify.com/api/client/python/reference.md#JsonSerializable) | None = <!-- -->None

    JSON-serializable request body. Cannot be used together with `data`.

  * ##### 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)) | None = <!-- -->None

    Compression algorithm for the request body, as a string literal or an `HttpCompressor` instance. The body is compressed under the same conditions as for API calls. Set it only if the Actor's server decodes the resulting `Content-Encoding`.

  * ##### optionalkeyword-onlystream: bool = <!-- -->False

    Whether to return the response with the body unread, so it can be read in chunks with `iter_bytes` (`aiter_bytes` in the async client). The response holds its connection open until you close it.

  * ##### optionalkeyword-onlytimeout: [Timeout](https://docs.apify.com/api/client/python/reference.md#Timeout) = <!-- -->'long'

    Timeout for the HTTP request. With `stream`, it bounds the wait for the server to start responding.

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

  The response of the Actor's server.

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

### [](#resource_id)resource_id

resource_id: str | None

Inherited from [ResourceClientBase.resource_id](https://docs.apify.com/api/client/python/reference/class/ResourceClientBase.md#resource_id)

Get the resource ID.
