ActorServerClient
Hierarchy
- ResourceClient
- ActorServerClient
Index
Properties
inheritedapifyClient
inheritedbaseUrl
inheritedhttpClient
optionalinheritedid
optionalinheritedparams
inheritedpublicBaseUrl
Added in 2.17.0
inheritedresourcePath
optionalinheritedsafeId
inheritedurl
Methods
getOpenApiSpec
Returns 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
actorStandby.build, orlatestif none is set. Use it to generate an HTTP client for the server, and point that client at the URL returned by getUrl.Parameters
options: TimeoutOptions = {}
Request options
Returns Promise<undefined | Record<string, unknown>>
The OpenAPI specification of the Actor's server, or
undefinedif the Actor's definition doesn't include oneThrows - When the Actor is not a Server Actor, or the build that serves its server interface doesn't exist.
Throws - When the Actor does not exist.
getUrl
Returns the URL of the Actor's server.
The URL is the Actor's
standbyUrl, fetched from the API by the first call of this method or getOpenApiSpec 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.Parameters
options: TimeoutOptions = {}
Request options
Returns Promise<string>
The URL of the Actor's server
Throws - When the Actor is not a Server Actor.
Throws - When the Actor does not exist.
request
Sends an HTTP request to the Actor's server.
The request goes to the URL returned by getUrl and carries the client's token in the
X-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 to'long'.The method resolves to 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. A browser follows redirects itself, though, so there the token goes with a redirect. Request bodies are sent uncompressed unless
compressionis set, since the Actor's server may not decode a compressed body.Parameters
optionalpath: string
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, can't be sent to another host. Pass the query inparams. A fragment (#...) is dropped, since it's never sent to the server.optionaloptions: ActorServerRequestOptions & { responseType?: parsed }
Request options
Returns Promise<ApifyResponse<T>>
The response of the Actor's server, with the body in the form
responseTypeasks for. An error response whose body doesn't parse as its content type comes with the raw bytes indata.Throws - When the Actor is not a Server Actor.
Throws - When a success response's body doesn't parse as its content type, with
responseType: 'parsed'.Throws - When the Actor does not exist.
Client for the server interface of a specific Actor.
Provides methods to work with the web server of a Server Actor, such as sending it requests or getting its OpenAPI specification. Get an instance with ActorClient.server.