Warning: You are viewing an old version (0.8) of this documentation. We recommend you view the latest version 1.1.
Realtime Client Library API

Using the Realtime library

The Realtime library when initialized attempts to establish and maintain a single connection to the Ably realtime service. The library extends the REST library to provide all REST API functionality including the authentication API. Whereas the Ably REST API is stateless, the Realtime API maintains connection and channel state.

The Ably Realtime client library is available for most popular languages and platforms with a consistent API across all platforms. You can view this documentation with your preferred language API and code examples using the language selector navigation above. If your preferred language is not listed in the language selector, please download the library in your preferred language and use that as a reference.

The Realtime library for browser Javascript environments should be loaded from the Ably CDN as follows:

<script lang="text/javascript" src="//cdn.ably.io/lib/ably.min-0.js" />

You can also obtain the library as an NPM module, or download the source directly from Github

The script and module both contain the Realtime and REST libraries as well as all their dependencies. To instance the Realtime library:

var realtime = new Ably.Realtime({ key: apiKey });

When including the client library from our CDN, we recommend you lock into major version 0 of the library. According to the semantic versioning scheme we adopt, you will then automatically receive minor and patch updates but you will never receive breaking changes. For example, if you lock into major version 0 of the library by including https://cdn.ably.io/lib/ably.min-0.js, you will receive all minor updates and patch fixes automatically (i.e 0.*.*). If you want to lock into minor version 0.8 and receive all patch fixes automatically (i.e. 0.8.*), then use https://cdn.ably.io/lib/ably.min-0.8.js. Additionally, the .min suffix can be dropped if you want the non-minified version for debugging.

View a complete list of the Javascript library releases

The Realtime library for Node.js is suitable for clients and servers and is hosted on Github and is obtainable as an NPM module directly from npm. Install with:

npm install ably

The Ably Node.js module contains both the REST and Realtime libraries; each is exported separately by the module. To instance the Realtime library:

var Ably = require('ably');
var realtime = new Ably.Realtime({ key: apiKey });

The Realtime library for Ruby hosted on Github and is published as a RubyGem and can be installed as follows:

gem install ably

If using bundler, simply add the following to your Gemfile and run bundle install:

gem 'ably'

The Ably Ruby gem contains both the REST and Realtime libraries; each is namespaced separately by the gem. To instance the Realtime library:

ably = Ably::Realtime.new(key: api_key)

The Realtime library for Java and Android is hosted on Github and is downloadable as a JAR from https://github.com/ably/ably-java/releases or via JCentre.

Ensure the JAR is included in your classpath as follows:

import io.ably.lib.types.*;
import io.ably.lib.realtime.*;
ClientOptions options = new ClientOptions(apiKey);
AblyRealtime realtime = new AblyRealtime(options);

The Realtime library for .Net is available as a Nuget Package. Open the nuget console in visual studio and type.

PM> Install-Package ably.io

Alternatively, search for the ‘ably.io’ package through the Nuget UI

using IO.Ably;

ClientOptions clientOptions = new ClientOptions("<API Key>");
AblyRealtime realtime = new AblyRealtime(clientOptions);

The Ably library is hosted on Github and is available as a CocoaPod. Add this line to your application’s Podfile:

pod 'AblyRealtime'

And install with pod install. Then in your files:

#import "Ably/Ably.h"

ARTRealtime realtime = [[ARTRealtime alloc] initWithKey:apiKey];
import Ably

let realtime = ARTRealtime(key: apiKey)

Note: The 0.8 iOS client libraries are not thread-safe. If you can’t upgrade to 1.0, we recommend that you ensure that all operations on a ARTRest or ARTRealtime object happen in the same Grand Central Dispatch serial queue. Also, it’s undefined from which queue or thread will callback blocks provided to the Ably library be called. This queue may be the same queue you use to call Ably, so if you’re calling another Ably operation from your callback, you should only dispatch a new task for it if you’re not already in Ably’s queue. For example:

@implementation YourClass {
    dispatch_queue_t _ablyQueue;
    ARTRealtime *ably;
}

- (void)initializeAbly {
    _ablyQueue = dispatch_queue_create("com.example.ably", NULL);
    [self doAblyOperation:^{
        _ably = [ARTRealtime initWithOptions:[self ablyOptions]];
    }];
}

- (void)subscribeToAbly {
    [self doAblyOperation:^{
        [[_ably.channels get:@"foo"] subscribe:^(ARTMessage *message) {
            // Answer back.
            [self doAblyOperation:^{
                [[_ably.channels get:@"foo"] publish:@"reply" data:@"Hi back!"];
            }];
        }];
    }];
}

- (void)doAblyOperation:(dispatch_block_t)block {
    // Make sure we're not already in the Ably queue! This can happen if Ably
    // calls our callback from the same task we dispatch.
    if (dispatch_get_current_queue() == _ablyQueue) {
        block();
    } else {
        dispatch_sync(_ablyQueue, block);
    }
}
class YourClass {
    var ablyQueue: DispatchQueue!
    var ably: ARTRealtime!

    func initializeAbly() {
        self.ablyQueue = DispatchQueue(label: "com.example.ably")
        self.doAblyOperation {
            self.ably = ARTRealtime(options: self.ablyOptions)
        }
    }

    func subscribeToAbly() {
        self.doAblyOperation {
            self.ably.channels.get("foo").subscribe { message in
                // Answer back.
                self.doAblyOperation {
                    self.ably.channels.get("foo").publish("reply", data:"Hi back!")
                }
            }
        }
    }

    func doAblyOperation(_ operation: () -> Void) {
        // Make sure we're not already in the Ably queue! This can happen if Ably
        // calls our callback from the same task we dispatch.
        if (String(validatingUTF8: __dispatch_queue_get_label(nil)) == "com.example.ably") {
            operation()
        } else {
            self.ablyQueue.sync(execute: operation)
        }
    }
}

The library is thread-safe on the 1.0 branch, starting from version 1.0.8.

The supported client options are described below.

Realtime API ReferenceRealtime::Client API reference

Constructor

The Ably Realtime library constructor is overloaded allowing it to be instanced using a ClientOptions object, or more simply using a string containing an API key or Token.

new Ably.Realtime(String keyOrTokenId)Ably::Realtime.new(String key_or_token_id)new io.ably.lib.AblyRealtime(String keyOrTokenIdString)new AblyRealtime(string key)- (instancetype)initWithKey:(NSString *)keyinit(key: String)
init(token: String)

This will instance the Realtime library with the provided API key or Token ID string.

new Ably.Realtime(ClientOptions clientOptions)Ably::Realtime.new(ClientOptions client_options)new io.ably.lib.AblyRealtime(ClientOptions clientOptions)new AblyRealtime(ClientOptions clientOptions)- (instancetype)initWithOptions:(ARTClientOptions *)options;init(options: ARTClientOptions)

This will instance the library using the specified ClientOptions.

This will instance the library and create a new Ably::Realtime::Client using the specified ClientOptions.

The Realtime constructor is used to instance the library. The Realtime library may be instanced multiple times with the same or different ClientOptions in any given context. Except where specified otherwise, instances operate independently of one another.

Authentication

The Realtime library 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.

Basic Authentication

A private API key string for ClientOptions#keyClientOptions#Key or the constructor, as obtained from the application dashboard, is required for Basic Authentication. Use this option if you wish to use Basic authentication, or if you want to be able to request tokens without needing to defer to a separate entity to sign token requests. Note that initializing the library with a keyKey does not necessarily mean that the library will use Basic auth; using the private key it is also able to create and sign token requests and use token authentication when necessary.

Token Authentication

The ClientOptions#token option takes a token string, and assumes the 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 authCallbackAuthUrl and AuthCallback:auth_url and :auth_callback options are provided to allow a user of the library to provide new tokens or token requests to the library as required; using these options allows the library to be instanced without a key or tokenKey or Token, and an initial token will be obtained automatically when required.

Read more on authentication.

AblyRealtime Propertiesio.ably.lib.AblyRealtime MembersAbly::Realtime::Client AttributesARTRealtime Properties

The Realtime client exposes the following public attributesmembersproperties:

authAuth

A reference to the Auth authentication object configured for this client library.

channelsChannels

A reference to the Channel collection instance for this library indexed by the channel name. See channels and messages for more information.

clientIdclient_idClientId

The client ID string, if any, configured for this client connection. See authentication for more information on authentication and using a client ID.

connectionConnection

A reference to the Connection object for this library instance.

rest_client

A reference to the REST Client configured with the same ClientOptions. The Realtime library is a superset of the REST library, however accessing methods in the REST library, unlike the Realtime library, are blocking operations.

AblyRealtime Methodsio.ably.lib.AblyRealtime MethodsAbly::Realtime::Client MethodsARTRealtime Methods

connectConnect

connect()Deferrable connect → yields Connectionvoid connect()void Connect()

Explicitly calling connect is unnecessary unless the ClientOptions autoConnectauto_connectAuthConnect is disabled. This method calls connection.connect()connection.connectconnection.Connect() and causes the connection to open, entering the connecting state.

Returns

A Deferrable object is returned from this method.

On successfully connecting to Ably, the registered success callbacks for the Deferrable and any block provided to this method yields a Connection object.

Failure to connect will trigger the errback callbacks of the Deferrable with an ErrorInfo object containing an error response as defined in the Ably REST API documentation.

closeClose

close()Deferrable close → yields Connectionvoid close()void Close()

This calls connection.close()connection.closeconnection.Close() and causes the connection to close, entering the closing state. Once closed, the library will not attempt to re-establish the connection without an explicit call to connect()connectConnect().

Returns

A Deferrable object is returned from this method.

On successfully closing the connection, the registered success callbacks for the Deferrable and any block provided to this method yields a Connection object.

Failure to close the connection will trigger the errback callbacks of the Deferrable with an ErrorInfo object containing an error response as defined in the Ably REST API documentation.

statsStats

stats(Object options, callback(ErrorInfo err, PaginatedResult<Stats> results))Deferrable stats(Hash options) → yields PaginatedResult<Stats>PaginatedResult<Stats> stats(Param[] options)stats(query: ARTStatsQuery?, callback: (ARTPaginatedResult<ARTStats>?, ARTErrorInfo?) → Void) throwsTask<PaginatedResult<Stats>> StatsAsync(StatsRequestParams query)

This call queries the REST /stats API and retrieves your application’s usage statistics. A PaginatedResult is returned, containing an array of Stats for the first page of results. PaginatedResult objects are iterable providing a means to page through historical statistics. See an example set of raw stats returned via the REST API.

See statistics for more information.

Parameters

optionsquery
an optional objectHashARTStatsQueryStatsRequestParamsParam[] array containing the query parameters
callback
is a function of the form: function(err, result)
&block
yields a PaginatedResult<Stats> array
callback
called with a ARTPaginatedResult<ARTStats> object or an error

options parametersARTStatsQuery propertiesStatsRequestParams properties

The following options, as defined in the REST /stats API endpoint, are permitted:

start:startStart
beginning of time earliest DateTimeOffset or Time or time in milliseconds since the epoch for any stats retrieved
Type: LongInt or @TimeDateTimeOffset
end:endEnd
current time latest DateTimeOffset or Time or time in milliseconds since the epoch for any stats retrieved
Type: LongInt or @TimeDateTimeOffset
direction:directionDirection
backwards :forwards or :backwards
Type: StringSymbolDirection enum
limit:limitLimit
100 maximum number of stats to retrieve up to 1,000
Type: Integer
unit:unitUnit
minute :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
Type: StringARTStatsGranularitySymbolStatsIntervalGranularity enum

Callback result

On success, result contains a PaginatedResult encapsulating an array of Stats objects corresponding to the current page of results. PaginatedResult supports pagination using next and first methods.

On failure to retrieve stats, err contains an ErrorInfo object with an error response as defined in the Ably REST API documentation.

Returns

On success, the returned PaginatedResult encapsulates an array of Stats objects corresponding to the current page of results. PaginatedResult supports pagination using next and first methods.

Failure to retrieve the stats will raise an AblyException

Returns

Returns a Task<PaginatedResult> which needs to be awaited.

On success, the returned PaginatedResult encapsulates an array of Stats objects corresponding to the current page of results. PaginatedResult supports pagination using NextAsync and FirstAsync methods.

Failure to retrieve the stats will raise an AblyException

Returns

A Deferrable object is returned from the stats method.

On success, the registered success callbacks for the Deferrable and any block provided to the method yields a PaginatedResult that encapsulates an array of Stats objects corresponding to the current page of results. PaginatedResult supports pagination using next and first methods.

Failure to retrieve the stats will trigger the errback callbacks of the Deferrable with an ErrorInfo object containing an error response as defined in the Ably REST API documentation.

timeTime

time(callback(ErrorInfo err, Number time))Deferrable time → yields Timelong time()Task TimeAsync()time(callback: (NSDate?, NSError?) → Void)

Obtains the time from the Ably service as a Time objecta DateTimeOffset objectmilliseconds since epoch. This may be required on clients that do not have access to a sufficiently well maintained time source and wish to issue token requests with a more accurate timestamp.

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 object with an error response as defined in the Ably REST API documentation.

Returns

On success, milliseconds since the epoch is returned.

Failure to retrieve the Ably server time will raise an AblyException.

Returns

A Task<DateTimeOffset> is returned from this methode.

When awaited on success it will return the server time converted to a DateTimeOffset.

Failure to retrieve the Ably server time will raise an AblyException.

Returns

A Deferrable object is returned from this method.

On success, the registered success callbacks for the Deferrable and any block provided to the method yields a Time object.

Failure to retrieve the Ably server time will trigger the errback callbacks of the Deferrable with an ErrorInfo object containing an error response as defined in the Ably REST API documentation.

ClientOptionsARTClientOptionsio.ably.lib.types.ClientOptionsIO.Ably.ClientOptions

ClientOptions is a plain Javascript object and is used in the Ably.Realtime constructor’s options argument. The following attributes can be defined on the object:

ClientOptions is a Hash object and is used in the Ably::Realtime constructor’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\AblyRealtime constructor’s options argument. The following named keys and values can be added to the associative array:

ARTClientOptions is used in the AblyRealtime constructor’s options argument.

ClientOptions is a plain Javascript object and is used in the Ably.Realtime constructor’s options argument. The following attributes can be defined on the object:

ClientOptions is a Hash object and is used in the Ably::Realtime constructor’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\AblyRest constructor’s options argument. The following named keys and values can be added to the associative array:

ARTClientOptions is used in the AblyRealtime constructor’s options argument.

PropertiesMembersAttributesKeyword arguments

keyKey:key
The full key string, as obtained from the application dashboard. Use this option if you wish to use Basic authentication, or wish to be able to issue tokens without needing to defer to a separate entity to sign token requests. Read more about Basic authentication
Type: String
tokenToken:token
An authenticated token string that is most commonly obtained from the @token@>Token property of a TokenDetails component of a token request response. Use this option if you wish to use Token authentication. Read more about Token authentication
Type: String
tokenDetailsTokenDetailstoken_details:token_details
An authenticated TokenDetails object that is most commonly obtained from of a token request response. Use this option if you wish to use Token authentication. Read more about Token authentication
Type: TokenDetails
tlsTls:tls
true A boolean value, indicating whether or not a TLS (“SSL”) secure connection should be used. An insecure connection cannot be used with Basic authentication ensuring private keys are compromised in transit. Find out more about TLS
Type: Boolean
clientIdClientIdclient_id:client_id
A client ID, used for identifying this client when publishing messages or for presence purposes. The clientIdclient_idClientId can be any non-empty string. This option is primarily intended to be used in situations where the library is instanced with a key; note that a clientIdclient_idClientId may also be implicit in a token used to instance the library; an error will be raised if a clientIdclient_id specified here conflicts with the clientIdclient_idClientId implicit in the token. Find out more about client identities
Type: String
authCallbackAuthCallbackauth_callback:auth_callback
A functionfunction with the form function(tokenParams, callback(err, tokenOrTokenRequest))TokenCallback instancecallable (eg a lambda)proc / lambda which is called when a new token is required. The role of the callback is to either generate a signed TokenRequest which may then be submitted automatically by the library to the Ably REST API requestToken; or to provide a valid token in as a TokenDetails object. See an authentication callback example or our authentication documentation for details of the token request format and associated API calls.
Type: CallableTokenCallbackProcFunc<TokenParams, Task<TokenDetails>>
authUrlAuthUrlauth_url:auth_url
A URL that the library may use to obtain a token string (in plain text format), or a signed TokenRequest or TokenDetails (in JSON format). For example, this can be used by a client to obtain signed token requests from an application server.
Type: StringUri
authMethodAuthMethodauth_method:auth_method
GET:get The HTTP verb to use for the request, either GET:get or POST:post
Type: StringSymbolHttpMethod
authHeadersAuthHeadersauth_headers:auth_headers
A set of key value pair headers to be added to any request made to the authUrlAuthUrl. Useful when an application requires these to be added to validate the request or implement the response.
Type: ObjectDictHashAssociative ArrayParam []Dictionary<string, string>
authParamsAuthParamsauth_params:auth_params
A set of key value pair params to be added to any request made to the authUrlAuthUrl. When the authMethodAuthMethod is GET, query params are added to the URL, whereas when authMethodAuthMethod 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.
Type: ObjectDictHashAssociative ArrayParam []Dictionary<string, string>
useTokenAuthUseTokenAuthuse_token_auth:use_token_auth
false When true, forces Token authentication to be used by the library. Please note that if a client_idclientId is not specified in the ClientOptions or TokenParams, then the token issued will be anonymous.
Type: Boolean
log
Parameters to control the log output of the library. The supplied value must be an object that may contain one or both of the following entries:

  • level: a number controlling the verbosity of the output. 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).

  • handler: a function to handle each line of log output. If handler is not specified, console.log is used.


Note that the log level and log handler have global scope in the library and will thus not act independently between library instances when multiple library instances exist concurrently.
Type: Object
transports
An optional array of transports to use, in descending order of preference. In the browser environment the available transports are: web_socket, xhr, jsonp.The transports available in the Node.js client library are: web_socket, xhr, comet.
Type: String []
logLevel
5 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.
Type: Integer
logHandler
System.out PrintStream 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.
Type: PrintStream

To set the log level and custom logger sink when using the .Net library, configure the static IO.Ably.Logger class or specify the ClientOptions:

LogLevel
Error 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.
Type: Enum
LoggerSink
IO.Ably.DefaultLoggerSink The default ILoggerSink outputs messages to the debug console. This property allows the user to pipe the log messages to their own logging infrastructure.
logLevel
ARTLogLevelWarn An enum controlling the verbosity of the output from ARTLogLevelVerbose to ARTLogLevelNone. A special value of 99 will silence all logging.
Type: ARTLogLevel
logHandler
A ARTLog object can be specified to handle each line of log output. If logHandler is not specified, a default ARTLog instance is used.
Type: ARTLog *
:log_level
:error 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 can be specified.
Type: Symbol, Logger::SEVERITY
:logger
STDOUT Logger A Ruby Logger compatible object to handle each line of log output. If logger is not specified, STDOUT is used.
Type: Ruby @Logger
logLevel
Log::WARNING A number controlling the verbosity of the output from 1 (minimum, errors only) to 4 (most verbose);
Type: Integer
logHandler
console.log A function to handle each line of log output. If handler is not specified, console.log is used. Note that the log level and log handler have global scope in the library and will therefore not act independently between library instances when multiple library instances exist concurrently.
Type: Function
useBinaryProtocolUseBinaryProtocoluse_binary_protocol:use_binary_protocol
true If set to false, will forcibly disable the binary protocol. The binary protocol is used by default unless it isNote: The binary protocol is currently not supported in Swiftin Objective-Cin PHP. Find out more about the benefits of binary encoding
Type: Boolean
queueMessagesQueueMessages:queue_messages
true If false, this disables the default behaviour whereby the library queues messages on a connection in the disconnected or connecting states. The default behaviour allows applications to submit messages immediately upon instancing the library without having to wait for the connection to be established. Applications may use this option to disable queuing if they wish to have application-level control over the queueing under those conditions
Type: Boolean
echoMessagesEchoMessages:echo_messages
true If false, prevents messages originating from this connection being echoed back on the same connection
Type: Boolean
autoConnectAutoConnect:auto_connect
true By default as soon as the client library is instanced it will connect to Ably. You can optionally set this to false and explicitly connect to Ably when require using the connect method
Type: Boolean
recover
This option allows a connection to inherit the state of a previous connection that may have existed under a different instance of the Realtime library. This might typically be used by clients of the browser library to ensure connection state can be preserved when the user refreshes the page. A recovery key string can be explicitly provided, or alternatively if a callback function is provided, the client library will automatically persist the recovery key between page reloads and call the callback when the connection is recoverable. The callback is then responsible for confirming whether the connection should be recovered or not. See connection state recovery for further information
Type: String, Callable
closeOnUnload
true When true, the client library will automatically send a close request to Ably whenever the window beforeunload event fires. By enabling this option, the close request sent to Ably ensures the connection state will not be retained and all channels associated with the channel will be detached. This is commonly used by developers who want presence leave events to fire immediately i.e. if a user navigates to another page or closes their browser, then enabling this option will result in the presence member leaving immediately. Without this option or an explicit call to the close method of the Connection object, Ably expects that the abruptly disconnected connection could later be recovered and therefore does not immediately remove the user from presence. Instead, to avoid “twitchy” presence behaviour an abruptly disconnected client is removed from channels in which they are present after 15 seconds, and the connection state is retained for two minutes
Type: Boolean
recoverRecover:recover
This option allows a connection to inherit the state of a previous connection that may have existed under a different instance of the library by providing that connection’s recoveryKeyrecovery_key. This might typically be used by clients of an app to ensure connection state can be preserved following a reload. See connection state recovery for further information and example code
Type: String
queryTimeQueryTime:query_time
false If true, the library will query the Ably servers for the current time instead of relying on a locally-available time of day
Type: Boolean
defaultTokenParamsDefaultTokenParams:default_token_params
When a TokenParams object is provided, it will override the client library defaults when issuing new tokens or token requests
Type: TokenParams
disconnectedRetryTimeoutDisconnectedRetryTimeout:disconnected_retry_timeout
15,000ms15s When the connection enters the DISCONNECTED state, after this delay in millisecondsin secondsas a NSTimeInterval, if the state is still DISCONNECTED, the client library will attempt to reconnect automatically
Type: IntegerNSTimeInterval
suspendedRetryTimeoutSuspendedRetryTimeout:suspended_retry_timeout
30,000ms30s When the connection enters the SUSPENDED state, after this delay in millisecondsin secondsas a NSTimeInterval, if the state is still SUSPENDED, the client library will attempt to reconnect automatically
Type: IntegerNSTimeInterval

Stats objectARTStatsio.ably.lib.types.StatsAbly::Models::StatsIO.Ably.Stats

A Stats object represents a application statistic 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 as well as your application 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 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.

PropertiesMembersAttributesKeyword arguments

allAll
aggregate count of both inbound and outbound message stats
Type: MessageTypes
apiRequestsapi_requestsApiRequests
breakdown of API requests received via the Ably REST API
Type: RequestCount
channelsChannels
breakdown of channel related stats such as min, mean and peak channels
Type: ResourceCount
connectionsConnections
breakdown of connection related stats such as min, mean and peak channels for TLS and non-TLS connections
Type: ConnectionTypes
inboundInbound
statistics such as count and data for all inbound messages received over REST and Realtime connection, broken down by normal channel messages or presence messages
Type: MessageTraffic
interval_granularityIntervalGranularity
A GRANULARITY constantvalueEnum representing the granularity (interval) of this statistic such as :minute, :hour, :day, :month'minute', 'hour', 'day', 'month'Minute, Hour, Day, Month.
Type: Stats::GRANULARITYStringStatsIntervalGranularity enum
intervalIdinterval_idIntervalId
the interval ID provides both the time from which the interval starts as well as the length of time that this statistic covers i.e. the period of time which the stats are aggregated for. For example, an interval ID value of “2016-03-01:10:02” represents a single minute interval for the UTC time presented in the string. However, an interval ID of “2016-03” represents a month interval for the entire month of March 2016 based on UTC time.
Type: String
interval_timeIntervalTime
A TimeDateTimeDateTimeOffset object representing the start of the interval
Type: TimeDateTimeDateTimeOffset
outboundOutbound
statistics such as count and data for all outbound messages retrieved via REST history requests, received over Realtime connections, or pushed with WebHooks, broken down by normal channel messages or presence messages
Type: MessageTraffic
persistedPersisted
messages persisted and later retrieved via the history API
Type: MessageTypes
tokenRequeststoken_requestsTokenRequests
breakdown of Token requests received via the Ably REST API.
Type: RequestCount

ARTStatsGranularity

ARTStatsGranularity is an enum specifying the granularity of a ARTStats interval.

typedef NS_ENUM(NSUInteger, ARTStatsGranularity) {
    ARTStatsGranularityMinute,
    ARTStatsGranularityHour,
    ARTStatsGranularityDay,
    ARTStatsGranularityMonth
};
enum ARTStatsGranularity : UInt {
    case Minute
    case Hour
    case Day
    case Month
}

StatsIntervalGranularity is an enum specifying the granularity of a Stats interval.

public enum StatsGranularity
{
    Minute,
    Hour,
    Day,
    Month
}

io.ably.lib.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 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

key
The key value
Type: String
value
The value associated with the key
Type: String

API reference
Documentation