Using the REST library
The Ably REST client libraries offer a simple stateless API to interact directly with Ably’s REST API. The REST library is typically used server-side to issue tokens, publish messages, and retrieve message history. If you are building a client-side application, you may want to consider using our stateful Ably Realtime client libraries.
The Ably REST 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, we recommend you download a library in your preferred language and use this documentation as an API reference.
The REST library for browser JavaScript environments should be loaded from the Ably CDN as follows:
<script lang="text/javascript" src="//cdn.ably.com/lib/ably.min-1.js"></script>
CopyCopied!
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 instantiate the REST library:
var rest = new Ably.Rest({ key: apiKey });
CopyCopied!
When including the client library from our CDN, we recommend you lock into major version 1
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 1
of the library by including https://cdn.ably.com/lib/ably.min-1.js
, you will receive all minor updates and patch fixes automatically (i.e 1.*.*
). If you want to lock into minor version 1.1
and receive all patch fixes automatically (i.e. 1.1.*
), then use https://cdn.ably.com/lib/ably.min-1.1.js
. Additionally, the .min
suffix can be dropped if you want the non-minified version for debugging.
View our client library SDKs feature support matrix to see the list of all the available features.
The supported client options are described in the API reference documentation.
Tutorials
If you would like to see examples of using the Ably REST client library, then we recommend you take a look at our REST tutorials.
API Reference
View the Constructor API Reference.