Ably Pub/Sub Ruby REST SDK
Build using Ably’s Pub/Sub Ruby REST SDK, supported on all popular platforms and frameworks.
Ably Pub/Sub provides flexible APIs that deliver features such as pub-sub messaging, message history, presence, and push notifications. Utilizing Ably’s realtime messaging platform, applications benefit from its highly performant, reliable, and scalable infrastructure.
This REST-only SDK supports applications that do not to include EventMachine
as a dependency. It's suitable for Rails or Sinatra applications, that favor the REST library due to its minimal dependencies and synchronous API.
For applications requiring Realtime functionality with an asynchronous, event-driven API, we recommend using the combined REST & Realtime gem.
Find out more:
Getting started
Everything you need to get started with Ably:
Supported platforms
Ably aims to support a wide range of platforms and browsers. If you experience any compatibility issues, open an issue in the repository or contact Ably support.
Platform | Support |
---|---|
Ruby | >= 2.7 |
Important
SDK versions < 1.2.5 will be deprecated from November 1, 2025.
Installation
The client library is available as a gem from RubyGems.org.
Add this line to your application's Gemfile:
gem 'ably-rest'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ably-rest
Usage
The following code connects to Ably's REST messaging service, publishes a messages to channel, retrieve message history, generate authentication tokens, and sends end-to-end encrypted messages:
# Initialize client and channel
client = Ably::Rest.new(key: 'your-ably-api-key')
channel = client.channel('test-channel')
# Publishing a message to a channel
channel.publish('test-event', 'hello world!') #=> true
# Querying the History
messages_page = channel.history #=> #<Ably::Models::PaginatedResult ...>
messages_page.items.first.data # payload for the message
# Generate a Token (for secure client connections)
token_details = client.auth.request_token
token_details.token # => "your-token"
client = Ably::Rest.new(token: token_details)
# Encrypted messages
secret_key = Ably::Util::Crypto.generate_random_key
channel = client.channels.get('test-channel', cipher: { key: secret_key })
channel.publish nil, "sensitive data" # automatically encrypted
Releases
The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.
Contribute
Read the CONTRIBUTING.md guidelines to contribute to Ably.
Support, feedback and troubleshooting
For help or technical support, visit Ably's support page. You can also view the community reported Github issues or raise one yourself.
Custom transportParams
This client library is currently not compatible with Custom transportParams