# ActorServerClient<!-- -->

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](https://docs.apify.com/api/client/js/reference/class/ActorClient.md#server).

### Hierarchy

* ResourceClient
  * *ActorServerClient*

```
const client = new ApifyClient({ token: 'my-token' });

const actorServerClient = client.actor('username/actor-name').server();



const response = await actorServerClient.request('/search', { params: { q: 'apify' } });

console.log(response.data);
```

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

## Index[](#Index)

### Properties

* [apifyClient](#apifyClient)
* [baseUrl](#baseUrl)
* [httpClient](#httpClient)
* [id](#id)
* [params](#params)
* [publicBaseUrl](#publicBaseUrl)
* [resourcePath](#resourcePath)
* [safeId](#safeId)
* [url](#url)

### Methods

* [getOpenApiSpec](#getOpenApiSpec)
* [getUrl](#getUrl)
* [request](#request)

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

### [](#apifyClient)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L40)inheritedapifyClient

apifyClient: [ApifyClient](https://docs.apify.com/api/client/js/reference/class/ApifyClient.md)

Inherited from ResourceClient.apifyClient

### [](#baseUrl)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L29)inheritedbaseUrl

baseUrl: string

Inherited from ResourceClient.baseUrl

### [](#httpClient)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L42)inheritedhttpClient

httpClient: [HttpClient](https://docs.apify.com/api/client/js/reference/class/HttpClient.md)

Inherited from ResourceClient.httpClient

### [](#id)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L25)optionalinheritedid

id?

<!-- -->

: string

Inherited from ResourceClient.id

### [](#params)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L44)optionalinheritedparams

params?

<!-- -->

: Record\<string, unknown>

Inherited from ResourceClient.params

### [](#publicBaseUrl)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L34)inheritedpublicBaseUrl

publicBaseUrl: string

Inherited from ResourceClient.publicBaseUrl

Added in 2.17.0

### [](#resourcePath)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L36)inheritedresourcePath

resourcePath: string

Inherited from ResourceClient.resourcePath

### [](#safeId)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L27)optionalinheritedsafeId

safeId?

<!-- -->

: string

Inherited from ResourceClient.safeId

### [](#url)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/base/api_client.ts#L38)inheritedurl

url: string

Inherited from ResourceClient.url

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

### [](#getOpenApiSpec)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/resource_clients/actor_server.ts#L135)getOpenApiSpec

* **getOpenApiSpec**(options): Promise\<undefined | Record\<string, unknown>>

- 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`, 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 getUrl.

  ***

  #### Parameters

  * ##### options: [TimeoutOptions](https://docs.apify.com/api/client/js/reference/interface/TimeoutOptions.md) = <!-- -->{}

    Request options

  #### Returns Promise\<undefined | Record\<string, unknown>>

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

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

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

### [](#getUrl)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/resource_clients/actor_server.ts#L106)getUrl

* **getUrl**(options): Promise\<string>

- 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](https://docs.apify.com/api/client/js/reference/interface/TimeoutOptions.md) = <!-- -->{}

    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.

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

### [](#request)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/resource_clients/actor_server.ts#L216)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/resource_clients/actor_server.ts#L221)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/resource_clients/actor_server.ts#L226)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/resource_clients/actor_server.ts#L231)[](https://github.com/apify/apify-client-js/blob/84036425d1fb761bc98185b09045076b3c86192b/src/resource_clients/actor_server.ts#L233)request

* **request**\<T>(path, options): Promise<[ApifyResponse](https://docs.apify.com/api/client/js/reference/interface/ApifyResponse.md)\<T>>
* **request**(path, options): Promise<[ApifyResponse](https://docs.apify.com/api/client/js/reference/interface/ApifyResponse.md)\<Uint8Array\<ArrayBufferLike>>>
* **request**(path, options): Promise<[ApifyResponse](https://docs.apify.com/api/client/js/reference/interface/ApifyResponse.md)\<ReadableStream\<Uint8Array\<ArrayBufferLike>>>>
* **request**(path, options): Promise<[ApifyResponse](https://docs.apify.com/api/client/js/reference/interface/ApifyResponse.md)\<any>>

- 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-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 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. In a browser the redirect response can't be read, so the request fails with an [ApifyClientError](https://docs.apify.com/api/client/js/reference/class/ApifyClientError.md) instead. Request bodies are sent uncompressed unless `compression` is 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 in `params`. A fragment (`#...`) is dropped, since it's never sent to the server.

  * ##### optionaloptions: [ActorServerRequestOptions](https://docs.apify.com/api/client/js/reference/interface/ActorServerRequestOptions.md) & { responseType?<!-- -->: parsed }

    Request options

  #### Returns Promise<[ApifyResponse](https://docs.apify.com/api/client/js/reference/interface/ApifyResponse.md)\<T>>

  The response of the Actor's server, with the body in the form `responseType` asks for. An error response whose body doesn't parse as its content type comes with the raw bytes in `data`.

  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.

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