ActorServerClientAsync
Hierarchy
- ResourceClientAsync
- ActorServerClientAsync
Index
Methods
Properties
Methods
__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
HTTP client for making requests.
keyword-onlyresource_path: str
Resource endpoint path (e.g., 'actors', 'datasets').
keyword-onlyclient_registry: ClientRegistryAsync
Bundle of client classes for dependency injection.
optionalkeyword-onlyresource_id: str | None = None
Optional resource ID for single-resource clients.
optionalkeyword-onlyparams: 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
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, orlatestif none is set. Use it to generate an HTTP client for the server, and point that client at the URL returned byget_url.https://docs.apify.com/platform/actors/development/actor-definition/web-server-schema
Parameters
optionalkeyword-onlytimeout: Timeout = 'short'
Timeout for each API HTTP request.
Returns dict[str, Any] | None
The OpenAPI specification of the Actor's server, or
Noneif the Actor's definition doesn't include one.
get_url
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 orget_openapi_specand 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.Parameters
optionalkeyword-onlytimeout: Timeout = 'short'
Timeout for the API HTTP request.
Returns str
The URL of the Actor's server.
request
Send an HTTP request to the Actor's server.
The request goes to the URL returned by
get_urland carries the client's token in theX-Apify-Authorizationheader, which the platform consumes, so it never reaches the Actor's code. Headers you pass,Authorizationincluded, 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 tolong.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
compressionis set, since the Actor's server may not decode a compressed body.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 inparams. A fragment (#...) is dropped, since it is never sent to the server.optionalkeyword-onlymethod: HttpMethod = 'GET'
HTTP method of the request.
optionalkeyword-onlyparams: QueryParams | None = None
Query parameters of the request, converted the same way as for API calls: booleans become
trueorfalse, a list of strings becomes one comma-separated value, a datetime becomes an ISO 8601 string in UTC, andNonevalues 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 | None = None
JSON-serializable request body. Cannot be used together with
data.optionalkeyword-onlycompression: (HttpCompressionAlgorithm | HttpCompressor) | None = None
Compression algorithm for the request body, as a string literal or an
HttpCompressorinstance. The body is compressed under the same conditions as for API calls. Set it only if the Actor's server decodes the resultingContent-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_bytesin the async client). The response holds its connection open until you close it.optionalkeyword-onlytimeout: Timeout = 'long'
Timeout for the HTTP request. With
stream, it bounds the wait for the server to start responding.
Returns HttpResponse
The response of the Actor's server.
Properties
resource_id
Get the resource ID.
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
ActorClientAsyncclass.