The REST client library is most commonly used server-side i.e. on your application servers, and is stateless. Reasons to use the REST library are:

  • Your application server is used to primarily issues tokens for clients and/or publish messages on channels.
  • Your application is mostly stateless i.e. you process a request or respond to an event, and then move onto the next request or event without any previous state carrying through.
  • Your prefer a synchronous request over an asynchronous request. Note not all REST libraries are synchronous, but where the platform offers a synchronous and asynchronous approach, the REST libraries are more often synchronous.

The Realtime library is most commonly used client-side and is stateful, it establishes a connection to Ably for that client and maintains state for the life of the connection. Reasons to use the Realtime library are:

  • You are developing a mobile, desktop or web client that needs to subscribe to messages in real time.
  • You want to maintain a persistent connection to Ably, attach to one or more channels, and publish and subscribe to messages.
  • Your application needs to register its presence on a channel, or listen for others becoming present in real time.

Other libraries and supported protocols to consider

For further information on when to use the REST client library, please see the REST client library usage documentation.