Overview

Producer

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. API Streamer, amongst other things, is being used to share live sports scores and financial market data, mobility IoT data such as GPS locations, and SaaS integration updates in real time.

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.

Using the API Streamer to publish data streams

You can share your realtime data streams with consumers in three distinct steps: 1) Deploy, 2) Manage and 3) Distribute.


Steps involved in publishing data streams

Deploy

Event-driven and realtime data, by its very nature, needs to flow from the producer to the consumer with the lowest possible latency. Given producers in most cases are decoupled from consumers of data, and not all data that is published is needed by all subscribers, the publish/subscribe pattern is most commonly used in systems designed to deliver realtime data as streams of events or messages.

In the first step of publishing data streams, you’ll need to set up an app on the Ably app dashboard or use one of the existing apps. 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.

Ably fundamentally organizes all the data into units called channels. In order to deploy your data into your Ably apps, you’ll need to publish it to one or more channels.

You can do this by either by using our Realtime Client SDKs, our REST Client SDKs, our MQTT adapter, or directly using our raw REST API (although this last option isn’t recommended as it is inferior to our SDKs in terms of performance and resilience).

In most cases, if you are only publishing your data streams and not expecting a two-way communication between you and the consumer of the data, the most efficient way is to use the REST Client SDKs.

You authenticate yourself using the API Key in your app, and start publishing your data into one or more channels. Additionally, if your publisher is not secure enough to embed API Keys directly, you can set up a separate authentication server and issue tokens to your publisher who can then use them to authenticate with Ably before being able to publish.

Deploying data streams using Ably’s REST Client SDKs

Using Ably’s REST Client SDKs to deploy your data streams to one of your apps is very easy. 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.

The following example shows a mock data stream by repeating the publish action at regular intervals.

var rest = new Ably.Rest('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V');
var channel = rest.channels.get('vet-car-cow');
setInterval(function(){ 
    channel.publish('example', 'message data'); 
}, 3000);
var rest = new Ably.Rest('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V');
var channel = rest.channels.get('vet-car-cow');
setInterval(function(){ 
    channel.publish('example', 'message data'); 
}, 3000);
rest = Ably::Rest.new('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V')
channel = rest.channels.get('vet-car-cow')
while true
  channel.publish 'example', 'message data'
  sleep 3
end
rest = AblyRest('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V')
channel = rest.channels.get('vet-car-cow')
def setInterval(func,time):
  e = threading.Event()
  while not e.wait(time):
      func()

def publish():
  channel.publish(u'example', u'message data')"

setInterval(publish,3)
$rest = new Ably\AblyRest('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V');
$channel = $rest->channels->get('vet-car-cow');
function setInterval($f, $milliseconds){
  $seconds=(int)$milliseconds/1000;
  while(true){
      $f();
      sleep($seconds);
  }
}
setInterval(function() use($channel) {
 $channel->publish('example', 'message data');
}, 3000);
AblyRest rest = new AblyRest("xVLyHw.lUFJow:f4ROUG6hvgaLwE-V");
Channel channel = rest.channels.get("vet-car-cow");
new Timer().scheduleAtFixedRate(new TimerTask(){
  @Override
  public void run(){
     channel.publish("example", "message data");
  }
},0,3000);
AblyRest rest = new AblyRest("xVLyHw.lUFJow:f4ROUG6hvgaLwE-V");
var channel = rest.Channels.Get("vet-car-cow");
SetInterval(() => channel.PublishAsync("example", "message data"), TimeSpan.FromSeconds(3));
ARTRest *rest = [[ARTRest alloc] initWithKey:@"xVLyHw.lUFJow:f4ROUG6hvgaLwE-V"];
ARTRestChannel *channel = [rest.channels get:@"vet-car-cow"];
while True:
  [channel publish:@"example" data:@"message data"];
  time.sleep(3)
let rest = ARTRest(key: "xVLyHw.lUFJow:f4ROUG6hvgaLwE-V")
let channel = rest.channels.get("vet-car-cow")
var publishTimer = Timer.scheduledTimer(timeInterval: 3.0, target: self, selector: #selector(ViewController.publishData), userInfo: nil, repeats: true)
@objc func publishData(){
  channel.publish("example", data: "message data")
}
rest, err := ably.NewRestClient(ably.NewClientOptions("xVLyHw.lUFJow:f4ROUG6hvgaLwE-V"))
channel := rest.Channels.Get("vet-car-cow", nil)
interval := setInterval(func() {
          err = channel.Publish("example", "message data")
}, 3000, false)


h4(#deploy-using-realtime-sdks). Deploying data streams using Ably's Realtime Client SDKs

Using Ably’s Realtime Client SDKs to deploy your data streams to one of your apps is very easy. 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.

The following example shows a mock data stream by repeating the publish action at regular intervals.

var realtime = new Ably.Realtime('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V');
var channel = realtime.channels.get('vet-car-cow');
setInterval(function(){ 
    channel.publish('example', 'message data'); 
}, 3000);
var realtime = new Ably.Realtime('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V');
var channel = realtime.channels.get('vet-car-cow');
setInterval(function(){ 
    channel.publish('example', 'message data'); 
}, 3000);
realtime = Ably::Realtime.new('xVLyHw.lUFJow:f4ROUG6hvgaLwE-V')
channel = realtime.channels.get('vet-car-cow')
while true
  channel.publish 'example', 'message data'
  sleep 3
end
AblyRealtime realtime = new AblyRealtime("xVLyHw.lUFJow:f4ROUG6hvgaLwE-V");
Channel channel = realtime.channels.get("vet-car-cow");
new Timer().scheduleAtFixedRate(new TimerTask(){
  @Override
  public void run(){
     channel.publish("example", "message data");
  }
},0,3000);
AblyRealtime realtime = new AblyRealtime("xVLyHw.lUFJow:f4ROUG6hvgaLwE-V");
IRealtimeChannel channel = realtime.Channels.Get("vet-car-cow");
SetInterval(() => channel.PublishAsync("example", "message data"), TimeSpan.FromSeconds(3));
ARTRealtime *realtime = [[ARTRealtime alloc] initWithKey:@"xVLyHw.lUFJow:f4ROUG6hvgaLwE-V"];
ARTRealtimeChannel *channel = [realtime.channels get:@"vet-car-cow"];
while True:
    [channel publish:@"example" data:@"message data"];
    time.sleep(3)
let realtime = ARTRealtime(key: "xVLyHw.lUFJow:f4ROUG6hvgaLwE-V")
let channel = realtime.channels.get("vet-car-cow")
var publishTimer = Timer.scheduledTimer(timeInterval: 3.0, target: self, selector: #selector(ViewController.publishData), userInfo: nil, repeats: true)
@objc func publishData(){
 channel.publish("example", data: "message data")
}

Manage

After you’ve successfully set up your app and know how to deploy your data streams into them, you can set up products to manage those data streams. Products allow you to distribute different subsets of data streams within your apps to different consumers.

In your API Streamer producer dashboard’s products tab, you can create new Products. While doing so, you can select the app into which you have deployed the data streams you intend to share using that Product. You can then specify a channel namespace, which is essentially a name given to the logical subset of the data in your app that you wish you share. For example, if you are publishing transport data to one of your apps called Public Transport Data, you could be publishing the data related to buses into the namespace called bus and the data related to trains into another namespace called train. You can then create two separate products, one for each of these namespaces to be distributed to the same or different sets of consumers.

The concept of channels explained earlier brings further categorization to each of these namespaces. For instance, the bus data for London and Manchester could go in two channels bus:london and bus:manchester. A product created using the namespace bus will give its consumers access to all the channels that are part of that namespace, in this case london and manchester.


Managing data streams using products

Distribute

After you’ve set up products to manage the data within your apps, it’s time to distribute them to the consumers of data. You can do this by setting up subscriptions in your API Streamer producer dashboard.

Creating new subscriptions is an easy way to give access to one or more of your products to the intended consumers of your data. When setting up subscriptions, you can also specify how your consumers will be charged for the data they consume. You have the options for bearing all the charges yourself, letting Ably bill the consumers directly for what they consume or even set up a custom option where you incur their charges up to a certain limit and Ably will charge them directly for any messages consumed over that limit.


Distributing your products to consumers

After you’ve set up new subscriptions, your intended consumers will automatically receive an invitation via email to use the data streams they’ve been given access to, with the pricing agreements you’ve specified in the subscription.

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 producer page of the API Streamer documentation. You can read more about:


API reference
Documentation