BBC News

From: BBC

Pull subscription protocols:

  • Ably Native SDKs
  • Websockets
    Websockets
  • SSE/HTTP Streaming
    SSE/HTTP Streaming
  • HTTP
  • MQTT
    MQTT
  • AMQP
    AMQP
  • STOMP
    STOMP
  • GRPC
    GRPC Coming soon
View pull subscription code example for this product

Push subscription protocols:

  • Google Cloud Functions
    Google Cloud Functions
  • AWS Lambda
    AWS Lambda
  • Azure Functions
    Azure Functions
  • Webhooks
    Webhooks
  • WebSub Coming soon
  • AMQP
    AMQP
  • Kafka
    Kafka Coming soon
  • Kinesis
    Kinesis
  • Amazon SQS
    Amazon SQS
Find out more about push subscriptions supported

Licensing

License category:


Pricing

Messages charges

Messages quota:

Bandwidth quota:

0

0 Bytes

Limits

No. of channels limit: 200


Contact details

Channel scope

[product:ably-bbc/news]

Subscribe code examples

Choose a pull subscription protocol:

  •         var ably = new Ably.Realtime(<API_KEY>);
    var channel = ably.channels.get('[product:ably-bbc/news]' + <CHANNEL_NAME>);
    
    channel.subscribe(function(message) {
      alert(message.data);
    });
          
            var ably = new Ably.Realtime(<API_KEY>);
    var channel = ably.channels.get('[product:ably-bbc/news]' + <CHANNEL_NAME>);
    
    channel.subscribe(function(message) {
      console.log(message.data);
    });
          
            AblyRealtime realtime = new AblyRealtime(<API_KEY>);
    Channel channel = realtime.channels.get("[product:ably-bbc/news]" + <CHANNEL_NAME>);
    channel.subscribe(new MessageListener() {
      @Override
      public void onMessage(Message message) {
        System.out.println(message.data);
      }
    });
          
            let ably = ARTRealtime(key: <API_KEY>)
    let channel = ably.channels.get("[product:ably-bbc/news]" + <CHANNEL_NAME>)
    
    channel.subscribe("greeting") { message in
      print("\(message.data)")
    }
          
            var ably = new AblyRealtime(<API_KEY>);
    var channel = ably.Channels.Get("[product:ably-bbc/news]" + <CHANNEL_NAME>);
    
    channel.Subscribe(message => {
      Console.WriteLine($"{message.Data}");
    });
          
            ARTRest realtime = [[ARTRealtime alloc] initWithKey:<API_KEY>];
    ARTRealtimeChannel *channel = [ably.channels get:@"[product:ably-bbc/news]" + <CHANNEL_NAME>];
    
    [channel subscribe:^(ARTMessage *message) {
      NSLog(@"Received: %@", message.data);
    }];
          

    <API_KEY> is your app's API KEY.

    <CHANNEL_NAME> is the name of a channel which the producer is publishing on.

    Select language

  •         const channelName = '[product:ably-bbc/news]' + <CHANNEL_NAME>;
    const uri = 'wss://realtime.ably.io/event-stream?key=' + <API_KEY> + '&channel=${channelName}';
    const webSocket = new WebSocket(uri);
    webSocket.onmessage = (event) => {
       if (event.data.message) {
          console.log(event.data.message);
       }
    };
    // This protocol is still in private beta. Get in touch if you want early access
          

    <API_KEY> is your app's API KEY.

    <CHANNEL_NAME> is the name of a channel which the producer is publishing on.

    Select language

  •         const EventSource = require('eventsource');
    const channelName = '[product:ably-bbc/news]' + <CHANNEL_NAME>;
    const uri = `https://realtime.ably.io/event-stream?key=<API_KEY>&channel=${channelName}`;
    const evtSource = new EventSource(uri);
    evtSource.addEventListener('message', msg => {
        console.log('Message: ', msg.data);
    });
    // This protocol is still in private beta. Get in touch if you want early access
          

    <API_KEY> is your app's API KEY.

    <CHANNEL_NAME> is the name of a channel which the producer is publishing on.

    Select language

  •         // You can only use CURL to obtain history of a channel.
    channel=$(echo "product:ably-bbc/news]" + <CHANNEL_NAME> | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"');
    curl "https://rest.ably.io/channels/${channel}/messages" -u '<API_KEY>'
          
            // This can be used to get the history of a product
    
    var channel = encodeURI('[product:ably-bbc/news]' + <CHANNEL_NAME>)
    $.ajax({
            url: 'https://rest.ably.io/channels/' + channel + '/messages',
            xhrFields: {
                withCredentials: true
            },
            beforeSend: function (xhr) {
                xhr.setRequestHeader('Authorization', 'Basic ' + btoa(<API_KEY>));
            },
            success: function(data){
                alert(data);
            }
    })
    var channel = encodeURI('[product:ably-bbc/news]' + <CHANNEL_NAME>)
          

    <API_KEY> is your app's API KEY.

    <CHANNEL_NAME> is the name of a channel which the producer is publishing on.

    Select language

  •         // Using https://www.npmjs.com/package/mqtt
    var mqtt = require('mqtt')
    
    var options = { 
      keepAlive: 15,
      username: <API_KEY_ID>,
      password: <API_KEY_SECRET>,
      port: 8883
    };
    
    var client = mqtt.connect('mqtts:mqtt.ably.io', options);
    
    var channel = encodeURI('[product:ably-bbc/news]' + <CHANNEL_NAME>)
    client.on('connect', function () {
      client.subscribe(channel);
    })
    
    client.on('message', function (topic, message) {
      console.log(message.toString())
    })
          
            import paho.mqtt.client as mqtt
    
    def on_connect(client, userdata, message):
      print(message)
    
    client = mqtt.Client()
    client.username_pw_set(<API_KEY_ID>, <API_KEY_SECRET>)
    client.tls_set()
    client.loop_start()
    client.connect('mqtt.ably.io', port=8883, keepalive=15)
    
    client.subscribe('[product:ably-bbc/news]' + <CHANNEL_NAME>)
    client.on_message = on_message
          
            import (
      MQTT "github.com/eclipse/paho.mqtt.golang"
    )
    
    func main() {
      options := MQTT.NewClientOptions();
      options.AddBroker("ssl://mqtt.ably.io:8883")
      options.SetKeepAlive(15)
      options.SetUsername("API_KEY_ID")
      options.SetPassword("API_KEY_SECRET")
      client := MQTT.NewClient(options)
      client.Connect();
      client.Subscribe('[product:ably-bbc/news]' + <CHANNEL_NAME>, 0, func(client mqtt.Client, msg mqtt.Message) {
        // Deal with message
      });
    }
          

    <API_KEY_ID> should be your API KEY id.

    <API_KEY_SECRET> should be your secret part of your API.

    <CHANNEL_NAME> is the name of a channel which the producer is publishing on.

    Select language

  •         const amqp = require('amqplib/callback_api');
    const queue = <APP_ID> + ':' + <QUEUE_NAME>;
    const url = 'amqps://' + <API_KEY> + '@' + <QUEUE_ENDPOINT>;
    
    amqp.connect(url, (err, conn) => {
      conn.createChannel((err, ch) => {
        ch.consume(queue, (item) => {
          // Deal with messages
        });
      });
    });
          
            using RabbitMQ.Client;
    
    string url = "amqps://" + <API_KEY> + "@" + <QUEUE_ENDPOINT>;
    string ablyQueue = <APP_ID> + ":" + <QUEUE_NAME>;
    
    var factory = new ConnectionFactory() { HostName = url };
    using (var connection = factory.CreateConnection()) {
        using (var channel = connection.CreateModel()) {
          channel.QueueDeclare(queue: ablyQueue);
    
          var consumer = new EventingBasicConsumer(channel);
          consumer.Received += (model, ea) => {
            // Deal with your messages
          };
        }
    }
          
            private final static String QUEUE_NAME = <APP_ID> + ":" + <QUEUE_NAME>;
    private final static String URL = "amqps://" + <API_KEY> + "@" + <QUEUE_ENDPOINT>;
    
    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost(URL);
    Connection connection = factory.newConnection();
    Channel channel = connection.createChannel();
    channel.queueDeclare(QUEUE_NAME, false, false, false, null);
    
    // deliverCallback to be used to deal with messages
    channel.basicConsume(QUEUE_NAME, true, deliverCallback, consumerTag -> { });
          

    <API_KEY> is your app's API KEY.

    <CHANNEL_NAME> is the name of a channel which the producer is publishing on.

    <QUEUE_*> are elements of your Ably queue.

    <APP_ID> is the first part of your API key.

    Select language

  •         const Stompit = require('stompit');
    
    const connectOptions = {
      'host': <QUEUE_ENDPOINT>,
      'port': <QUEUE_PORT>,
      'ssl': true,
      'connectHeaders':{
        'host': <QUEUE_VHOST>,
        'login': <API_KEY_ID>,
        'passcode': <API_KEY_SECRET>
      }
    };
    
    const subscribeHeaders = {
      'destination': '/amq/queue/' + <QUEUE_NAME>
      'ack': 'client-individual'
    };
    
    Stompit.connect(connectOptions, function(error, client) {
      client.subscribe(subscribeHeaders, function(error, message) {
        message.readString('utf-8', function(error, body) {
          // Do what you want with the body
        });
      });
    });
          

    <API_KEY_ID> should be your API KEY id.

    <API_KEY_SECRET> should be your secret part of your API.

    <CHANNEL_NAME> is the name of a channel which the producer is publishing on.

    <QUEUE_*> are elements of your Ably queue.

    Serverless and push subscription protocols supported:

    • Google Cloud Functions
      Google Cloud Functions
    • AWS Lambda
      AWS Lambda
    • Azure Functions
      Azure Functions
    • Webhooks
      Webhooks
    • WebSub Coming soon
    • AMQP
      AMQP
    • Kafka
      Kafka Coming soon
    • Kinesis
      Kinesis
    • Amazon SQS
      Amazon SQS
    Find out more about push subscriptions supported

    Ably carries out periodic reviews of products in the Ably Hub. However, we don't individually review each new product or update. As such, we cannot endorse or certify any of these products. Report violations or inappropriate products.

    API Streamer ID:

    ably-bbc/news

    Image preview Image preview

    Ably Hub

    This stream is bought to you via the Ably Hub - the place to go for data streams for your apps & services.