NBA G League Push Feeds
Intro to Push
Push API feeds automatically send JSON payloads via a push service, and can dramatically reduce the number of calls you need to make to our RESTful API feeds. The structure of a Push feed is similar to the structure of a corresponding RESTful API feed.
Our Push services are based on a HTTP publish/subscribe model. When making a call to the Push feeds, you "subscribe" to various data feeds provided by our service. Whenever new content is available on a feed, the server pushes it 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 a request. If left unfiltered, than all data for the feed is displayed (i.e. all games, events, or statistics).
Technical Requirements
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.
Access
Push feeds are an add-on service, and unavailable in the self-issued trial within your account. Reach out to a sales representative for trial access.
Syntax for using our Push feeds and examples of the JSON payloads can be found on each endpoint page.
Simulations
Don't have a Push trial? Access past games - including Push - with our API Simulations!
Disconnections
Our Push service does not provide a "stateful session", there is no memory of what data has been sent previously.
Should you cease to receive heartbeat messages, or are disconnected from the Push service for any reason, re-connect using your same initial request.
Samples
Each Push feed page includes code samples in Ruby, Java and Python which provide an example of feed consumption. Using these samples will output the feed 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....");
}
}
Note: In the provided Java sample, replace "URL GOES HERE" with the desired Push feed URL.