# REST SDK: Constructor
> **Note**
>
> We've updated the style and readability of our API references, starting with JavaScript. Check out the [Pub/Sub JavaScript SDK API references](https://ably.com/docs/pub-sub/api/javascript/rest/rest-client.md) in their new location.
## Create a client
> **Note**
>
> The Swift and Objective-C SDK has no public REST client from version 2.0. The client returned by `[ARTPubSubDevice createClientWithOptions:]``PubSubDevice.createClient(options:)` makes the REST requests described on this page, such as `stats`, `time` and `request`, and its channels provide `history` and presence `get`. See the [realtime client](https://ably.com/docs/api/realtime-sdk.md) for its full API.
The Ably REST library constructor is overloaded allowing it to be instantiated using a [`ClientOptions`](#client-options) object, or more simply using a string containing an [API key](https://ably.com/docs/auth/basic.md) or [Token](https://ably.com/docs/auth/token.md).The PHP REST client is created with the `\Ably\PubSub\Server::createHttpClient()` factory, which accepts an options array, a [`ClientOptions`](#client-options) instance, or a string containing an [API key](https://ably.com/docs/auth/basic.md) or [Token](https://ably.com/docs/auth/token.md).The Go REST client is created with `pubsub.NewHTTPClient`, which takes `ClientOption` functions such as `pubsub.WithKey` (see [`ClientOptions`](#client-options)), imported from `github.com/ably/ably-pubsub-go/v2/server/pubsub`.The Ably REST client is created with the `create_http_client(**kwargs)` factory function, imported from `ably.pubsub.server`. It takes the [`ClientOptions`](#client-options) as keyword arguments, so a client can be created using an [API key](https://ably.com/docs/auth/basic.md) or [Token](https://ably.com/docs/auth/token.md) (`key=...` or `token=...`) alone, or with any further options.
`Ably::PubSub::Server.create_http_client(String key_or_token_id)`
`\Ably\PubSub\PubSubHttpClient \Ably\PubSub\Server::createHttpClient(String key_or_token_id)`
`PubSubServer.httpClientBuilder().key(String key).build()`
`PubSubServer.httpClientBuilder().token(String tokenId).build()`
`PubSubHttpClient PubSubServer.CreateHttpClient(string key)`
`+ (ARTPubSubClient *)createClientWithKey:(NSString *)key;
+ (ARTPubSubClient *)createClientWithToken:(NSString *)token;`
`PubSubDevice.createClient(key: String)
PubSubDevice.createClient(token: String)`
`create_http_client(key="API_KEY") -> PubSubHttpClient`
`create_http_client(token="TOKEN") -> PubSubHttpClient`
`pubsub.NewHTTPClient(pubsub.WithKey(key string)) (*pubsub.HTTPClient, error)`
This will instantiate the REST library with the provided API key or Token ID string or token string.
Server-package clients should authenticate with an API key; see [Server clients and token authentication](https://ably.com/docs/auth/token.md#server-token-auth).
`Ably::PubSub::Server.create_http_client(`[`ClientOptions`](#client-options)` client_options)`
`\Ably\PubSub\PubSubHttpClient \Ably\PubSub\Server::createHttpClient(`[`ClientOptions`](#client-options)` client_options)`
`PubSubServer.httpClientBuilder(`[`ClientOptions`](#client-options)` clientOptions).build()`
`PubSubHttpClient PubSubServer.CreateHttpClient(`[`ClientOptions`](#client-options)` clientOptions)`
`+ (ARTPubSubClient *)createClientWithOptions:(`[`ARTClientOptions`](#client-options)` *)options;`
`PubSubDevice.createClient(options: `[`ClientOptions`](#client-options)`)`
`create_http_client(`[`**ClientOptions`](#client-options)`) -> PubSubHttpClient`
`pubsub.NewHTTPClient(pubsub.WithKey(key string), pubsub.WithClientID(clientID string)) (*pubsub.HTTPClient, error)`
This will instantiate the library using the specified [`ClientOptions`](#client-options).
This will instantiate the client using the [`ClientOptions`](#client-options) passed as keyword arguments. The factory returns a `PubSubHttpClient`; the client class behind it is internal and cannot be constructed directly. A synchronous client with the same HTTP surface, without `async`/`await`, is created with `create_http_client` imported from `ably.pubsub.server.sync`.
This will instantiate the library using the specified [`ClientOptions`](#client-options), and returns a `PubSubHttpClient`. `PubSubServer` is `io.ably.pubsub.server.PubSubServer`, from the `io.ably.pubsub:server` artifact. `build()` throws an [`AblyException`](https://ably.com/docs/api/rest-sdk/types.md#ably-exception). The no-argument overload (`PubSubServer.httpClientBuilder()`) starts from an empty `ClientOptions`; the builder has one method per [ClientOptions](#client-options) member, for example `key(String)`, `clientId(String)` and `endpoint(String)`.
Import the factory with `require 'ably/pubsub/server'`.
Import the factory with `from ably.pubsub.server import create_http_client`.
Import the factory from `github.com/ably/ably-pubsub-go/server/pubsub`.
The factory is in the `io.ably.pubsub:server` artifact.
The factory is in the `Ably.PubSub.Server` package.
Flutter has no separate HTTP client. `ably.createClient()` returns a `PubSubClient`, which provides `channels`, `auth`, `push` and `time()`.
The HTTP client may be created multiple times with the same or different [`ClientOptions`](#client-options) in any given context. Except where specified otherwise, instances operate independently of one another.
Create the client with the `\Ably\PubSub\Server::createHttpClient()` factory, which accepts an options array, an API key string, a token string or a `ClientOptions` instance, and returns a `PubSubHttpClient`. Do not instantiate `PubSubHttpClient` directly with `new`: a client created that way does not declare that it is a server-side client in the `Ably-Agent` header.
### Authentication
The HTTP client needs to have credentials to be able to authenticate with the Ably service. Ably supports both Basic and Token based authentication schemes. Read more on [authentication](https://ably.com/docs/auth.md).
#### Basic Authentication
A private API key string for [`ClientOptions#key`](#client-options)[`ClientOptions#Key`](#client-options)[`WithKey`](#client-options) or the constructorthe factory, as obtained from the [application dashboard](https://ably.com/dashboard), is required for [Basic Authentication](https://ably.com/docs/auth/basic.md). Use this option if you wish to use [Basic authentication](https://ably.com/docs/auth/basic.md), or if you want to be able to [request Ably Tokens](https://ably.com/docs/auth/token.md) without needing to defer to a separate entity to sign Ably TokenRequests. Note that initializing the library with a `key``Key` does not necessarily mean that the library will use Basic auth; using the private key it is also able to create and sign Ably TokenRequests and use token authentication when necessary.
#### Token Authentication
The [`ClientOptions#token`](#client-options)[`ClientOptions#Token`](#client-options)[`WithToken`](#client-options) option takes a `token` string, and assumes that the Ably-compatible token has been obtained from some other instance that requested the token. Use the token option if you are provided with a token to use and you do not have a key (or do not have a key with the capabilities that you require).
Since tokens are short-lived, it is rarely sufficient to start with a token without the means for refreshing it. The [`authUrl` and `authCallback` options](#client-options)[`:auth_url` and `:auth_callback` options](#client-options)[`auth_url` and `auth_callback` options](#client-options)[`AuthUrl` and `AuthCallback` options](#client-options)[`WithAuthURL` and `WithAuthCallback` options](#client-options)[`authUrl` and `authCallback` options](#client-options) are provided to allow a user of the library to provide new Ably-compatible tokens or Ably TokenRequests to the library as required; using these options allows the library to be instantiated without a `key` or `token``Key` or `Token`, and an initial token will be obtained automatically when required.
Read more on [authentication](https://ably.com/docs/auth.md).
### Thread safety
The Cocoa SDK makes the following thread safety guarantees:
* All public methods and properties can be safely accessed from any thread, both for reading and writing operations.
* Objects like `ARTTokenDetails` and message data returned by the SDK can be safely read from multiple threads. However, you should not modify these objects after they're created.
* Objects you pass to the library must not be mutated afterwards. Once passed to the SDK, treat them as immutable. You can safely read from them or pass them again, and the library will never modify them.
All internal operations are dispatched to a single serial GCD queue to ensure thread safety within the SDK. You can specify a custom queue for this using `ARTClientOptions.internalDispatchQueue`, but it must be serial to maintain thread safety guarantees.
All callbacks provided by you are dispatched to the main queue by default, allowing you to update UI directly without additional thread switching. You can specify a different queue using `ARTClientOptions.dispatchQueue`. The callback queue must be different from `ARTClientOptions.internalDispatchQueue` to prevent deadlocks. Using the same queue creates circular dependencies where internal operations wait for callbacks, while callbacks wait for the internal queue.
### Thread safety
The Cocoa SDK makes the following thread safety guarantees:
* All public methods and properties can be safely accessed from any thread, both for reading and writing operations.
* Objects like `TokenDetails` and message data returned by the SDK can be safely read from multiple threads. However, you should not modify these objects after they're created.
* Objects you pass to the library must not be mutated afterwards. Once passed to the SDK, treat them as immutable. You can safely read from them or pass them again, and the library will never modify them.
All internal operations are dispatched to a single serial GCD queue to ensure thread safety within the SDK. You can specify a custom queue for this using `ClientOptions.internalDispatchQueue`, but it must be serial to maintain thread safety guarantees.
All callbacks provided by you are dispatched to the main queue by default, allowing you to update UI directly without additional thread switching. You can specify a different queue using `ClientOptions.dispatchQueue`. The callback queue must be different from `ClientOptions.internalDispatchQueue` to prevent deadlocks. Using the same queue creates circular dependencies where internal operations wait for callbacks, while callbacks wait for the internal queue.
## PubSubHttpClient PropertiesHTTPClient PropertiesPubSubHttpClient PropertiesPubSubHttpClient Propertiesio.ably.pubsub.http.PubSubHttpClient MembersAbly::PubSub::Http::Client AttributesARTPubSubClient PropertiesPubSubClient Properties
The REST client exposes the following public attributesmembersproperties:
### authAuth
A reference to the [`Auth`](https://ably.com/docs/api/rest-sdk/authentication.md) authentication object configured for this client library.
### push
A reference to the [`Push`](https://ably.com/docs/push.md)[`ARTPush`](https://ably.com/docs/push.md) object in this client library.Not available in Go: `HTTPClient` has no push property.
### device
A reference to the [`LocalDevice`](https://ably.com/docs/push/configure/device.md)[`ARTLocalDevice`](https://ably.com/docs/push/configure/device.md)[`LocalDevice`](https://ably.com/docs/push/configure/device.md) object.
### channelsChannels
[`Channels`](https://ably.com/docs/channels.md) is a reference to the [`Channel`](https://ably.com/docs/channels.md) collection instance for this library indexed by the channel name. You can use the [`Get`](https://ably.com/docs/api/rest-sdk/channels.md#get) method of this to get a `Channel` instance. See [channels](https://ably.com/docs/channels.md) and [messages](https://ably.com/docs/messages.md) for more information.
## PubSubHttpClient MethodsHTTPClient MethodsPubSubHttpClient MethodsPubSubHttpClient Methodsio.ably.pubsub.http.PubSubHttpClient MethodsAbly::PubSub::Http::Client MethodsARTPubSubClient MethodsPubSubClient Methods
### statsStats
`PaginatedResult stats(Hash options)`
`async stats(direction=None, start=None, end=None, params=None, limit=None, unit=None) -> PaginatedResult`
`PaginatedResult stats(Array options)`
`PaginatedResult stats(Param[] options)`
`Task> StatsAsync(StatsRequestParams query)`
`stats(query: StatsQuery?, callback: (PaginatedResult?, ErrorInfo?) -> Void)`
`stats(query: ARTStatsQuery?, callback: (ARTPaginatedResult?, ARTErrorInfo?) -> Void)`
`(c *HTTPClient) Stats(o ...StatsOption) StatsRequest`
The returned `StatsRequest` is performed by calling `Pages(ctx context.Context) (*StatsPaginatedResult, error)` or `Items(ctx context.Context) (*StatsPaginatedItems, error)`.
This call queries the [REST `/stats` API](https://ably.com/docs/api/rest-api.md#stats) and retrieves your application's usage statistics. A [`PaginatedResult`](https://ably.com/docs/api/rest-sdk/types.md#paginated-result) is returned, containing an array of [`Stats`](#stats-type) for the first page of results. [`PaginatedResult`](https://ably.com/docs/api/rest-sdk/types.md#paginated-result) objects are iterable providing a means to page through historical statistics. [See an example set of raw stats returned via the REST API](https://ably.com/docs/metadata-stats/stats.md#metrics).
See [statistics](https://ably.com/docs/metadata-stats/stats.md) for more information.
#### Parameters
| Parameter | Description |
|-----------|-------------|
| options | An optional Hash containing the query parameters |
| &block | Yields a `PaginatedResult` object |
| Parameter | Description |
|-----------|-------------|
| query | An optional `StatsQuery` containing the query parameters |
| callback | Called with a [`PaginatedResult`](#paginated-result)`<`[`Stats`](https://ably.com/docs/api/rest-sdk/types.md#stats)`>` object or an error |
| Parameter | Description |
|-----------|-------------|
| query | An optional `ARTStatsQuery` containing the query parameters |
| callback | Called with a [`ARTPaginatedResult`](#paginated-result)`<`[`ARTStats`](https://ably.com/docs/api/rest-sdk/types.md#stats)`>` object or an error |
| Parameter | Description |
|-----------|-------------|
| optionsdirection, start, end, params, limit, unitquery`o ...StatsOption` | An optional objectlist of `StatsOption` functionsset of keyword arguments`StatsRequestParams`[`Param[]`](#param) array containing the query parameters (see the table below) |
#### options parametersoptions parameters (`StatsOption`)ARTStatsQuery propertiesStatsQuery propertiesStatsRequestParams properties
The following options, as defined in the [REST `/stats` API](https://ably.com/docs/api/rest-api.md#stats) endpoint, are permitted:
| Parameter | Description | Type | Default |
|-----------|-------------|------|---------|
| start:startStart`StatsWithStart` | Earliest `DateTimeOffset` or `Time` or time in milliseconds since the epoch for any stats retrieved | `Long``Int` or `Time``DateTimeOffset``time.Time` | beginning of time |
| end:endEnd`StatsWithEnd` | Latest `DateTimeOffset` or `Time` or time in milliseconds since the epoch for any stats retrieved | `Long``Int` or `Time``DateTimeOffset``time.Time` | current time |
| direction:directionDirection`StatsWithDirection` | `:forwards` or `:backwards``forwards` or `backwards` | `String``Symbol``Direction` enum`Direction` (`Forwards` or `Backwards`) | backwards |
| limit:limitLimit`StatsWithLimit` | Maximum number of stats to retrieve up to 1,000 | `Integer``int` | 100 |
| unit:unitUnit`StatsWithUnit` | `:minute`, `:hour`, `:day` or `:month`.`minute`, `hour`, `day` or `month`. Based on the unit selected, the given start or end times are rounded down to the start of the relevant interval depending on the unit granularity of the query | `String`[`ARTStatsGranularity`](#stats-granularity)[`StatsGranularity`](#stats-granularity)[`StatsIntervalGranularity`](https://ably.com/docs/api/rest-sdk/types.md#stats-granularity) enum`PeriodUnit` (`PeriodMinute`, `PeriodHour`, `PeriodDay` or `PeriodMonth`) | minute |
#### Callback result
On success, `result` contains a [`PaginatedResult`](#paginated-result) encapsulating an array of [`Stats`](https://ably.com/docs/api/rest-sdk/types.md#stats) objects corresponding to the current page of results. [`PaginatedResult`](#paginated-result) supports pagination using [`next`](#paginated-result) and [`first`](#paginated-result) methods.
On failure to retrieve stats, `err` contains an [`ErrorInfo`](#error-info) object with an error response as defined in the [Ably REST API](https://ably.com/docs/api/rest-api.md#common) documentation.
#### Returns
On success, the returned [`PaginatedResult`](#paginated-result) encapsulates an array of [`Stats`](https://ably.com/docs/api/rest-sdk/types.md#stats) objects corresponding to the current page of results. [`PaginatedResult`](#paginated-result) supports pagination using [`next`](#paginated-result) and [`first`](#paginated-result) methods.
Failure to retrieve the stats will raise an [`AblyException`](https://ably.com/docs/api/rest-sdk/types.md#ably-exception)
#### Returns
The method is asynchronous and return Task which needs to be awaited.
On success, the returned [`PaginatedResult`](#paginated-result) encapsulates a list of [`Stats`](https://ably.com/docs/api/rest-sdk/types.md#stats) objects corresponding to the current page of results. [`PaginatedResult`](#paginated-result) supports pagination using [`NextAsync`](#paginated-result) and [`FirstAsync`](#paginated-result) methods.
Failure to retrieve the stats will raise an [`AblyException`](https://ably.com/docs/api/rest-sdk/types.md#ably-exception)
### timeTime
`Time time`
`async time() -> float`
`Integer time()`
`long time()`
`Task TimeAsync()`
`time(callback: (NSDate?, NSError?) -> Void)`
`(c *HTTPClient) Time(ctx context.Context) (time.Time, error)`
Obtains the time from the Ably service as a `Time` objecta `DateTimeOffset` objectmilliseconds since epoch. (Clients that do not have access to a sufficiently well maintained time source and wish to issue Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) with a more accurate timestamp should use the `queryTime``query_time` [`clientOptions`](#client-options) instead of this method).
#### Callback result
On success, `time` is a number containing the number of milliseconds since the epoch.
On failure to retrieve the Ably server time, `err` contains an [`ErrorInfo`](#error-info) object with an error response as defined in the [Ably REST API](https://ably.com/docs/api/rest-api.md#common) documentation.
#### Returns
On success, milliseconds since epochthe `Time`the `DateTimeOffset` is returned.
Failure to retrieve the Ably server time will raise an [`AblyException`](https://ably.com/docs/api/rest-sdk/types.md#ably-exception).
#### Returns
On success, the Ably server time is returned as a `time.Time`.
On failure to retrieve the Ably server time, `error` contains an [`ErrorInfo`](#error-info) object with an error response as defined in the [Ably REST API](https://ably.com/docs/api/rest-api.md#common) documentation.
### requestRequestRequestV2
`HttpPaginatedResponse request(String method, String path, Object params, Object body, Object headers)`
`HttpPaginatedResponse request(String method, String path, Array params, Array body, Array headers)`
`async request(method, path, version, params=None, body=None, headers=None) -> HttpPaginatedResponse`
`HttpPaginatedResponse request(String method, String path, Param[] params, HttpCore.RequestBody body, Param[] headers)`
`Task RequestV2(string method, string path, Dictionary requestParams = null, string body = null, Dictionary headers = null)`
`- (void)request:(NSString *)method path:(NSString *)path params:(nullable NSDictionary *)params body:(nullable id)body headers:(nullable NSDictionary *)headers callback:(void (^)(ARTHTTPPaginatedResponse *_Nullable, ARTErrorInfo *_Nullable))callback`
`request(_ method: String, path: String, params: [String: String]?, body: Any?, headers: [String: String]?, callback: @escaping (HTTPPaginatedResponse?, ErrorInfo?) -> Void)`
`(c *HTTPClient) Request(method string, path string, o ...RequestOption) HTTPRequest`
The returned `HTTPRequest` is performed by calling `Pages(ctx context.Context) (*HTTPPaginatedResponse, error)` or `Items(ctx context.Context) (*HTTPPaginatedItems, error)`.
Makes a REST request to a provided path. This is provided as a convenience for developers who wish to use REST API functionality that is either not documented or is not yet included in the public API, without having to handle authentication, paging, fallback hosts, MsgPack and JSON support, etc. themselves.
#### Parameters
| Parameter | Description | Type |
|-----------|-------------|------|
| method | either `get`, `post`, `put`, `patch` or `delete` | `string``String` |
| path | the path to query | `string``String` |
| params | (optional) any querystring parameters needed | `Dictionary``Object``Array``url.Values` (`RequestWithParams`)[`Param[]`](#param) |
| body | (optional; for `post`, `put` and `patch` methods) the body of the request, as anything that can be serialized into JSON, as a JToken., as an array or object. (for C#, a JSON string)...(optional; for `post`, `put` and `patch` methods) the body of the request, as an `HttpCore.RequestBody`, for example created with `HttpUtils.requestBodyFromGson(JsonElement json, boolean useBinaryProtocol)`. | `string``Serializable``Array` or `object``interface{}` (`RequestWithBody`)`HttpCore.RequestBody` |
| headers | (optional) any headers needed. If provided, these will be mixed in with the default library headers | `Dictionary``Object``Array``http.Header` (`RequestWithHeaders`)[`Param[]`](#param) |
The `version` argument is required. It is the string identifying the Ably REST API version to use for the request, for example `"3"`. The `params`, `body` and `headers` arguments are optional. The `body` argument is a value that can be serialized into JSON, such as a `dict` or `list`.
#### Callback result
On successfully receiving a response from Ably, `results` contains an `ARTHTTPPaginatedResponse` containing the `statusCode` of the response, a `success` boolean (equivalent to whether the status code is between 200 and 299), `headers`, and an `items` array containing the current page of results. It supports pagination using [`next`](#paginated-result) and [`first`](#paginated-result) methods, identically to [`PaginatedResult`](https://ably.com/docs/api/rest-sdk/types.md#paginated-result).
On failure to obtain a response, `err` contains an [`ErrorInfo`](https://ably.com/docs/api/rest-sdk/types.md#error-info) object with an error response as defined in the [Ably REST API](https://ably.com/docs/api/rest-api.md#common) documentation. (Note that if a response is obtained, any response, even with a non-2xx status code, will result in an HTTP Paginated Response, not an `err`).
#### Callback result
On successfully receiving a response from Ably, `results` contains an `HTTPPaginatedResponse` containing the `statusCode` of the response, a `success` boolean (equivalent to whether the status code is between 200 and 299), `headers`, and an `items` array containing the current page of results. It supports pagination using [`next`](#paginated-result) and [`first`](#paginated-result) methods, identically to [`PaginatedResult`](https://ably.com/docs/api/rest-sdk/types.md#paginated-result).
On failure to obtain a response, `err` contains an [`ErrorInfo`](https://ably.com/docs/api/rest-sdk/types.md#error-info) object with an error response as defined in the [Ably REST API](https://ably.com/docs/api/rest-api.md#common) documentation. (Note that if a response is obtained, any response, even with a non-2xx status code, will result in an HTTP Paginated Response, not an `err`).
#### Returns
On successfully receiving a response from Ably, the returned [`HttpPaginatedResponse`](https://ably.com/docs/api/rest-sdk/types.md#http-paginated-response) contains a `status_code``statusCode` and a `success` boolean, `headers`, and an `items` array containing the current page of results. It supports pagination using [`next`](#paginated-result) and [`first`](#paginated-result) methods, identically to [`PaginatedResult`](https://ably.com/docs/api/rest-sdk/types.md#paginated-result).
Failure to obtain a response will raise an [`AblyException`](https://ably.com/docs/api/realtime-sdk/types.md#ably-exception). (Note that if a response is obtained, any response, even with a non-2xx status code, will result in an HTTP Paginated Response, not an exception).
#### Returns
The method is asynchronous and return a Task that has to be awaited to get the result.
On successfully receiving a response from Ably, the returned [`HttpPaginatedResponse`](https://ably.com/docs/api/rest-sdk/types.md#http-paginated-response) containing the `StatusCode` and a `Success` boolean, `Headers`, and an `Items` array containing the current page of results. [`HttpPaginatedResponse`](https://ably.com/docs/api/rest-sdk/types.md#http-paginated-response) supports pagination using [`NextAsync`](#paginated-result) and [`FirstAsync`](#paginated-result) methods.
Failure to obtain a response will raise an [`AblyException`](https://ably.com/docs/api/realtime-sdk/types.md#ably-exception). (Note that if a response is obtained, any response, even with a non-2xx status code, will result in an HTTP Paginated Response, not an exception).
### batch_presence
`async batch_presence(channels: list[str]) -> BatchResult`
Retrieves the members present on several channels in a single request to the [batch presence endpoint](https://ably.com/docs/api/rest-api.md#batch-presence).
#### Parameters
| Parameter | Description | Type |
|-----------|-------------|------|
| channels | the names of the channels to query. Passing a single string rather than a list raises `TypeError` | `list[str]` |
#### Returns
A `BatchResult` with `success_count`, `failure_count` and a `results` list holding one entry per channel: a `BatchPresenceSuccessResult` with the `channel` name and its `presence` list of [`PresenceMessage`](https://ably.com/docs/api/rest-sdk/types.md#presence-message) objects, or a `BatchPresenceFailureResult` with the `channel` name and an `error` [`AblyException`](https://ably.com/docs/api/rest-sdk/types.md#ably-exception).
A failure of the request as a whole raises an [`AblyException`](https://ably.com/docs/api/rest-sdk/types.md#ably-exception).
## Related types
### ClientOptionsClientOptionsARTClientOptionsio.ably.pubsub.types.ClientOptionsAbly.PubSub.ClientOptions
`ClientOptions` is a Hash object and is used in the `Ably::PubSub::Server.create_http_client` factory's `options` argument. The following key symbol values can be added to the Hash:
`ClientOptions` is a associative array and is used in the `\Ably\PubSub\Server::createHttpClient` factory's `options` argument. The following named keys and values can be added to the associative array:
`ART``ClientOptions` is used in the [client constructor's](#constructor) `options` argument.
`ClientOptions` is used in the `options` argument of `PubSubServer.httpClientBuilder(ClientOptions)`.
`ClientOptions` is used in the `options` argument of the `PubSubServer.CreateHttpClient` factory.
The client options are `ClientOption` functions, such as `pubsub.WithKey`, passed to the `pubsub.NewHTTPClient` constructor.
#### Properties
| Parameter | Description | Type |
|-----------|-------------|------|
| `WithKey` | The full key string, as obtained from the [application dashboard](https://ably.com/dashboard). Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequests. Read more about [Basic authentication](https://ably.com/docs/auth/basic.md) | `string` |
| `WithToken` | An authenticated token string (obtained from the `Token` property of a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) component of an Ably TokenRequest response, or a [JSON Web Token](https://tools.ietf.org/html/rfc7519) satisfying [the Ably requirements for JWTs](https://ably.com/docs/auth/token/jwt.md)). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `AuthUrl` or `AuthCallback`. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `string` |
| `WithAuthCallback` | A function which is called when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). See [our authentication documentation](https://ably.com/docs/auth.md) for details of the Ably TokenRequest format and associated API calls. | `func(context.Context, TokenParams) (Tokener, error)` |
| `WithAuthURL` | A URL that the library may use to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). For example, this can be used by a client to obtain signed Ably TokenRequests from an application server. | `string` |
| `WithAuthMethod` | The HTTP verb to use for the request, either `GET` or `POST`
_default: `GET`_ | `string` |
| `WithAuthHeaders` | A set of key value pair headers to be added to any request made to the `authUrl`. Useful when an application requires these to be added to validate the request or implement the response. | `http.Header` |
| `WithAuthParams` | A set of key value pair params to be added to any request made to the `authUrl`. When the `AuthMethod` is `GET`, query params are added to the URL, whereas when `AuthMethod` is `POST`, the params are sent as URL encoded form data. Useful when an application require these to be added to validate the request or implement the response. | `url.Values` |
| `WithTokenDetails` | An authenticated [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `AuthUrl` or `AuthCallback`. Use this option if you wish to use Token authentication. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `*TokenDetails` |
| `WithTLS` | A boolean value, indicating whether or not a TLS ("SSL") secure connection should be used. An insecure connection cannot be used with Basic authentication as it would lead to a possible compromise of the private API key while in transit. [Find out more about TLS](https://faqs.ably.com/are-messages-sent-to-and-received-from-ably-securely-using-tls)
_default: true_ | `bool` |
| `WithClientID` | A client ID, used for identifying this client when publishing messages or for presence purposes. The `ClientId` can be any non-empty string. This option is primarily intended to be used in situations where the library is instantiated with a key; note that a `ClientId` may also be implicit in a token used to instantiate the library; an error will be raised if a `ClientId` specified here conflicts with the `ClientId` implicit in the token. [Find out more about client identities](https://ably.com/docs/auth/identified-clients.md) | `string` |
| `WithUseTokenAuth` | When true, forces [Token authentication](https://ably.com/docs/auth/token.md) to be used by the library. Please note that if a `ClientId` is not specified in the [`ClientOptions`](https://ably.com/docs/api/realtime-sdk/types.md#client-options) or [`TokenParams`](https://ably.com/docs/api/realtime-sdk/types.md#token-params), then the Ably Token issued will be [anonymous](https://faqs.ably.com/authenticated-and-identified-clients).
_default: false_ | `bool` |
| `WithEndpoint` | Sets the endpoint that REST requests use. The value can be a routing policy name such as `acme` (resolved to `acme.realtime.ably.net`), a non-production routing policy name prefixed with `nonprod:` such as `nonprod:sandbox` (resolved to `sandbox.realtime.ably-nonprod.net`), or a hostname (a value containing `.` or `::`, or `localhost`), which is used as given and has no default fallback hosts. Enables [enterprise customers](https://ably.com/pricing) to use their own custom endpoints, which support dedicated, isolated clusters and regional message routing and storage constraints. See our [platform customization guide](https://ably.com/docs/platform/account/enterprise-customization.md) for more details.
_default: `main` (that is `main.realtime.ably.net`)_ | `string` |
| `WithIdempotentRESTPublishing` | When true, enables idempotent publishing by assigning a unique message ID client-side, allowing the Ably servers to discard automatic publish retries following a failure such as a network fault. Enabled by default in all current Ably SDKs.
_default: true_ | `bool` |
| `WithFallbackHosts` | An array of fallback hosts to be used in the case of an error necessitating the use of an alternative host. When set, these replace the default fallback hosts, and an empty array disables the [fallback host functionality](https://faqs.ably.com/routing-around-network-and-dns-issues). When the endpoint is a hostname (see `WithEndpoint`) there are no default fallback hosts. If your customer success manager has provided you with a set of custom fallback hosts, please specify them here.
_default: derived from the endpoint; for the default endpoint, `[main.a.fallback.ably-realtime.com, main.b.fallback.ably-realtime.com, main.c.fallback.ably-realtime.com, main.d.fallback.ably-realtime.com, main.e.fallback.ably-realtime.com]`_ | `[]string` |
| `WithTransportParams` | Optional. Can be used to pass in arbitrary connection parameters, such as [`heartbeatInterval`](https://ably.com/docs/connect.md#heartbeats) and [`remainPresentFor`](https://ably.com/docs/presence-occupancy/presence.md#unstable-connections) | `url.Values` |
| `WithLogLevel` | Controls the verbosity of the log output of the library. Valid values are `LogNone`, `LogError`, `LogWarning`, `LogInfo`, `LogVerbose` and `LogDebug`.
_default: `LogWarning`_ | `LogLevel` |
| `WithUseBinaryProtocol` | If set to false, will forcibly disable the binary protocol (MessagePack). The binary protocol is used by default unless it is not supported. Find out more about the [benefits of binary encoding](https://faqs.ably.com/do-you-binary-encode-your-messages-for-greater-efficiency)
_default: true_ | `bool` |
| `WithQueryTime` | If true, the library will query the Ably servers for the current time when [issuing TokenRequests](https://ably.com/docs/auth/token.md) instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request), so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd). The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request.
_default: false_ | `bool` |
| `WithDefaultTokenParams` | When a [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) object is provided, it will override the client library defaults when issuing new [Ably Tokens](https://ably.com/docs/api/realtime-sdk/authentication.md#token-details) or [Ably `TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) | `TokenParams` |
#### Attributes
| Parameter | Description | Type |
|-----------|-------------|------|
| :key | The full key string, as obtained from the [application dashboard](https://ably.com/dashboard). Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequests. Read more about [Basic authentication](https://ably.com/docs/auth/basic.md) | `String` |
| :token | An authenticated token. This can either be a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object, a [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request) object, or token string (obtained from the `token` property of a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) component of an Ably TokenRequest response, or a [JSON Web Token](https://tools.ietf.org/html/rfc7519) satisfying [the Ably requirements for JWTs](https://ably.com/docs/auth/token/jwt.md)). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `:auth_url` or `:auth_callback`. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `String`, `TokenDetails` or `TokenRequest` |
| :auth_callback | A proc / lambda (called synchronously in REST and Realtime but does not block EventMachine in the latter) which is called when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). See [our authentication documentation](https://ably.com/docs/auth.md) for details of the Ably TokenRequest format and associated API calls. | `Proc` |
| :auth_url | A URL that the library may use to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). For example, this can be used by a client to obtain signed Ably TokenRequests from an application server. | `String` |
| :auth_method | The HTTP verb to use for the request, either `:get` or `:post`
_default: `:get`_ | `Symbol` |
| :auth_headers | A set of key value pair headers to be added to any request made to the `authUrl`. Useful when an application requires these to be added to validate the request or implement the response. | `Hash` |
| :auth_params | A set of key value pair params to be added to any request made to the `authUrl`. When the `authMethod` is `GET`, query params are added to the URL, whereas when `authMethod` is `POST`, the params are sent as URL encoded form data. Useful when an application require these to be added to validate the request or implement the response. | `Hash` |
| :token_details | An authenticated [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `:auth_url` or `:auth_callback`. Use this option if you wish to use Token authentication. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `TokenDetails` |
| :tls | A boolean value, indicating whether or not a TLS ("SSL") secure connection should be used. An insecure connection cannot be used with Basic authentication as it would lead to a possible compromise of the private API key while in transit. [Find out more about TLS](https://faqs.ably.com/are-messages-sent-to-and-received-from-ably-securely-using-tls)
_default: true_ | `Boolean` |
| :client_id | A client ID, used for identifying this client when publishing messages or for presence purposes. The `client_id` can be any non-empty string. This option is primarily intended to be used in situations where the library is instantiated with a key; note that a `client_id` may also be implicit in a token used to instantiate the library; an error will be raised if a `client_id` specified here conflicts with the `client_id` implicit in the token. [Find out more about client identities](https://ably.com/docs/auth/identified-clients.md) | `String` |
| :use_token_auth | When true, forces [Token authentication](https://ably.com/docs/auth/token.md) to be used by the library. Please note that if a `client_id` is not specified in the [`ClientOptions`](https://ably.com/docs/api/realtime-sdk/types.md#client-options) or [`TokenParams`](https://ably.com/docs/api/realtime-sdk/types.md#token-params), then the Ably Token issued will be [anonymous](https://faqs.ably.com/authenticated-and-identified-clients).
_default: false_ | `Boolean` |
| :endpoint | The endpoint that both REST requests and the realtime connection use. It can be a routing policy name such as `acme` (resolved to `acme.realtime.ably.net`), a non-production routing policy name prefixed with `nonprod:` such as `nonprod:sandbox` (resolved to `sandbox.realtime.ably-nonprod.net`), or a hostname such as `localhost`, which is used as given and has no default fallback hosts. Enables [enterprise customers](https://ably.com/pricing) to use their own custom endpoints, which support dedicated, isolated clusters and regional message routing and storage constraints. See our [platform customization guide](https://ably.com/docs/platform/account/enterprise-customization.md) for more details.
_default: nil, which resolves to `main.realtime.ably.net`_ | `String` |
| :idempotent_rest_publishing | When true, enables idempotent publishing by assigning a unique message ID client-side, allowing the Ably servers to discard automatic publish retries following a failure such as a network fault. Enabled by default in all current Ably SDKs.
_default: true_ | `Boolean` |
| :fallback_hosts | An array of fallback hosts to be used in the case of an error necessitating the use of an alternative host. When set, these replace the default fallback hosts, which are derived from `:endpoint`, and an empty array disables the [fallback host functionality](https://faqs.ably.com/routing-around-network-and-dns-issues). When `:endpoint` is a hostname there are no default fallback hosts. If your customer success manager has provided you with a set of custom fallback hosts, please specify them here.
_default: `[main.a.fallback.ably-realtime.com, main.b.fallback.ably-realtime.com, main.c.fallback.ably-realtime.com, main.d.fallback.ably-realtime.com, main.e.fallback.ably-realtime.com]`_ | `String []` |
| :transport_params | Optional. Can be used to pass in arbitrary connection parameters, such as [`heartbeatInterval`](https://ably.com/docs/connect.md#heartbeats) and [`remainPresentFor`](https://ably.com/docs/presence-occupancy/presence.md#unstable-connections) | `Hash` |
| :log_level | Log level for the standard Logger that outputs to `STDOUT`. Can be set to `:fatal`, `:error`, `:warn`, `:info`, `:debug` or `:none`. Alternatively a [`Logger` severity constant](https://ruby-doc.org/3.4.1/stdlibs/logger/Logger.html#class-Logger-label-Severity) can be specified. The default is `:error`. | `Symbol`, [`Logger::SEVERITY`](https://ruby-doc.org/3.4.1/stdlibs/logger/Logger.html#class-Logger-label-Severity) |
| :logger | A Ruby [`Logger`](https://ruby-doc.org/3.4.1/stdlibs/logger/Logger.html#class-Logger-label-Synopsis) compatible object to handle each line of log output. If `logger` is not specified, `STDOUT` is used. | `STDOUT Logger` |
| :use_binary_protocol | If set to false, will forcibly disable the binary protocol (MessagePack). The binary protocol is used by default unless it is not supported. The default is true. Find out more about the [benefits of binary encoding](https://faqs.ably.com/do-you-binary-encode-your-messages-for-greater-efficiency)
_default: true_ | `Boolean` |
| :query_time | If true, the library will query the Ably servers for the current time when [issuing TokenRequests](https://ably.com/docs/auth/token.md) instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request), so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd). The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request.
_default: false_ | `Boolean` |
| :default_token_params | When a [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) object is provided, it will override the client library defaults when issuing new [Ably Tokens](https://ably.com/docs/api/realtime-sdk/authentication.md#token-details) or [Ably `TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) | [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) |
#### Keyword arguments
These are passed as keyword arguments to `create_http_client` (and `create_realtime_client`).
| Parameter | Description | Type |
|-----------|-------------|------|
| key | The full key string, as obtained from the [application dashboard](https://ably.com/dashboard). Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequests. Mutually exclusive with `key_name` and `key_secret`. Read more about [Basic authentication](https://ably.com/docs/auth/basic.md) | `str` |
| token | An authenticated token string, either an Ably Token string (obtained from the `token` property of a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) component of an Ably TokenRequest response) or a [JSON Web Token](https://tools.ietf.org/html/rfc7519) satisfying [the Ably requirements for JWTs](https://ably.com/docs/auth/token/jwt.md). To pass a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object, use `token_details`. This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `auth_url` or `auth_callback`. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `str` |
| token_details | An authenticated [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `auth_url` or `auth_callback`. Use this option if you wish to use Token authentication. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `TokenDetails` |
| auth_callback | An async callable (a coroutine function, defined with `async def`) which is awaited with the token params `dict` when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). See [our authentication documentation](https://ably.com/docs/auth.md) for details of the Ably TokenRequest format and associated API calls. | `Callable` |
| auth_url | A URL that the library may use to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). For example, this can be used by a client to obtain signed Ably TokenRequests from an application server. | `str` |
| auth_method | The HTTP verb to use for the request, either `GET` or `POST`
_default: `GET`_ | `str` |
| auth_headers | A set of key value pair headers to be added to any request made to the `auth_url`. Useful when an application requires these to be added to validate the request or implement the response. | `dict` |
| auth_params | A set of key value pair params to be added to any request made to the `auth_url`. When the `auth_method` is `GET`, query params are added to the URL, whereas when `auth_method` is `POST`, the params are sent as URL encoded form data. Useful when an application require these to be added to validate the request or implement the response. | `dict` |
| tls | A boolean value, indicating whether or not a TLS ("SSL") secure connection should be used. An insecure connection cannot be used with Basic authentication as it would lead to a possible compromise of the private API key while in transit. [Find out more about TLS](https://faqs.ably.com/are-messages-sent-to-and-received-from-ably-securely-using-tls)
_default: True_ | `bool` |
| client_id | A client ID, used for identifying this client when publishing messages or for presence purposes. The `client_id` can be any non-empty string. This option is primarily intended to be used in situations where the library is instantiated with a key; note that a `client_id` may also be implicit in a token used to instantiate the library; an error will be raised if a `client_id` specified here conflicts with the `client_id` implicit in the token. [Find out more about client identities](https://ably.com/docs/auth/identified-clients.md) | `str` |
| use_token_auth | Whether to use [Token authentication](https://ably.com/docs/auth/token.md). When not set, the client uses token auth if any of `auth_callback`, `auth_url`, `token` or `token_details` is given, even alongside a `key`, which it then keeps only to renew tokens; it uses Basic auth if only a `key` is given. Set it to `False` to authenticate with the `key` regardless, or to `True` to request tokens with the `key`. Please note that if a `client_id` is not specified in the [`ClientOptions`](https://ably.com/docs/api/realtime-sdk/types.md#client-options) or [`TokenParams`](https://ably.com/docs/api/realtime-sdk/types.md#token-params), then the Ably Token issued will be [anonymous](https://faqs.ably.com/authenticated-and-identified-clients).
_default: None_ | `bool` |
| endpoint | Either a routing policy name or a fully qualified domain name to connect to, which enables [enterprise customers](https://ably.com/pricing) to use their own custom endpoints, which support dedicated, isolated clusters and regional message routing and storage constraints. See our [platform customization guide](https://ably.com/docs/platform/account/enterprise-customization.md) for more details.
_default: `main`_ | `str` |
| idempotent_rest_publishing | When true, enables idempotent publishing by assigning a unique message ID client-side, allowing the Ably servers to discard automatic publish retries following a failure such as a network fault. Enabled by default in all current Ably SDKs.
_default: True_ | `bool` |
| fallback_hosts | A list of fallback hosts to be used in the case of an error necessitating the use of an alternative host. If your customer success manager has provided you with a set of custom fallback hosts, please specify them here. When this option is not specified, the fallback hosts are derived from the `endpoint`, and when `endpoint` is a fully qualified domain name there are no fallback hosts. [Find out more about fallback host functionality](https://faqs.ably.com/routing-around-network-and-dns-issues).
_default: `[main.a.fallback.ably-realtime.com, main.b.fallback.ably-realtime.com, main.c.fallback.ably-realtime.com, main.d.fallback.ably-realtime.com, main.e.fallback.ably-realtime.com]`_ | `list[str]` |
| transport_params | Optional. Can be used to pass in arbitrary connection parameters, such as [`heartbeatInterval`](https://ably.com/docs/connect.md#heartbeats) and [`remainPresentFor`](https://ably.com/docs/presence-occupancy/presence.md#unstable-connections) | `dict` |
| use_binary_protocol | If set to false, will forcibly disable the binary protocol (MessagePack) and use JSON instead. The binary protocol is used by default. Find out more about the [benefits of binary encoding](https://faqs.ably.com/do-you-binary-encode-your-messages-for-greater-efficiency)
_default: True_ | `bool` |
| query_time | If true, the library will query the Ably servers for the current time when [issuing TokenRequests](https://ably.com/docs/auth/token.md) instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request), so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd). The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request.
_default: False_ | `bool` |
| default_token_params | When a [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) object is provided, it will override the client library defaults when issuing new [Ably Tokens](https://ably.com/docs/api/realtime-sdk/authentication.md#token-details) or [Ably `TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) | [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) |
| http_open_timeout_seconds | The timeout, in seconds, for establishing an HTTP connection
_default: 4_ | `int` or `float` |
| http_request_timeout_seconds | The timeout, in seconds, for each read and write of an HTTP request, and for waiting for a free pooled connection
_default: 10_ | `int` or `float` |
| http_max_retry_count | The maximum number of fallback hosts the client tries for a single request after the primary endpoint. `0` tries the primary endpoint only
_default: 3_ | `int` |
| http_max_retry_duration_seconds | How long, in seconds, the client keeps retrying a request across hosts before giving up
_default: 15_ | `int` or `float` |
| fallback_retry_timeout_seconds | How long, in seconds, a fallback host stays preferred once the client has failed over to it
_default: 600_ | `int` or `float` |
| max_message_size | The largest total size, in bytes, of the messages a single publish may carry. A larger publish raises an [`AblyException`](https://ably.com/docs/api/realtime-sdk/types.md#ably-exception) with code `40009` and is not sent
_default: 65536_ | `int` |
#### MembersPropertiesAttributes
| Parameter | Description | Type |
|-----------|-------------|------|
| keyKey:key | The full key string, as obtained from the [application dashboard](https://ably.com/dashboard). Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequests. Read more about [Basic authentication](https://ably.com/docs/auth/basic.md) | `String` |
| tokenToken:token | An authenticated token. This can either be a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object, a [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request) object, or token string (obtained from the `token``Token` property of a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) component of an Ably TokenRequest response, or a [JSON Web Token](https://tools.ietf.org/html/rfc7519) satisfying [the Ably requirements for JWTs](https://ably.com/docs/auth/token/jwt.md)). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `authUrl`:auth_urlauth_url or `authCallback``AuthCallback``auth_callback``:auth_callback`. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `String`, `TokenDetails` or `TokenRequest` |
| authCallbackAuthCallbackauth_callback:auth_callback | A function`TokenCallback` instancecallable (eg a lambda)proc / lambda (called synchronously in REST and Realtime but does not block EventMachine in the latter) which is called when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). See [our authentication documentation](https://ably.com/docs/auth.md) for details of the Ably TokenRequest format and associated API calls. | `Callable``TokenCallback``Proc` |
| authUrlAuthUrl:auth_urlauth_url | A URL that the library may use to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). For example, this can be used by a client to obtain signed Ably TokenRequests from an application server. | `String``NSURL` |
| authMethodAuthMethodauth_method:auth_method | The HTTP verb to use for the request, either `GET``:get` or `POST``:post`
_default: `GET``:get`_ | `String``Symbol` |
| authHeadersAuthHeadersauth_headers:auth_headers | A set of key value pair headers to be added to any request made to the `authUrl`. Useful when an application requires these to be added to validate the request or implement the response. | `Object``Dict``Hash``Associative Array``Param []` |
| authParamsAuthParams:auth_paramsauth_params | A set of key value pair params to be added to any request made to the `authUrl`. When the `authMethod``AuthMethod` is `GET`, query params are added to the URL, whereas when `authMethod``AuthMethod` is `POST`, the params are sent as URL encoded form data. Useful when an application require these to be added to validate the request or implement the response. | `Object``Hash``Associative Array``Param[]``NSArray``[NSURLQueryItem]/Array` |
| tokenDetailsTokenDetailstoken_details:token_details | An authenticated [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `authUrl``AuthUrl``:auth_url``auth_url` or `authCallback`AuthCallback`auth_callback``:auth_callback`. Use this option if you wish to use Token authentication. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `TokenDetails` |
| tlsTls:tls | A boolean value, indicating whether or not a TLS ("SSL") secure connection should be used. An insecure connection cannot be used with Basic authentication as it would lead to a possible compromise of the private API key while in transit. [Find out more about TLS](https://faqs.ably.com/are-messages-sent-to-and-received-from-ably-securely-using-tls)
_default: true_ | `Boolean` |
| clientIdClientIdclient_id:client_id | A client ID, used for identifying this client when publishing messages or for presence purposes. The `clientId``client_id``ClientId` can be any non-empty string. This option is primarily intended to be used in situations where the library is instantiated with a key; note that a `clientId``client_id``ClientId` may also be implicit in a token used to instantiate the library; an error will be raised if a `clientId``client_id` specified here conflicts with the `clientId``client_id``ClientId` implicit in the token. [Find out more about client identities](https://ably.com/docs/auth/identified-clients.md) | `String` |
| useTokenAuthUseTokenAuthuse_token_auth:use_token_auth | When true, forces [Token authentication](https://ably.com/docs/auth/token.md) to be used by the library. Please note that if a `client_id``clientId` is not specified in the [`ClientOptions`](https://ably.com/docs/api/realtime-sdk/types.md#client-options) or [`TokenParams`](https://ably.com/docs/api/realtime-sdk/types.md#token-params), then the Ably Token issued will be [anonymous](https://faqs.ably.com/authenticated-and-identified-clients).
_default: false_ | `Boolean` |
| endpointEndpoint:endpoint | Enables [enterprise customers](https://ably.com/pricing) to use their own custom endpoints, which support dedicated, isolated clusters and regional message routing and storage constraints. See our [platform customization guide](https://ably.com/docs/platform/account/enterprise-customization.md) for more details.
_default: nullNullNonenil_ | `String` |
| idempotentRestPublishingIdempotentRestPublishing:idempotent_rest_publishing | When true, enables idempotent publishing by assigning a unique message ID client-side, allowing the Ably servers to discard automatic publish retries following a failure such as a network fault. Enabled by default in all current Ably SDKs.
_default: true_ | `Boolean` |
| fallbackHostsFallbackHostsfallback_hosts:fallback_hosts | An array of fallback hosts to be used in the case of an error necessitating the use of an alternative host. When a custom environment is specified, the [fallback host functionality](https://faqs.ably.com/routing-around-network-and-dns-issues) is disabled. If your customer success manager has provided you with a set of custom fallback hosts, please specify them here.
_default: `[a.ably-realtime.com, b.ably-realtime.com, c.ably-realtime.com, d.ably-realtime.com, e.ably-realtime.com]`_ | `String []` |
| transportParamstransport_params:transport_params | Optional. Can be used to pass in arbitrary connection parameters, such as [`heartbeatInterval`](https://ably.com/docs/connect.md#heartbeats) and [`remainPresentFor`](https://ably.com/docs/presence-occupancy/presence.md#unstable-connections) | `Object``Dict``Hash``Associative Array``Param []` |
| logLevellog_level | A number controlling the verbosity of the log output of the library. Valid values are: 0 (no logs), 1 (errors only), 2 (errors plus connection and channel state changes), 3 (high-level debug output), and 4 (full debug output). | `Integer` |
| logHandlerlog_handler | A function to handle each line of the library's log output. If `logHandler` is not specified, `console.log` is used. | `Callable` |
| useBinaryProtocoluse_binary_protocol | If set to true, will enable the binary protocol (MessagePack) if it is supported. It's disabled by default on browsers for performance considerations (browsers are optimized for decoding JSON). Find out more about the [benefits of binary encoding](https://faqs.ably.com/do-you-binary-encode-your-messages-for-greater-efficiency)
_default: false_ | `Boolean` |
| queryTimeQueryTime:query_timequery_time | If true, the library will query the Ably servers for the current time when [issuing TokenRequests](https://ably.com/docs/auth/token.md) instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request), so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd). The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request.
_default: false_ | `Boolean` |
| defaultTokenParamsdefault_token_params:default_token_paramsDefaultTokenParams | When a [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) object is provided, it will override the client library defaults when issuing new [Ably Tokens](https://ably.com/docs/api/realtime-sdk/authentication.md#token-details) or [Ably `TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) | [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) |
#### Members
| Parameter | Description | Type |
|-----------|-------------|------|
| key | The full key string, as obtained from the [application dashboard](https://ably.com/dashboard). Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequests. Read more about [Basic authentication](https://ably.com/docs/auth/basic.md) | `String` |
| token | An authenticated token. This can either be a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object, a [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request) object, or token string (obtained from the `token` property of a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) component of an Ably TokenRequest response, or a [JSON Web Token](https://tools.ietf.org/html/rfc7519) satisfying [the Ably requirements for JWTs](https://ably.com/docs/auth/token/jwt.md)). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `authUrl` or `authCallback`. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `String`, `TokenDetails` or `TokenRequest` |
| authCallback | A `TokenCallback` instance which is called when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). See [our authentication documentation](https://ably.com/docs/auth.md) for details of the Ably TokenRequest format and associated API calls. | `TokenCallback` |
| authUrl | A URL that the library may use to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). For example, this can be used by a client to obtain signed Ably TokenRequests from an application server. | `String` |
| authMethod | The HTTP verb to use for the request, either `GET` or `POST`
_default: `GET`_ | `String` |
| authHeaders | A set of key value pair headers to be added to any request made to the `authUrl`. Useful when an application requires these to be added to validate the request or implement the response. | `Param[]` |
| authParams | A set of key value pair params to be added to any request made to the `authUrl`. When the `authMethod` is `GET`, query params are added to the URL, whereas when `authMethod` is `POST`, the params are sent as URL encoded form data. Useful when an application require these to be added to validate the request or implement the response. | `Param[]` |
| tokenDetails | An authenticated [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `authUrl` or `authCallback`. Use this option if you wish to use Token authentication. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `TokenDetails` |
| tls | A boolean value, indicating whether or not a TLS ("SSL") secure connection should be used. An insecure connection cannot be used with Basic authentication as it would lead to a possible compromise of the private API key while in transit. [Find out more about TLS](https://faqs.ably.com/are-messages-sent-to-and-received-from-ably-securely-using-tls)
_default: true_ | `Boolean` |
| clientId | A client ID, used for identifying this client when publishing messages or for presence purposes. The `clientId` can be any non-empty string. This option is primarily intended to be used in situations where the library is instantiated with a key; note that a `clientId` may also be implicit in a token used to instantiate the library; an error will be raised if a `clientId` specified here conflicts with the `clientId` implicit in the token. [Find out more about client identities](https://ably.com/docs/auth/identified-clients.md) | `String` |
| useTokenAuth | When true, forces [Token authentication](https://ably.com/docs/auth/token.md) to be used by the library. Please note that if a `clientId` is not specified in the [`ClientOptions`](https://ably.com/docs/api/realtime-sdk/types.md#client-options) or [`TokenParams`](https://ably.com/docs/api/realtime-sdk/types.md#token-params), then the Ably Token issued will be [anonymous](https://faqs.ably.com/authenticated-and-identified-clients).
_default: false_ | `Boolean` |
| endpoint | The endpoint used by both REST requests and the realtime connection. It can be a routing policy name, such as `acme`, which connects to `acme.realtime.ably.net` (enterprise customers can use their own routing policies, which support dedicated, isolated clusters and regional message routing and storage constraints); a `nonprod:` routing policy name, such as `nonprod:sandbox`; or a hostname (a value containing `.` or `::`, or `localhost`), which is used as given and has no default fallback hosts. See our [platform customization guide](https://ably.com/docs/platform/account/enterprise-customization.md) for more details.
_default: main_ | `String` |
| idempotentRestPublishing | When true, enables idempotent publishing by assigning a unique message ID client-side, allowing the Ably servers to discard automatic publish retries following a failure such as a network fault. Enabled by default in all current Ably SDKs.
_default: true_ | `Boolean` |
| fallbackHosts | An array of fallback hosts to be used in the case of an error necessitating the use of an alternative host. When `endpoint` is a hostname, there are no default fallback hosts and the [fallback host functionality](https://faqs.ably.com/routing-around-network-and-dns-issues) is disabled unless you specify them here. If your customer success manager has provided you with a set of custom fallback hosts, please specify them here; they always replace the defaults.
_default: `[main.a.fallback.ably-realtime.com, main.b.fallback.ably-realtime.com, main.c.fallback.ably-realtime.com, main.d.fallback.ably-realtime.com, main.e.fallback.ably-realtime.com]`, derived from `endpoint`_ | `String[]` |
| transportParams | Optional. Can be used to pass in arbitrary connection parameters, such as [`heartbeatInterval`](https://ably.com/docs/connect.md#heartbeats) and [`remainPresentFor`](https://ably.com/docs/presence-occupancy/presence.md#unstable-connections) | `Param[]` |
| logLevel | A number controlling the verbosity of the output from 2 (maximum, verbose) to 6 (errors only). A special value of 99 will silence all logging. Note that the `logLevel` is a static variable in the library and will thus not act independently between library instances when multiple library instances exist concurrently.
_default: 5_ | `Integer` |
| logHandler | A `LogHandler` interface can be specified to handle each line of log output. If `logHandler` is not specified, `System.out` is used. Note that the `logHandler` is a static variable in the library and will thus not act independently between library instances when multiple library instances exist concurrently.
_default: `Log.DefaultHandler`, which writes to `System.out`_ | `Log.LogHandler` |
| useBinaryProtocol | If set to false, will forcibly disable the binary protocol (MessagePack). The binary protocol is used by default unless it is not supported. Find out more about the [benefits of binary encoding](https://faqs.ably.com/do-you-binary-encode-your-messages-for-greater-efficiency)
_default: true_ | `Boolean` |
| queryTime | If true, the library will query the Ably servers for the current time when [issuing TokenRequests](https://ably.com/docs/auth/token.md) instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request), so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd). The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request.
_default: false_ | `Boolean` |
| defaultTokenParams | When a [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) object is provided, it will override the client library defaults when issuing new [Ably Tokens](https://ably.com/docs/api/realtime-sdk/authentication.md#token-details) or [Ably `TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) | [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) |
#### Properties
| Parameter | Description | Type |
|-----------|-------------|------|
| key | The full key string, as obtained from the [application dashboard](https://ably.com/dashboard). Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequests. Read more about [Basic authentication](https://ably.com/docs/auth/basic.md) | `String` |
| token | An authenticated token. This can either be a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object, a [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request) object, or token string (obtained from the `token` property of a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) component of an Ably TokenRequest response, or a [JSON Web Token](https://tools.ietf.org/html/rfc7519) satisfying [the Ably requirements for JWTs](https://ably.com/docs/auth/token/jwt.md)). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `authUrl` or `authCallback`. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `String`, `TokenDetails` or `TokenRequest` |
| authCallback | A function which is called when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). See [our authentication documentation](https://ably.com/docs/auth.md) for details of the Ably TokenRequest format and associated API calls. | `Callable` |
| authUrl | A URL that the library may use to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). For example, this can be used by a client to obtain signed Ably TokenRequests from an application server. | `String` |
| authMethod | The HTTP verb to use for the request, either `GET` or `POST`
_default: `GET`_ | `String` |
| authHeaders | A set of key value pair headers to be added to any request made to the `authUrl`. Useful when an application requires these to be added to validate the request or implement the response. | `Associative Array` |
| authParams | A set of key value pair params to be added to any request made to the `authUrl`. When the `authMethod` is `GET`, query params are added to the URL, whereas when `authMethod` is `POST`, the params are sent as URL encoded form data. Useful when an application require these to be added to validate the request or implement the response. | `Associative Array` |
| tokenDetails | An authenticated [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `authUrl` or `authCallback`. Use this option if you wish to use Token authentication. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `TokenDetails` |
| tls | A boolean value, indicating whether or not a TLS ("SSL") secure connection should be used. An insecure connection cannot be used with Basic authentication as it would lead to a possible compromise of the private API key while in transit. [Find out more about TLS](https://faqs.ably.com/are-messages-sent-to-and-received-from-ably-securely-using-tls)
_default: true_ | `Boolean` |
| clientId | A client ID, used for identifying this client when publishing messages or for presence purposes. The `clientId` can be any non-empty string. This option is primarily intended to be used in situations where the library is instantiated with a key; note that a `clientId` may also be implicit in a token used to instantiate the library; an error will be raised if a `clientId` specified here conflicts with the `clientId` implicit in the token. [Find out more about client identities](https://ably.com/docs/auth/identified-clients.md) | `String` |
| useTokenAuth | When true, forces [Token authentication](https://ably.com/docs/auth/token.md) to be used by the library. Please note that if a `clientId` is not specified in the [`ClientOptions`](https://ably.com/docs/api/realtime-sdk/types.md#client-options) or [`TokenParams`](https://ably.com/docs/api/realtime-sdk/types.md#token-params), then the Ably Token issued will be [anonymous](https://faqs.ably.com/authenticated-and-identified-clients).
_default: false_ | `Boolean` |
| endpoint | Where the client connects. This replaces the removed `environment` and `restHost` options, which are ignored if passed. One of: a routing policy ID such as `main`, or a dedicated cluster ID such as `acme`, which resolves to `[id].realtime.ably.net`; `nonprod:[id]`, which resolves to `[id].realtime.ably-nonprod.net`; or a hostname (a value containing `.` or `::`, or `localhost`), which is used as given and has no default fallback hosts. Enables [enterprise customers](https://ably.com/pricing) to use their own custom endpoints, which support dedicated, isolated clusters and regional message routing and storage constraints. See our [platform customization guide](https://ably.com/docs/platform/account/enterprise-customization.md) for more details.
_default: `main`_ | `String` |
| idempotentRestPublishing | When true, enables idempotent publishing by assigning a unique message ID client-side, allowing the Ably servers to discard automatic publish retries following a failure such as a network fault. Enabled by default in all current Ably SDKs.
_default: true_ | `Boolean` |
| fallbackHosts | An array of fallback hosts to be used in the case of an error necessitating the use of an alternative host. A non-empty array replaces the default fallback hosts, which are derived from `endpoint`. When `endpoint` is a hostname there are no default fallback hosts, so the [fallback host functionality](https://faqs.ably.com/routing-around-network-and-dns-issues) is disabled unless you specify them here. If your customer success manager has provided you with a set of custom fallback hosts, please specify them here.
_default: `[main.a.fallback.ably-realtime.com, main.b.fallback.ably-realtime.com, main.c.fallback.ably-realtime.com, main.d.fallback.ably-realtime.com, main.e.fallback.ably-realtime.com]`_ | `String []` |
| logLevel | A number controlling the verbosity of the log output of the library. Valid values are: 0 (no logs), 1 (errors only), 2 (errors and warnings), 3 (high-level debug output), and 4 (full debug output). The values are available as constants of `\Ably\PubSub\Log`.
_default: 2 (`Log::WARNING`)_ | `Integer` |
| logHandler | A function to handle each line of the library's log output. If `logHandler` is not specified, STDOUT is used. | `Callable` |
| useBinaryProtocol | If set to false, will forcibly disable the binary protocol (MessagePack) and use JSON instead. Find out more about the [benefits of binary encoding](https://faqs.ably.com/do-you-binary-encode-your-messages-for-greater-efficiency)
_default: true_ | `Boolean` |
| queryTime | If true, the library will query the Ably servers for the current time when [issuing TokenRequests](https://ably.com/docs/auth/token.md) instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request), so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd). The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request.
_default: false_ | `Boolean` |
| defaultTokenParams | When a [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) object is provided, it will override the client library defaults when issuing new [Ably Tokens](https://ably.com/docs/api/realtime-sdk/authentication.md#token-details) or [Ably `TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) | [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) |
#### Properties
| Parameter | Description | Type |
|-----------|-------------|------|
| Key | The full key string, as obtained from the [application dashboard](https://ably.com/dashboard). Use this option if you wish to use Basic authentication, or wish to be able to issue Ably Tokens without needing to defer to a separate entity to sign Ably TokenRequests. Read more about [Basic authentication](https://ably.com/docs/auth/basic.md) | `String` |
| Token | An authenticated token. This can either be a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object, a [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request) object, or token string (obtained from the `Token` property of a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) component of an Ably TokenRequest response, or a [JSON Web Token](https://tools.ietf.org/html/rfc7519) satisfying [the Ably requirements for JWTs](https://ably.com/docs/auth/token/jwt.md)). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `AuthUrl` or `AuthCallback`. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `String`, `TokenDetails` or `TokenRequest` |
| AuthCallback | A function which is called when a new token is required. The role of the callback is to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). See [our authentication documentation](https://ably.com/docs/auth.md) for details of the Ably TokenRequest format and associated API calls. | `Func>` |
| AuthUrl | A URL that the library may use to obtain a fresh token, one of: an Ably Token string (in plain text format); a signed [`TokenRequest`](https://ably.com/docs/api/realtime-sdk/types.md#token-request); a [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) (in JSON format); an [Ably JWT](https://ably.com/docs/api/realtime-sdk/authentication.md#ably-jwt). For example, this can be used by a client to obtain signed Ably TokenRequests from an application server. | `Uri` |
| AuthMethod | The HTTP verb to use for the request, either `GET` or `POST`
_default: `GET`_ | `HttpMethod` |
| AuthHeaders | A set of key value pair headers to be added to any request made to the `AuthUrl`. Useful when an application requires these to be added to validate the request or implement the response. | `Dictionary` |
| AuthParams | A set of key value pair params to be added to any request made to the `AuthUrl`. When the `AuthMethod` is `GET`, query params are added to the URL, whereas when `AuthMethod` is `POST`, the params are sent as URL encoded form data. Useful when an application require these to be added to validate the request or implement the response. | `Dictionary` |
| TokenDetails | An authenticated [`TokenDetails`](https://ably.com/docs/api/realtime-sdk/types.md#token-details) object (most commonly obtained from an Ably Token Request response). This option is mostly useful for testing: since tokens are short-lived, in production you almost always want to use an authentication method that allows the client library to renew the token automatically when the previous one expires, such as `AuthUrl` or `AuthCallback`. Use this option if you wish to use Token authentication. Read more about [Token authentication](https://ably.com/docs/auth/token.md) | `TokenDetails` |
| Tls | A boolean value, indicating whether or not a TLS ("SSL") secure connection should be used. An insecure connection cannot be used with Basic authentication as it would lead to a possible compromise of the private API key while in transit. [Find out more about TLS](https://faqs.ably.com/are-messages-sent-to-and-received-from-ably-securely-using-tls)
_default: true_ | `Boolean` |
| ClientId | A client ID, used for identifying this client when publishing messages or for presence purposes. The `ClientId` can be any non-empty string. This option is primarily intended to be used in situations where the library is instantiated with a key; note that a `ClientId` may also be implicit in a token used to instantiate the library; an error will be raised if a `ClientId` specified here conflicts with the `ClientId` implicit in the token. [Find out more about client identities](https://ably.com/docs/auth/identified-clients.md) | `String` |
| UseTokenAuth | When true, forces [Token authentication](https://ably.com/docs/auth/token.md) to be used by the library. Please note that if a `clientId` is not specified in the [`ClientOptions`](https://ably.com/docs/api/realtime-sdk/types.md#client-options) or [`TokenParams`](https://ably.com/docs/api/realtime-sdk/types.md#token-params), then the Ably Token issued will be [anonymous](https://faqs.ably.com/authenticated-and-identified-clients).
_default: false_ | `Boolean` |
| Endpoint | Sets the endpoint that both REST requests and realtime connections use. The value can be a routing policy name such as `acme` (resolved to `acme.realtime.ably.net`), a non-production routing policy name prefixed with `nonprod:` such as `nonprod:sandbox` (resolved to `sandbox.realtime.ably-nonprod.net`), or a hostname (a value containing `.` or `::`, or `localhost`), which is used as given and has no default fallback hosts. Enables [enterprise customers](https://ably.com/pricing) to use their own custom endpoints, which support dedicated, isolated clusters and regional message routing and storage constraints. See our [platform customization guide](https://ably.com/docs/platform/account/enterprise-customization.md) for more details
**Default:** null (resolves to `main`, that is `main.realtime.ably.net`) | `String` |
| IdempotentRestPublishing | When true, enables idempotent publishing by assigning a unique message ID client-side, allowing the Ably servers to discard automatic publish retries following a failure such as a network fault. Enabled by default in all current Ably SDKs.
_default: true_ | `Boolean` |
| FallbackHosts | An array of fallback hosts to be used in the case of an error necessitating the use of an alternative host. When set, these replace the default fallback hosts, and an empty array disables the [fallback host functionality](https://faqs.ably.com/routing-around-network-and-dns-issues). When `Endpoint` is a hostname there are no default fallback hosts. If your customer success manager has provided you with a set of custom fallback hosts, please specify them here
**Default:** derived from `Endpoint`; for the default endpoint, `[main.a.fallback.ably-realtime.com, main.b.fallback.ably-realtime.com, main.c.fallback.ably-realtime.com, main.d.fallback.ably-realtime.com, main.e.fallback.ably-realtime.com]` | `String[]` |
| TransportParams | Optional. Can be used to pass in arbitrary connection parameters, such as [`heartbeatInterval`](https://ably.com/docs/connect.md#heartbeats) and [`remainPresentFor`](https://ably.com/docs/presence-occupancy/presence.md#unstable-connections) | `Dictionary` |
| LogLevel | This is an enum controlling the verbosity of the output from `Debug` (maximum) to `Error` (errors only). A special value of `None` will silence all logging. Note that the `LogLevel` is a static variable in the library and will thus not act independently between library instances. The default is `Warning`. | `Enum` |
| LogHandler | The default logger outputs messages to the debug console. This property allows the user to pipe the log messages to their own logging infrastructure by supplying an `ILoggerSink`
**Default:** null | `ILoggerSink` |
| UseBinaryProtocol | If set to true, will enable the binary protocol (MessagePack) if it is supported. It's disabled by default on browsers for performance considerations (browsers are optimized for decoding JSON). Find out more about the [benefits of binary encoding](https://faqs.ably.com/do-you-binary-encode-your-messages-for-greater-efficiency)
_default: false_ | `Boolean` |
| QueryTime | If true, the library will query the Ably servers for the current time when [issuing TokenRequests](https://ably.com/docs/auth/token.md) instead of relying on a locally-available time of day. Knowing the time accurately is needed to create valid signed Ably [`TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request), so this option is useful for library instances on auth servers where for some reason the server clock cannot be kept synchronized through normal means, such as an [NTP daemon](https://en.wikipedia.org/wiki/Ntpd). The server is queried for the current time once per client library instance (which stores the offset from the local clock), so if using this option you should avoid instancing a new version of the library for each request.
_default: false_ | `Boolean` |
| DefaultTokenParams | When a [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) object is provided, it will override the client library defaults when issuing new [Ably Tokens](https://ably.com/docs/api/realtime-sdk/authentication.md#token-details) or [Ably `TokenRequests`](https://ably.com/docs/api/rest-sdk/authentication.md#token-request) | [`TokenParams`](https://ably.com/docs/api/rest-sdk/types.md#token-params) |
### Stats object StatsARTStats io.ably.pubsub.types.Stats Ably::Models::Stats Ably\PubSub\Models\Stats Ably.PubSub.Stats
A `Stats` object represents an application's statistics for the specified interval and time period. Ably aggregates statistics globally for all accounts and applications, and makes these available both through our [statistics API](https://ably.com/docs/metadata-stats/stats.md) as well as your [application dashboard](https://ably.com/dashboard).
Please note that most attributes of the `Stats` type below contain references to further stats types. This documentation is not exhaustive for all stats types, and as such, links to the stats types below will take you to the [Ruby library stats documentation](https://www.rubydoc.info/gems/ably/Ably/Models/Stats) which contains exhaustive stats documentation. Ruby and Python however uses `under_score` case instead of the default `camelCase` in most languages, so please bear that in mind.
#### PropertiesMembersAttributesAttributes
| Property | Description | Type |
|----------|-------------|------|
| unit | The length of the interval that this statistic covers, such as `minute`, `hour`, `day` or `month` | `String` |
| interval_id | The UTC time at which the time period covered by this `Stats` object starts, at the resolution of `unit`: for example `2018-03-01:10:02` (minute), `2018-03-01:10` (hour), `2018-03-01` (day) or `2018-03` (month) | `String` |
| interval_time | A `Time` object representing the parsed `interval_id` (the UTC time at which the time period covered by this `Stats` object starts) | `Time` |
| entries | The statistics for the interval, as a flat `Hash` keyed by dot-separated metric name, such as `messages.all.all.count`. The set of metrics available is described by the JSON schema referenced by `schema` | `Hash` |
| in_progress | If present, the last sub-interval, within the interval, for which statistics are included. Only present for an interval that is still in progress | `String` |
| app_id | The ID of the Ably application the statistics relate to | `String` |
| schema | The URL of the JSON schema that describes the structure of `entries` | `String` |
| Parameter | Description | Type |
|-----------|-------------|------|
| IntervalGranularity | The length of the interval that this statistic covers, such as `Minute`, `Hour`, `Day`, `Month`. | [`StatsIntervalGranularity`](https://ably.com/docs/api/realtime-sdk/types.md#stats-granularity) enum |
| IntervalId | The UTC time at which the time period covered by this `Stats` object starts. For example, an interval ID value of "2018-03-01:10" in a `Stats` object whose `IntervalGranularity` is `Day` would indicate that the period covered is "2018-03-01:10 .. 2018-03-01:11". All `Stats` objects, except those whose `IntervalGranularity` is `Minute`, have an interval ID with resolution of one hour and the time period covered will always begin and end at a UTC hour boundary. For this reason it is not possible to infer the `IntervalGranularity` by looking at the resolution of the `intervalId`. `Stats` objects covering an individual minute will have an interval ID indicating that time; for example "2018-03-01:10:02". | `String` |
| IntervalTime | A `DateTimeOffset` representing the start of the interval | `DateTimeOffset` |
| Interval | `IntervalId` parsed as a `DateTimeOffset`. Only minute-resolution interval IDs (for example "2018-03-01:10:02") can be parsed; for other units this property throws | `DateTimeOffset` |
| All | Aggregate count of both `inbound` and `outbound` message stats | [`MessageTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTypes) |
| ApiRequests | Breakdown of API requests received via the Ably REST API | [`RequestCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/RequestCount) |
| Channels | Breakdown of channel related stats such as min, mean and peak channels | [`ResourceCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/ResourceCount) |
| Connections | Breakdown of connection related stats such as min, mean and peak connections for TLS and non-TLS connections | [`ConnectionTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/ConnectionTypes) |
| Inbound | Statistics such as count and data for all inbound messages received over REST and Realtime connections, organized into normal channel messages or presence messages | `InboundMessageTraffic` |
| Outbound | Statistics such as count and data for all outbound messages retrieved via REST history requests, received over Realtime connections, or pushed with Webhooks, organized into normal channel messages or presence messages | `OutboundMessageTraffic` |
| Persisted | Messages persisted and later retrieved via the [history API](https://ably.com/docs/storage-history/history.md) | [`MessageTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTypes) |
| TokenRequests | Breakdown of Ably Token requests received via the Ably REST API. | [`RequestCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/RequestCount) |
| Parameter | Description | Type |
|-----------|-------------|------|
| unit | The length of the interval that this statistic covers, such as `'minute'`, `'hour'`, `'day'`, `'month'`. | `str` |
| interval_id | The UTC time at which the time period covered by this `Stats` object starts. For example, an interval ID value of "2018-03-01:10" in a `Stats` object whose `unit` is `day` would indicate that the period covered is "2018-03-01:10 .. 2018-03-01:11". All `Stats` objects, except those whose `unit` is `minute`, have an interval ID with resolution of one hour and the time period covered will always begin and end at a UTC hour boundary. For this reason it is not possible to infer the `unit` by looking at the resolution of the `interval_id`. `Stats` objects covering an individual minute will have an interval ID indicating that time; for example "2018-03-01:10:02". | `str` |
| interval_time | A timezone-aware `datetime`, in UTC, representing the parsed `interval_id` (the UTC time at which the time period covered by this `Stats` object starts) | `datetime` |
| entries | The statistics for the interval, as a `dict` keyed by metric name, such as `messages.all.all.count`. The set of metrics available is described by the JSON schema referenced by `schema` | `dict` |
| in_progress | If present, the last sub-interval, within the interval, for which statistics are included. Only present for an interval that is still in progress | `str` |
| app_id | The ID of the Ably application the statistics relate to | `str` |
| schema | The URL of the JSON schema that describes the structure of `entries` | `str` |
| Property | Description | Type |
|----------|-------------|------|
| unit | The length of the interval that this statistic covers, such as `minute`, `hour`, `day` or `month` | `ARTStatsGranularity``StatsGranularity` |
| intervalId | The UTC time at which the time period covered by this `Stats` object starts. For example, an interval ID value of "2018-03-01:10" in a `Stats` object whose `unit` is `day` would indicate that the period covered is "2018-03-01:10 .. 2018-03-01:11". All `Stats` objects, except those whose `unit` is `minute`, have an interval ID with resolution of one hour and the time period covered will always begin and end at a UTC hour boundary. For this reason it is not possible to infer the `unit` by looking at the resolution of the `intervalId`. `Stats` objects covering an individual minute will have an interval ID indicating that time; for example "2018-03-01:10:02". | `NSString``String` |
| intervalTime | The start of the interval covered by this `Stats` object | `NSDate``Date` |
| inProgress | If present, the last sub-interval, within the interval, for which statistics are included. Only present for an interval that is still in progress | `NSString``String?` |
| entries | The statistics for the interval, keyed by metric name, such as `messages.inbound.all.messages.count`. A metric with no recorded value is absent. The set of metrics available is described by the JSON schema referenced by `schema` | `NSDictionary``[String: NSNumber]` |
| schema | The URL of the JSON schema that describes the structure of `entries` | `NSString``String` |
| appId | The ID of the Ably application the statistics relate to | `NSString``String` |
| Parameter | Description | Type |
|-----------|-------------|------|
| unit | The length of the interval that this statistic covers, such as `:minute`, `:hour`, `:day`, `:month``Minute`, `Hour`, `Day`, `Month``"day"`, `"month"``'minute'`, `'hour'`, `'day'`, `'month'`. | [`Stats::GRANULARITY`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats#GRANULARITY-constant)[`StatsIntervalGranularity`](https://ably.com/docs/api/realtime-sdk/types.md#stats-granularity) enum`ARTStatsGranularity``StatsGranularity``String` |
| intervalIdinterval_idIntervalIdIntervalID | The UTC time at which the time period covered by this `Stats` object starts. For example, an interval ID value of "2018-03-01:10" in a `Stats` object whose `unit` is `day` would indicate that the period covered is "2018-03-01:10 .. 2018-03-01:11". All `Stats` objects, except those whose `unit` is `minute`, have an interval ID with resolution of one hour and the time period covered will always begin and end at a UTC hour boundary. For this reason it is not possible to infer the `unit` by looking at the resolution of the `intervalId`. `Stats` objects covering an individual minute will have an interval ID indicating that time; for example "2018-03-01:10:02". | `String` |
| allAll | Aggregate count of both `inbound` and `outbound` message stats | [`MessageTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTypes) |
| apiRequestsapi_requestsApiRequestsAPIRequests | Breakdown of API requests received via the Ably REST API | [`RequestCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/RequestCount) |
| channelsChannels | Breakdown of channel related stats such as min, mean and peak channels | [`ResourceCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/ResourceCount) |
| connectionsConnections | Breakdown of connection related stats such as min, mean and peak connections for TLS and non-TLS connections | [`ConnectionTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/ConnectionTypes) |
| inboundInbound | Statistics such as count and data for all inbound messages received over REST and Realtime connections, organized into normal channel messages or presence messages | [`MessageTraffic`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTraffic) |
| outboundOutbound | Statistics such as count and data for all outbound messages retrieved via REST history requests, received over Realtime connections, or pushed with Webhooks, organized into normal channel messages or presence messages | [`MessageTraffic`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTraffic) |
| persistedPersisted | Messages persisted and later retrieved via the [history API](https://ably.com/docs/storage-history/history.md) | [`MessageTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTypes) |
| tokenRequeststoken_requestsTokenRequests | Breakdown of Ably Token requests received via the Ably REST API. | [`RequestCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/RequestCount) |
| pushPush | Detailed stats on push notifications, see [our Push documentation](https://ably.com/docs/push.md) for more details | `PushStats` |
| Parameter | Description | Type |
|-----------|-------------|------|
| Unit | The length of the interval that this statistic covers, such as `"minute"`, `"hour"`, `"day"` or `"month"`. | `string` |
| IntervalID | The UTC time at which the time period covered by this `Stats` object starts. For example, an interval ID value of "2018-03-01:10" in a `Stats` object whose `Unit` is `day` would indicate that the period covered is "2018-03-01:10 .. 2018-03-01:11". All `Stats` objects, except those whose `Unit` is `minute`, have an interval ID with resolution of one hour and the time period covered will always begin and end at a UTC hour boundary. For this reason it is not possible to infer the `Unit` by looking at the resolution of the `IntervalID`. `Stats` objects covering an individual minute will have an interval ID indicating that time; for example "2018-03-01:10:02". | `string` |
| InProgress | If present, the last sub-interval, within the interval, for which statistics are included. Only present for an interval that is still in progress | `string` |
| Count | The number of stats entries aggregated into this `Stats` object | `float64` |
| All | Aggregate count of both `inbound` and `outbound` message stats | `StatsMessageTypes` |
| APIRequests | Breakdown of API requests received via the Ably REST API | `StatsRequestCount` |
| Channels | Breakdown of channel related stats such as min, mean and peak channels | `StatsResourceCount` |
| Connections | Breakdown of connection related stats such as min, mean and peak connections for TLS and non-TLS connections | `StatsConnectionTypes` |
| Inbound | Statistics such as count and data for all inbound messages received over REST and Realtime connections, organized into normal channel messages or presence messages | `StatsMessageTraffic` |
| Outbound | Statistics such as count and data for all outbound messages retrieved via REST history requests, received over Realtime connections, or pushed with Webhooks, organized into normal channel messages or presence messages | `StatsMessageTraffic` |
| Persisted | Messages persisted and later retrieved via the [history API](https://ably.com/docs/storage-history/history.md) | `StatsMessageTypes` |
| TokenRequests | Breakdown of Ably Token requests received via the Ably REST API. | `StatsRequestCount` |
| Push | Detailed stats on push notifications, see [our Push documentation](https://ably.com/docs/push.md) for more details | `PushStats` |
| XchgProducer | Breakdown of usage of the Ably API Streamer as a producer | `StatsXchgMessages` |
| XchgConsumer | Breakdown of usage of the Ably API Streamer as a consumer | `StatsXchgMessages` |
| PeakRates | Peak message, API request, token request and reactor rates | `StatsRates` |
| Parameter | Description | Type |
|-----------|-------------|------|
| unit | The length of the interval that this statistic covers, such as `'minute'`, `'hour'`, `'day'`, `'month'`. | `String` |
| intervalId | The UTC time at which the time period covered by this `Stats` object starts. For example, an interval ID value of "2018-03-01:10" in a `Stats` object whose `unit` is `day` would indicate that the period covered is "2018-03-01:10 .. 2018-03-01:11". All `Stats` objects, except those whose `unit` is `minute`, have an interval ID with resolution of one hour and the time period covered will always begin and end at a UTC hour boundary. For this reason it is not possible to infer the `unit` by looking at the resolution of the `intervalId`. `Stats` objects covering an individual minute will have an interval ID indicating that time; for example "2018-03-01:10:02". | `String` |
| all | Aggregate count of both `inbound` and `outbound` message stats | [`MessageTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTypes) |
| apiRequests | Breakdown of API requests received via the Ably REST API | [`RequestCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/RequestCount) |
| channels | Breakdown of channel related stats such as min, mean and peak channels | [`ResourceCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/ResourceCount) |
| connections | Breakdown of connection related stats such as min, mean and peak connections for TLS and non-TLS connections | [`ConnectionTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/ConnectionTypes) |
| inbound | Statistics such as count and data for all inbound messages received over REST and Realtime connections, organized into normal channel messages or presence messages | [`MessageTraffic`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTraffic) |
| outbound | Statistics such as count and data for all outbound messages retrieved via REST history requests, received over Realtime connections, or pushed with Webhooks, organized into normal channel messages or presence messages | [`MessageTraffic`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTraffic) |
| persisted | Messages persisted and later retrieved via the [history API](https://ably.com/docs/storage-history/history.md) | [`MessageTypes`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/MessageTypes) |
| tokenRequests | Breakdown of Ably Token requests received via the Ably REST API. | [`RequestCount`](https://www.rubydoc.info/gems/ably/Ably/Models/Stats/RequestCount) |
### ARTStatsGranularityStatsGranularityStatsIntervalGranularity
`ARTStatsGranularity``StatsGranularity` is an enum specifying the granularity of a [ARTStats interval](https://ably.com/docs/api/rest-sdk/statistics.md#stats-type)[Stats interval](https://ably.com/docs/api/rest-sdk/statistics.md#stats-type).
#### Objc
```
typedef NS_ENUM(NSUInteger, ARTStatsGranularity) {
ARTStatsGranularityMinute,
ARTStatsGranularityHour,
ARTStatsGranularityDay,
ARTStatsGranularityMonth
};
```
#### Swift
```
enum StatsGranularity : UInt {
case minute
case hour
case day
case month
}
```
`StatsIntervalGranularity` is an enum specifying the granularity of a [Stats interval](https://ably.com/docs/api/rest-sdk/statistics.md#stats-type).
#### Csharp
```
public enum StatsIntervalGranularity
{
Minute,
Hour,
Day,
Month
}
```
### HttpPaginatedResponseHTTPPaginatedResponse
An `HttpPaginatedResponse` is a superset of [PaginatedResult](https://ably.com/docs/api/rest-sdk/types.md#paginated-result), which is a type that represents a page of results plus metadata indicating the relative queries available to it. `HttpPaginatedResponse` additionally carries information about the response to an HTTP request. It is used when [making custom HTTP requests](https://ably.com/docs/api/rest-sdk.md#request).An `HTTPPaginatedResponse` is a superset of [PaginatedResult](https://ably.com/docs/api/rest-sdk/types.md#paginated-result), which is a type that represents a page of results plus metadata indicating the relative queries available to it. `HTTPPaginatedResponse` additionally carries information about the response to an HTTP request. It is used when [making custom HTTP requests](https://ably.com/docs/api/rest-sdk.md#request).
#### PropertiesMembersAttributes
| Property | Description | Type |
|----------|-------------|------|
| itemsitems()Itemsitems`Items(dst interface{})` | Contains a page of results; for example, an array of [Message](#message) or [PresenceMessage](#presence-message) objects for a channel history request | `Array<>``List<>``error` |
| statusCodestatus_codeStatusCode`StatusCode()` | The HTTP status code of the response | `Number` |
| successSuccess`Success()` | Whether the HTTP status code indicates success. This is equivalent to `200 <= statusCode < 300``200 <= status_code < 300``200 <= StatusCode < 300` | `Boolean` |
| headersHeaders`Headers()` | The headers of the response | `Object` |
| errorCodeerror_codeErrorCode`ErrorCode()` | The error code if the `X-Ably-Errorcode` HTTP header is sent in the response | `Int` |
| errorMessageerror_messageErrorMessage`ErrorMessage()` | The error message if the `X-Ably-Errormessage` HTTP header is sent in the response | `String` |
| Property | Description | Type |
|----------|-------------|------|
| `Items(dst interface{})` | Decodes the current page of results into `dst`; for example, a slice of [Message](#message) or [PresenceMessage](#presence-message) values for a channel history request | `error` |
| `StatusCode()` | The HTTP status code of the response | `int` |
| `Success()` | Whether the HTTP status code indicates success. This is equivalent to `200 <= StatusCode < 300` | `bool` |
| `Headers()` | The headers of the response | `http.Header` |
| `ErrorCode()` | The error code if the `X-Ably-Errorcode` HTTP header is sent in the response | `ErrorCode` |
| `ErrorMessage()` | The error message if the `X-Ably-Errormessage` HTTP header is sent in the response | `string` |
| Property | Description | Type |
|----------|-------------|------|
| items | Contains a page of results; for example, a list of [Message](#message) or [PresenceMessage](#presence-message) objects for a channel history request | `list` |
| status_code | The HTTP status code of the response | `int` |
| success | Whether the HTTP status code indicates success. This is equivalent to `200 <= status_code < 300` | `bool` |
| headers | The headers of the response, as a read-only mapping from header name to value, looked up case-insensitively | `Mapping[str, str]` |
| error_code | The error code if the `X-Ably-Errorcode` HTTP header is sent in the response, otherwise `None` | `int` |
| error_message | The error message if the `X-Ably-Errormessage` HTTP header is sent in the response | `str` |
| Property | Description | Type |
|----------|-------------|------|
| status_code | The HTTP status code of the response | `Number` |
| success | Whether the HTTP status code indicates success. This is equivalent to `200 <= status_code < 300` | `Boolean` |
| headers | The headers of the response | `Object` |
| error_code | The error code if the `X-Ably-Errorcode` HTTP header is sent in the response | `Int` |
| error_message | The error message if the `X-Ably-Errormessage` HTTP header is sent in the response | `String` |
| Property | Description | Type |
|----------|-------------|------|
| statusCodestatus_codeStatusCode | The HTTP status code of the response | `Number` |
| successSuccess | Whether the HTTP status code indicates success. This is equivalent to `200 <= statusCode < 300``200 <= status_code < 300``200 <= StatusCode < 300` | `Boolean` |
| headersHeaders | The headers of the response | `Object` |
| errorCodeerror_codeErrorCode | The error code if the `X-Ably-Errorcode` HTTP header is sent in the response | `Int` |
| errorMessageerror_messageErrorMessage | The error message if the `X-Ably-Errormessage` HTTP header is sent in the response | `String` |
#### Methods
##### firstFirst
`HttpPaginatedResponse first`
Returns a new `HttpPaginatedResponse` for the first page of results. When using the Realtime library, the `first` method returns a [Deferrable](https://ably.com/docs/api/realtime-sdk/types.md#deferrable) and yields an [HttpPaginatedResponse](https://ably.com/docs/api/realtime-sdk/types.md#http-paginated-response).
`HttpPaginatedResponse first()`
Returns a new `HttpPaginatedResponse` for the first page of results.
`async first() -> HttpPaginatedResponse`
Returns a new `HttpPaginatedResponse` for the first page of results.
`Task FirstAsync()`
Returns a new `HttpPaginatedResponse` for the first page of results. The method is asynchronous and returns a Task which needs to be awaited to get the [HttpPaginatedResponse](https://ably.com/docs/api/realtime-sdk/types.md#http-paginated-response).
`HttpPaginatedResponse first()`
Returns a new `HttpPaginatedResponse` for the first page of results.
`first(callback: (ARTHTTPPaginatedResponse?, ARTErrorInfo?) -> Void)`
Returns a new `HttpPaginatedResponse` for the first page of results.
`first(callback: (HTTPPaginatedResponse?, ErrorInfo?) -> Void)`
Returns a new `HTTPPaginatedResponse` for the first page of results.
`First(ctx context.Context) error`
Loads the first page of results. Call `Next` before reading the page with `Items`.
##### hasNextHasNexthas_next?has_next
`Boolean hasNext()`
`Boolean has_next?`
`Boolean hasNext()`
`has_next() -> bool`
`bool HasNext`
`Boolean hasNext()`
`HasNext(ctx context.Context) bool`
Returns `true` if there are more pages available by calling `next``Next` and returns `false` if this page is the last page available.
##### isLastIsLastlast?is_last
`Boolean isLast()`
`Boolean last?`
`Boolean isLast()`
`is_last() -> bool`
`bool IsLast`
`Boolean isLast()`
`IsLast(ctx context.Context) bool`
Returns `true` if this page is the last page and returns `false` if there are more pages available by calling `next``Next` available.
##### nextNext
`HttpPaginatedResponse next`
Returns a new `HttpPaginatedResponse` loaded with the next page of results. If there are no further pages, then `null` is returned. When using the Realtime library, the `first` method returns a [Deferrable](https://ably.com/docs/api/realtime-sdk/types.md#deferrable) and yields an [HttpPaginatedResponse](https://ably.com/docs/api/realtime-sdk/types.md#http-paginated-response).
`HttpPaginatedResponse next()`
Returns a new `HttpPaginatedResponse` loaded with the next page of results. If there are no further pages, then `null` is returned.
`async next() -> HttpPaginatedResponse`
Returns a new `HttpPaginatedResponse` loaded with the next page of results. If there are no further pages, then `None` is returned.
`Task NextAsync()`
Returns a new `HttpPaginatedResponse` loaded with the next page of results. If there are no further pages, then a blank HttpPaginatedResponse will be returned. The method is asynchronous and return a Task which needs to be awaited to get the `HttpPaginatedResponse`.
`HttpPaginatedResponse next()`
Returns a new `HttpPaginatedResponse` loaded with the next page of results. If there are no further pages, then `Null` is returned.
`next(callback: (ARTHTTPPaginatedResponse?, ARTErrorInfo?) -> Void)`
Returns a new `HttpPaginatedResponse` loaded with the next page of results. If there are no further pages, then `nil` is returned.
`next(callback: (HTTPPaginatedResponse?, ErrorInfo?) -> Void)`
Returns a new `HTTPPaginatedResponse` loaded with the next page of results. If there are no further pages, then `nil` is returned.
`Next(ctx context.Context) bool`
Loads the next page of results and returns `true`, or returns `false` if there are no further pages or the page could not be loaded (see `Err() error`).
#### Example
The `HttpPaginatedResponse` interface is a superset of `PaginatedResult`, see the [PaginatedResult example](https://ably.com/docs/api/rest-sdk/types.md#paginated-result-example)The `HTTPPaginatedResponse` is a superset of `PaginatedResult`, see the [PaginatedResult example](https://ably.com/docs/api/rest-sdk/types.md#paginated-result-example)
### io.ably.pubsub.types.Param
`Param` is a type encapsulating a key/value pair. This type is used frequently in method parameters allowing key/value pairs to be used more flexible, see [Channel#history](https://ably.com/docs/api/realtime-sdk/history.md#channel-history) for an example.
Please note that `key` and `value` attributes are always strings. If an `Integer` or other value type is expected, then you must coerce that type into a `String`.
#### Members
| Property | Description | Type |
|----------|-------------|------|
| key | The key value | `String` |
| value | The value associated with the `key` | `String` |
## Related Topics
- [Channels](https://ably.com/docs/api/rest-sdk/channels.md): Client Library SDK REST API Reference Channels documentation.
- [Channel Status](https://ably.com/docs/api/rest-sdk/channel-status.md): Client Library SDK REST API Reference Channel Status documentation.
- [Messages](https://ably.com/docs/api/rest-sdk/messages.md): Client Library SDK REST API Reference Message documentation.
- [Presence](https://ably.com/docs/api/rest-sdk/presence.md): Presence events provide clients with information about the status of other clients 'present' on a channel
- [Authentication](https://ably.com/docs/api/rest-sdk/authentication.md): Client Library SDK REST API Reference Authentication documentation.
- [History](https://ably.com/docs/api/rest-sdk/history.md): Client Library SDK REST API Reference History documentation.
- [Push Notifications - Admin](https://ably.com/docs/api/rest-sdk/push-admin.md): Client Library SDK REST API Reference Push documentation.
- [Encryption](https://ably.com/docs/api/rest-sdk/encryption.md): Client Library SDK REST API Reference Crypto documentation.
- [Statistics](https://ably.com/docs/api/rest-sdk/statistics.md): Client Library SDK REST API Reference Statistics documentation.
- [Types](https://ably.com/docs/api/rest-sdk/types.md): Client Library SDK REST API Reference Types documentation.
## Documentation Index
To discover additional Ably documentation:
1. Fetch [llms.txt](https://ably.com/llms.txt) for the canonical list of available pages.
2. Identify relevant URLs from that index.
3. Fetch target pages as needed.
Avoid using assumed or outdated documentation paths.