Docs
Coverage MatrixDocumentationChange LogLog InContact Us
Docs

Push Feeds

Intro to Push

Some of our APIs include Push feeds that allow you to get updates as soon as they are available. Push API feeds automatically send JSON payload to you via a push service, and can dramatically reduce the number of calls you need to make to our RESTful API feeds. The structure of the Push feeds are similar to the structure of the corresponding RESTful API feed (i.e. Push Boxscore, Push Events, and Push Statistics). The push service ensures reliable and efficient delivery of the most up to date information.

Our Push services are based on a HTTP publish/subscribe model. When making a call to the Push APIs, you "subscribe" to various data feeds provided by our service; whenever new content is available on one of those feeds, the server pushes that information out to your client. When no new information is available on the feed, a heartbeat message is sent every 5 seconds to keep the connection active. If you want to filter the results of the feeds, there are several optional query string parameters that can be applied to the API call. If left unfiltered, than all data for the feed is displayed (i.e. all games, events, or statistics).

For your applications to accept data from our Push feeds, ensure that your application can:

  • Can follow a HTTP redirect or use the location provided in the feeds header within one minute of your initial request.
  • Can accept HTTP data transfer encoded as chunked.

Our Push service does not provide a "stateful session", there is no memory of what data has been sent previously. If you are disconnected from the Push session, you can use the RESTful API to catch up or recover from the disconnection.

Syntax for using our Push feeds and examples of the JSON payloads can be found on each endpoint page.

Samples

To best utilize Push feeds, we have included code samples in Ruby, Java and Python which provide an example of a way you can consume the feeds. Using these samples will output the feeds content to STDOUT.

For Java, we have also provided a Stream Client to assist your integration.

Note: In the provided Java sample, replace "URL GOES HERE" with the desired Push feed URL.

require 'httpclient'

module Sportradar
    module HTTP
        module Stream
            class Client
                attr_reader :url, :logger

                def initialize(url, publisher, logger)
                    @url = url
                    @logger = logger
                    @publisher = publisher
                    @client = ::HTTPClient.new(:agent_name => 'SportsData/1.0')
                end

                def start
                    @thread ||= Thread.new do
                        logger.debug "Starting loop"
                        @client.get_content(url, :follow_redirect => true) do |chunk|
                            @publisher.publish(::JSON.parse(chunk)) if @publisher
                        end
                        logger.debug "finished loop"
                    end
                end

                def stop
                    @thread.terminate if @thread
                end

            end
        end
    end
end
package com.sportradar.http.stream.client;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class StreamClientTest {

	private StreamClient client;

	private static String SERVICE_URL = "<URL GOES HERE>";

	@Before
	public void setup() {
		client = new StreamClient();
	}

	@After
	public void cleanup() {
		client.terminate();
	}

	@Test
	public void testStream() throws Exception {
		Handler handler = new ConsoleHandler();
		client.stream(SERVICE_URL, handler);
		System.out.println("Connecting....");
		Thread.sleep(1 * 60 * 1000);
		System.out.println("Disconnecting....");
	}

}