Push Feeds
Streamline your access to live game updates by utilizing our NHL Push feeds.
Intro
With our RESTful endpoints, you'll make API requests when you want to receive new data. But our Push feeds allow you to open a connection with a single call to receive continuous live updates. Once this connection opens, it will remain open indefinitely.
Thus, Push feeds are an efficient option to retrieve live NHL game data. You need not worry about API pull frequency, but need only to "listen" for game updates.
RESTful & Push
Each Push update comes in the form of a JSON payload, which will mimic the structure of a similar RESTful NHL API endpoint. Below are the Push endpoints alongside their RESTful counterparts.
Push Feed | RESTful Counterpart |
---|---|
Push Clock | n/a |
Push Events | Game Play-by-Play |
Push Statistics | Game Summary |
It's important to note that our Push service is not meant to replace our RESTful API, but to complement it. Push does not provide a "stateful session". There is no memory or method to access data sent previously. If you are disconnected from a Push session, use the corresponding RESTful API feed to catch up or recover from the disconnection. For example, if you experience a disconnection from a game while using Push Events, request the RESTful Game Play-by-Play to capture the plays missed during the disconnection.
Additionally, it is important to note that Push feeds correlate to RESTful endpoints, but are not a strict 1:1 mapping for all NHL data. For a complete NHL experience, you will need to make use of RESTful endpoints.
Access
NHL Push feeds are an add-on service, and unavailable in the self-issued NHL trial within your account. Reach out to a sales representative for trial access.
NHL Push feeds are available for Sportradar Realtime customers only
Make a Request
Each Push feed starts with a URL request, as with our other RESTful API endpoints.
curl -L -X GET 'https://api.sportradar.com/nhl/{access_level}/stream/{language_code}/{push_feed}/subscribe' \
-H 'x-api-key: {your_api_key}'
When constructed, the above call opens up an HTTP redirect connection, returning all Push data for the requested feed. To filter results to a smaller data set include an optional query string.
There are no restrictions on the number of connections you may have open. Feel free to filter requests to individual games and close the connections when games complete, or keep a single unfiltered connection open indefinitely.
Visit the feed endpoints pages for complete syntax instructions.
Filtering
By default, a Push feed will provide all data available. For example, a Push Events connection would stream all NHL games in progress to your application. If needed, you can filter the data returned by including query strings.
For example, let's say you want to restrict your connection to one NHL game in progress. Construct your call as normal and add the unique game id
to the query string.
Here's an example:
curl -L -X GET 'https://api.sportradar.com/nhl/trial/stream/en/events/subscribe?&match=sd:match:673b459c-7506-4c11-9273-1b9502537f1d' \
-H 'x-api-key: {your_api_key}'
Visit the feed endpoints pages for complete query string syntax instructions.
Technical Requirements
To accept data from our Push feeds, ensure that your application can:
- Follow an HTTP redirect, or use the location provided in the feeds header within one minute of your initial request.
- Accept HTTP data transfer encoded as chunked.
Payloads
Our Push services are delivered by HTTP Streaming with chunked encoding, also commonly called HTTP Chunked. The streaming of data is based on long HTTP response. Chunked streaming allows you to act on the chunks immediately instead of waiting or requesting a full file.
When new feed content is available, the server pushes that information out to your client. When no new information is available on a feed, a heartbeat message is sent every 5 seconds to keep the connection active.
Messages are delivered in JSON format only.
{
"heartbeat":{
"interval":5000
}
}{
"heartbeat":{
"interval":5000
}
}{
"heartbeat":{
"interval":5000
}
}{
"payload":{
"game":{
"id":"8fc62fdb-962c-4999-9885-ac63c95d8080",
"status":"inprogress",
"coverage":"full",
"reference":"20130",
"scheduled":"2023-10-30T23:00:00+00:00",
"period":2,
"sr_id":"sr:match:41971165",
"home":{
"name":"Bruins",
"market":"Boston",
"reference":"6",
"id":"4416ba1a-0f24-11e2-8525-18a905767e44",
"points":1,
"sr_id":"sr:team:3677"
},
"away":{
"name":"Panthers",
"market":"Florida",
"reference":"13",
"id":"4418464d-0f24-11e2-8525-18a905767e44",
"points":2,
"sr_id":"sr:team:3687"
}
},
"event":{
"id":"a00c23af-64ac-4c33-af88-9a68552b1859",
"event_type":"stoppage",
"stoppage_type":"Icing",
"sequence":1698712501153,
"clock":"5:29",
"clock_decimal":"5:29",
"official":true,
"wall_clock":"2023-10-31T00:35:01Z",
"updated":"2023-10-31T00:35:32Z",
"description":"Stoppage - Icing",
"period":{
"id":"5806749e-75ce-496e-9264-f819f8c99d1f",
"number":2,
"sequence":2,
"type":"Period"
},
"details":{
"stoppage_type":"Icing"
},
"on_ice":[
{
"team":{
"name":"Panthers",
"market":"Florida",
"reference":"13",
"id":"4418464d-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:team:3687",
"players":[
{
"full_name":"Anton Lundell",
"jersey_number":"15",
"reference":"8482113",
"position":"F",
"primary_position":"C",
"id":"53a04226-4657-4064-8764-9cd526f966a7",
"sr_id":"sr:player:1571752"
},
{
"full_name":"Ryan Lomberg",
"jersey_number":"94",
"reference":"8479066",
"position":"F",
"primary_position":"LW",
"id":"08c092f7-e369-437b-9aa4-2366f5266dfe",
"sr_id":"sr:player:1052865"
},
{
"full_name":"Gustav Forsling",
"jersey_number":"42",
"reference":"8478055",
"position":"D",
"primary_position":"D",
"id":"a24e0f46-9cad-49dd-b07f-7835e0848d99",
"sr_id":"sr:player:600624"
},
{
"full_name":"Niko Mikkola",
"jersey_number":"77",
"reference":"8478859",
"position":"D",
"primary_position":"D",
"id":"65071e7e-2846-4203-8be0-b5ef38b20a5f",
"sr_id":"sr:player:599818"
},
{
"full_name":"Oliver Ekman-Larsson",
"jersey_number":"91",
"reference":"8475171",
"position":"D",
"primary_position":"D",
"id":"4289ec26-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:player:47945"
},
{
"full_name":"Sergei Bobrovsky",
"jersey_number":"72",
"reference":"8475683",
"position":"G",
"primary_position":"G",
"id":"433d0416-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:player:88027"
}
]
}
},
{
"team":{
"name":"Bruins",
"market":"Boston",
"reference":"6",
"id":"4416ba1a-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:team:3677",
"players":[
{
"full_name":"Charlie McAvoy",
"jersey_number":"73",
"reference":"8479325",
"position":"D",
"primary_position":"D",
"id":"72d92fa8-71ce-4437-adb5-e861e5f6f55f",
"sr_id":"sr:player:983633"
},
{
"full_name":"Hampus Lindholm",
"jersey_number":"27",
"reference":"8476854",
"position":"D",
"primary_position":"D",
"id":"671bbc9e-99ea-4c1f-b871-f8efd53b0d8f",
"sr_id":"sr:player:215040"
},
{
"full_name":"David Pastrnak",
"jersey_number":"88",
"reference":"8477956",
"position":"F",
"primary_position":"RW",
"id":"69cc1757-78c5-4461-bde3-2b252854ecb8",
"sr_id":"sr:player:307642"
},
{
"full_name":"Brad Marchand",
"jersey_number":"63",
"reference":"8473419",
"position":"F",
"primary_position":"LW",
"id":"42eba095-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:player:97117"
},
{
"full_name":"Linus Ullmark",
"jersey_number":"35",
"reference":"8476999",
"position":"G",
"primary_position":"G",
"id":"d4dd5956-5c99-4e69-b21f-713b64327eca",
"sr_id":"sr:player:350972"
},
{
"full_name":"Matthew Poitras",
"jersey_number":"51",
"reference":"8483505",
"position":"F",
"primary_position":"C",
"id":"26e4b065-15ed-459f-b532-631d34f678a0",
"sr_id":"sr:player:2322775"
}
]
}
}
]
}
},
"locale":"en",
"metadata":{
"league":"NHL",
"match":"sd:match:8fc62fdb-962c-4999-9885-ac63c95d8080,sr:match:41971165",
"status":"inprogress",
"on_ice":"sd:player:53a04226-4657-4064-8764-9cd526f966a7,sd:player:08c092f7-e369-437b-9aa4-2366f5266dfe,sd:player:a24e0f46-9cad-49dd-b07f-7835e0848d99,sd:player:65071e7e-2846-4203-8be0-b5ef38b20a5f,sd:player:4289ec26-0f24-11e2-8525-18a905767e44,sd:player:433d0416-0f24-11e2-8525-18a905767e44,sd:player:72d92fa8-71ce-4437-adb5-e861e5f6f55f,sd:player:671bbc9e-99ea-4c1f-b871-f8efd53b0d8f,sd:player:69cc1757-78c5-4461-bde3-2b252854ecb8,sd:player:42eba095-0f24-11e2-8525-18a905767e44,sd:player:d4dd5956-5c99-4e69-b21f-713b64327eca,sd:player:26e4b065-15ed-459f-b532-631d34f678a0",
"event_type":"stoppage",
"event_category":"stoppage",
"locale":"en",
"operation":"update",
"version":"v5"
}
Disconnections
Should you cease to receive heartbeat messages, or are disconnected from the Push service for any reason, re-connect using your same initial request.
Metadata
Each payload includes a metadata header message. The metadata includes information on the type of payload and possible filtering options, saving processing and integration time.
"locale":"en",
"metadata":{
"league":"NHL",
"match":"sd:match:4c2c22af-6755-42c8-adb5-0058da782d02,sr:match:41971169",
"status":"inprogress",
"team":"sd:team:441862de-0f24-11e2-8525-18a905767e44,sr:team:3675",
"on_ice":"sd:player:1bbe4c78-3f85-425a-b5e9-790d005630d6,sd:player:baeee6b2-c75d-4f6d-b52b-8c977f173179,sd:player:9d24fa2d-3487-4e50-b3fc-dd8ac710705e,sd:player:e448f557-fb48-4816-ab7a-dd32b92f7d5c,sd:player:0a626220-8869-4919-b16b-8e61bc8f6aaa,sd:player:485f3be0-81fb-49ef-87b8-ab26651004b7,sd:player:436ece1c-0f24-11e2-8525-18a905767e44,sd:player:063abdbc-25dd-442c-a26e-af44ba79506d,sd:player:453cb83d-bdd1-4862-aa4e-e9f32f458f82,sd:player:4342422b-0f24-11e2-8525-18a905767e44,sd:player:42789ae7-0f24-11e2-8525-18a905767e44,sd:player:433e7a98-0f24-11e2-8525-18a905767e44",
"zone":"offensive",
"strength":"powerplay",
"event_type":"shotmissed",
"event_category":"shot",
"locale":"en",
"operation":"update",
"version":"v5"
}
"locale":"en",
"metadata":{
"league":"NHL",
"match":"sd:match:065f948d-471b-47b4-a971-001dc9004371,sr:match:41971171",
"status":"inprogress",
"player":"sd:player:34cac817-7b7e-4f0f-bcd7-5750bec543f3,sr:player:902254",
"stats_type":"player",
"locale":"en",
"operation":"update",
"version":"v5"
}
Comma delimited values in the header are interpreted as an array of values.
"player":"sd:player:34cac817-7b7e-4f0f-bcd7-5750bec543f3,sr:player:902254"
"match":"sd:match:065f948d-471b-47b4-a971-001dc9004371,sr:match:41971171",
Visit the Endpoints documentation for each feed to view all available data points.
Samples
Code Samples
To best utilize Push feeds, see the below code samples in Ruby and Java. These provide an example of a method to 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, api_key, logger)
@url = url
@logger = logger
@api_key = api_key
@client = ::HTTPClient.new(agent_name: 'SportsData/1.0')
end
def start
@thread ||= Thread.new do
logger.debug "Starting loop"
headers = {
'x-api-key' => @api_key
}
@client.get_content(url, header: headers, 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 java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class StreamClient {
private Thread streamThread;
private volatile boolean running = false;
private String apiKey;
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public void stream(String serviceUrl, Handler handler) {
running = true;
streamThread = new Thread(() -> {
try {
URL url = new URL(serviceUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("User-Agent", "SportsData/1.0");
if (apiKey != null && !apiKey.isEmpty()) {
connection.setRequestProperty("x-api-key", apiKey);
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while (running && (line = reader.readLine()) != null) {
if (!line.trim().isEmpty()) {
handler.handle(line);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
});
streamThread.start();
}
public void terminate() {
running = false;
if (streamThread != null) {
streamThread.interrupt();
}
}
}
Data Samples
Samples can be found on each individual Endpoints page.
Simulations
You can use our API Simulations to open up a continuous Push simulation of a game. This allows you to experience and analyze our data without having to wait for a real game to take place.
ID Updates
All updates to the Push feeds are categorized as an update
or a delete
. These will be found within metadata.operation
.
Updates may be the creation of an event or an update of information to a previous event.
When you receive an event with the same ID as an event that has been previously consumed, it is best practice to replace the data from the previous message with the data consumed in the most recent message. For example, a player being updated on a play like faceoff or removed from a play or goal overturned after the initial goal scored is sent.
{
"payload":{
"game":{
"id":"8fc62fdb-962c-4999-9885-ac63c95d8080",
"status":"inprogress",
"coverage":"full",
"reference":"20130",
"scheduled":"2023-10-30T23:00:00+00:00",
"period":2,
"sr_id":"sr:match:41971165",
"home":{
"name":"Bruins",
"market":"Boston",
"reference":"6",
"id":"4416ba1a-0f24-11e2-8525-18a905767e44",
"points":1,
"sr_id":"sr:team:3677"
},
"away":{
"name":"Panthers",
"market":"Florida",
"reference":"13",
"id":"4418464d-0f24-11e2-8525-18a905767e44",
"points":2,
"sr_id":"sr:team:3687"
}
},
"event":{
"id":"a00c23af-64ac-4c33-af88-9a68552b1859",
"event_type":"stoppage",
"stoppage_type":"Icing",
"sequence":1698712501153,
"clock":"5:29",
"clock_decimal":"5:29",
"official":true,
"wall_clock":"2023-10-31T00:35:01Z",
"updated":"2023-10-31T00:35:32Z",
"description":"Stoppage - Icing",
"period":{
"id":"5806749e-75ce-496e-9264-f819f8c99d1f",
"number":2,
"sequence":2,
"type":"Period"
},
"details":{
"stoppage_type":"Icing"
},
"on_ice":[
{
"team":{
"name":"Panthers",
"market":"Florida",
"reference":"13",
"id":"4418464d-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:team:3687",
"players":[
{
"full_name":"Anton Lundell",
"jersey_number":"15",
"reference":"8482113",
"position":"F",
"primary_position":"C",
"id":"53a04226-4657-4064-8764-9cd526f966a7",
"sr_id":"sr:player:1571752"
},
{
"full_name":"Ryan Lomberg",
"jersey_number":"94",
"reference":"8479066",
"position":"F",
"primary_position":"LW",
"id":"08c092f7-e369-437b-9aa4-2366f5266dfe",
"sr_id":"sr:player:1052865"
},
{
"full_name":"Gustav Forsling",
"jersey_number":"42",
"reference":"8478055",
"position":"D",
"primary_position":"D",
"id":"a24e0f46-9cad-49dd-b07f-7835e0848d99",
"sr_id":"sr:player:600624"
},
{
"full_name":"Niko Mikkola",
"jersey_number":"77",
"reference":"8478859",
"position":"D",
"primary_position":"D",
"id":"65071e7e-2846-4203-8be0-b5ef38b20a5f",
"sr_id":"sr:player:599818"
},
{
"full_name":"Oliver Ekman-Larsson",
"jersey_number":"91",
"reference":"8475171",
"position":"D",
"primary_position":"D",
"id":"4289ec26-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:player:47945"
},
{
"full_name":"Sergei Bobrovsky",
"jersey_number":"72",
"reference":"8475683",
"position":"G",
"primary_position":"G",
"id":"433d0416-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:player:88027"
}
]
}
},
{
"team":{
"name":"Bruins",
"market":"Boston",
"reference":"6",
"id":"4416ba1a-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:team:3677",
"players":[
{
"full_name":"Charlie McAvoy",
"jersey_number":"73",
"reference":"8479325",
"position":"D",
"primary_position":"D",
"id":"72d92fa8-71ce-4437-adb5-e861e5f6f55f",
"sr_id":"sr:player:983633"
},
{
"full_name":"Hampus Lindholm",
"jersey_number":"27",
"reference":"8476854",
"position":"D",
"primary_position":"D",
"id":"671bbc9e-99ea-4c1f-b871-f8efd53b0d8f",
"sr_id":"sr:player:215040"
},
{
"full_name":"David Pastrnak",
"jersey_number":"88",
"reference":"8477956",
"position":"F",
"primary_position":"RW",
"id":"69cc1757-78c5-4461-bde3-2b252854ecb8",
"sr_id":"sr:player:307642"
},
{
"full_name":"Brad Marchand",
"jersey_number":"63",
"reference":"8473419",
"position":"F",
"primary_position":"LW",
"id":"42eba095-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:player:97117"
},
{
"full_name":"Linus Ullmark",
"jersey_number":"35",
"reference":"8476999",
"position":"G",
"primary_position":"G",
"id":"d4dd5956-5c99-4e69-b21f-713b64327eca",
"sr_id":"sr:player:350972"
},
{
"full_name":"Matthew Poitras",
"jersey_number":"51",
"reference":"8483505",
"position":"F",
"primary_position":"C",
"id":"26e4b065-15ed-459f-b532-631d34f678a0",
"sr_id":"sr:player:2322775"
}
]
}
}
]
}
},
"locale":"en",
"metadata":{
"league":"NHL",
"match":"sd:match:8fc62fdb-962c-4999-9885-ac63c95d8080,sr:match:41971165",
"status":"inprogress",
"on_ice":"sd:player:53a04226-4657-4064-8764-9cd526f966a7,sd:player:08c092f7-e369-437b-9aa4-2366f5266dfe,sd:player:a24e0f46-9cad-49dd-b07f-7835e0848d99,sd:player:65071e7e-2846-4203-8be0-b5ef38b20a5f,sd:player:4289ec26-0f24-11e2-8525-18a905767e44,sd:player:433d0416-0f24-11e2-8525-18a905767e44,sd:player:72d92fa8-71ce-4437-adb5-e861e5f6f55f,sd:player:671bbc9e-99ea-4c1f-b871-f8efd53b0d8f,sd:player:69cc1757-78c5-4461-bde3-2b252854ecb8,sd:player:42eba095-0f24-11e2-8525-18a905767e44,sd:player:d4dd5956-5c99-4e69-b21f-713b64327eca,sd:player:26e4b065-15ed-459f-b532-631d34f678a0",
"event_type":"stoppage",
"event_category":"stoppage",
"locale":"en",
"operation":"update",
"version":"v5"
}
}{
"payload":{
"game":{
"id":"4c2c22af-6755-42c8-adb5-0058da782d02",
"status":"inprogress",
"coverage":"full",
"reference":"20132",
"scheduled":"2023-10-30T23:00:00+00:00",
"period":2,
"sr_id":"sr:match:41971169",
"home":{
"name":"Penguins",
"market":"Pittsburgh",
"reference":"5",
"id":"4417b7d7-0f24-11e2-8525-18a905767e44",
"points":1,
"sr_id":"sr:team:3697"
},
"away":{
"name":"Ducks",
"market":"Anaheim",
"reference":"24",
"id":"441862de-0f24-11e2-8525-18a905767e44",
"points":2,
"sr_id":"sr:team:3675"
}
},
"event":{
"id":"1d569b3b-60dd-4846-a3b7-eef8312bb903",
"event_type":"substitution",
"sequence":1698712500543,
"clock":"2:21",
"clock_decimal":"2:21",
"official":true,
"wall_clock":"2023-10-31T00:35:00Z",
"updated":"2023-10-31T00:35:33Z",
"description":"Ducks substitution (Radko Gudas,Troy Terry,Sam Carrick,Ross Johnston,Ilya Lyubushkin)",
"attribution":{
"name":"Ducks",
"market":"Anaheim",
"reference":"24",
"id":"441862de-0f24-11e2-8525-18a905767e44",
"team_goal":"left",
"sr_id":"sr:team:3675"
},
"period":{
"id":"372ab8ba-e48e-4026-b740-18371b445dea",
"number":2,
"sequence":2,
"type":"Period"
},
"players":[
{
"full_name":"Ross Johnston",
"jersey_number":"44",
"reference":"8477527",
"id":"0a626220-8869-4919-b16b-8e61bc8f6aaa",
"sr_id":"sr:player:983175"
},
{
"full_name":"Ilya Lyubushkin",
"jersey_number":"46",
"reference":"8480950",
"id":"485f3be0-81fb-49ef-87b8-ab26651004b7",
"sr_id":"sr:player:368924"
},
{
"full_name":"Radko Gudas",
"jersey_number":"7",
"reference":"8475462",
"id":"43493300-0f24-11e2-8525-18a905767e44",
"sr_id":"sr:player:318321"
},
{
"full_name":"Sam Carrick",
"jersey_number":"39",
"reference":"8475842",
"id":"e448f557-fb48-4816-ab7a-dd32b92f7d5c",
"sr_id":"sr:player:608376"
},
{
"full_name":"Troy Terry",
"jersey_number":"19",
"reference":"8478873",
"id":"baeee6b2-c75d-4f6d-b52b-8c977f173179",
"sr_id":"sr:player:1088190"
}
]
}
},
"locale":"en",
"metadata":{
"league":"NHL",
"match":"sd:match:4c2c22af-6755-42c8-adb5-0058da782d02,sr:match:41971169",
"status":"inprogress",
"team":"sd:team:441862de-0f24-11e2-8525-18a905767e44,sr:team:3675",
"event_type":"substitution",
"event_category":"substitution",
"locale":"en",
"operation":"update",
"version":"v5"
}
Endpoint Docs
Visit the links below for syntax structure, data samples, and data dictionaries for all NHL Push feeds.
- Push Clock - Provides a game clock feed with high level scoring and strength information
- Push Events - Provides detailed, real-time information on every live game event.
- Push Statistics - Provides detailed, real-time game stats at the team and player level for all live games.
Updated about 1 hour ago