Overview

Consumer

The Ably API Streamer makes it easy and cost-effective for organizations and developers to offer realtime APIs, at any scale. It provides a unified solution for publishing, managing and distributing realtime data via open protocol APIs, all built on the global Ably Data Stream Network. From live sports scores to financial market data, mobility IoT data such as GPS locations, and SaaS integration updates, API Streamer can be used to seamlessly distribute and consume realtime data.

You can consume data streams using the API Streamer either by following a direct invitation from a data producer (mostly applicable for commercial and private streams) or by subscribing to an open data stream of a product listed on the Ably Hub, a marketplace for streaming data sources. Once you have a subscription to a product, you can integrate the data into your own apps and projects.

Our API Streamer docs are currently in beta. While we are working hard to improve them, please feel free to reach us out in case of any queries.

Consuming and managing data streams

Ably supports two subscription models to consume streams of data:

  • Pull Subscription Protocols are used by clients that connect to Ably and explicitly subscribe to streams on-demand. Protocols such as MQTT, SSE, or Ably’s native realtime protocol, are all Pull based protocols as clients initiate the connection to Ably and request a subscription to a stream of data from the Ably service.
  • Push Subscription Protocols are outbound streams to third party systems that are initiated when data is published on a channel. Push Subscription protocols are often used where it is not practical to consume data on-demand, typically when the volumes of messages or channels are high, and complexity for the subscriber increases. Ably’s Push Subscription Protocols are offered through the Ably Reactor service, and enable developers to stream data into their streaming or queuing services like Kafka, AMQP (RabbitMQ) or Amazon SQS/Kinesis, or to trigger serverless functions across all popular cloud providers.


API Streamer Consumer options

Subscribing to data streams using Ably’s Realtime Client SDKs

To subscribe to a product, you’ll need to know how channel names work in the API Streamer. A channel name is made up of producer credentials combined with the topic that the data represents. As an example, for the product trains from the company train-company, where they’re publishing data to their channel underground, would make up the channel [product:train-company/trains]underground. In most cases the producer of the data will have channel names directly listed in their documentation.

To start consuming data streams, you can log into the API Streamer’s consumer dashboard. In the Subscriptions tab, you’ll see a list of all the products that you have access to. You can view any product for more information about the producer offering that product, as well as the documentation on how to use that product. One of the key things you need from the documentation is the channel names to which the data streams are being published.

As a consumer, you simply need to subscribe to this channel with either a Pull Subscription Protocol or a Push Subscription Protocol explained previously.

To manage the data from the products you have access to easily, you can set up any number of apps in your apps dashboard. By default, all the Ably accounts come with two pre-loaded apps called ‘Production’ and ‘Sandbox’. If you are just trying out the API Streamer for the first time, we recommend you use the ‘Sandbox’ app to get up and running quickly.

In order to use the Ably client SDKs, your client devices will need to authenticate with Ably first. You can simply use the API key which you can obtain from the app you wish to use, also called Basic Auth mechanism or set up an auth server so your client devices can use the Token Auth mechanism. Tokens are short lived and hence more secure in cases where embedding API Keys on the client-side code isn’t feasible. Learn more about the various authentication mechanisms in Ably.

The following code snippets show examples of subscribing to the streaming data channels using Ably’s Client SDKs using basic authentication for simplicity. Note: You can choose the language of your choice from the navbar on the top of this page to see an example in that language.

var realtime = new Ably.Realtime('YOUR-API-KEY-OR-TOKEN');
var channel = realtime.channels.get('CHANNEL-NAME-FROM-PRODUCT-DOCS');
channel.subscribe(function(message) {
  alert('Received: ' + message.data);
});
var Ably = require('ably');
var realtime = new Ably.Realtime('YOUR-API-KEY-OR-TOKEN');
var channel = realtime.channels.get('CHANNEL-NAME-FROM-PRODUCT-DOCS');
channel.subscribe(function(message) {
  console.log("Received: "  message.data);
});
realtime = Ably::Realtime.new('YOUR-API-KEY-OR-TOKEN')
channel = realtime.channels.get('CHANNEL-NAME-FROM-PRODUCT-DOCS')
channel.subscribe do |message|
  puts "Received: #{message.data}"
end
AblyRealtime realtime = new AblyRealtime("YOUR-API-KEY-OR-TOKEN");
Channel channel = realtime.channels.get("CHANNEL-NAME-FROM-PRODUCT-DOCS");
channel.subscribe(new MessageListener() {
  @Override
  public void onMessage(Message message) {
    System.out.println("New messages arrived. " + message.name);
  }
});
AblyRealtime realtime = new AblyRealtime("YOUR-API-KEY-OR-TOKEN");
IRealtimeChannel channel = realtime.Channels.Get("CHANNEL-NAME-FROM-PRODUCT-DOCS");
channel.Subscribe(message => {
  Console.WriteLine($"Message: {message.Name}:{message.Data} received");
});
ARTRealtime *realtime = [[ARTRealtime alloc] initWithKey:@"YOUR-API-KEY-OR-TOKEN"];
ARTRealtimeChannel *channel = [realtime.channels get:@"CHANNEL-NAME-FROM-PRODUCT-DOCS"];
[channel subscribe:^(ARTMessage *message) {
    NSLog(@"Received: %@", message.data);
}];
[channel publish:@"example" data:@"message data"];
let realtime = ARTRealtime(key: "YOUR-API-KEY-OR-TOKEN")
let channel = realtime.channels.get("CHANNEL-NAME-FROM-PRODUCT-DOCS")
channel.subscribe { message in
    print("Received: \(message.data)")
}

Tutorials

We are working on step-by-step tutorials for you to easily follow along. In the meantime, if you’d like to get any questions answered, we’ll be happy to help.

Next up

You are currently in the consumer page of the API Streamer documentation. You can read more about:


API reference
Documentation