This endpoint retrieves real-time event updates for all live matches.
Syntax
https://api.sportradar.com/basketball/{access_level}/stream/events/subscribe?api_key={your_api_key} |
Parameters
Parameter | Description |
---|---|
access_level | Defines the access level of your API keyproduction , trial |
your_api_key | Your API key |
Optional Query String Parameters
By default, a Push feed will provide all data available for all in progress games. If needed, you can filter the data returned by including query strings.
Optional query string parameters must be added after your API key with an ampersand (&
). If you are filtering for more than one result, separate the results with a comma (,
) and no spaces.
URL Parameters | Description |
---|---|
channel | Channel type Example: channel=basketball |
competition_id | Competition id Example: competition_id=sr:competition:27230 |
event_id | Event type Example: event_id=score_change |
format | Format type Example: format=json |
season_id | Season id Example: season_id=sr:season:59654 |
sport_event_id | Sport event id Example: sport_event_id=sr:sport_event:17582523 |
sport_id | Sport id Example: sport_id=sr:sport:22 |
Code Samples
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sportradar.com/basketball/trial/stream/events/subscribe?api_key={your_api_key}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
import json
r = requests.get("https://api.sportradar.com/basketball/trial/stream/events/subscribe",
params = {'api_key': 'your_api_key'},
allow_redirects=False)
redirect_url = r.headers['Location']
r = requests.get(redirect_url, stream=True)
for line in r.iter_lines():
# filter out keep-alive new lines
if line:
decoded_line = line.decode('utf-8')
print(json.loads(decoded_line))
curl -L GET 'api.sportradar.com/basketball/trial/stream/events/subscribe?api_key={your_api_key}'
Samples with Query String Params
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sportradar.com/basketball/trial/stream/events/subscribe?api_key={your_api_key}&format=json&sport_event_id=sr:sport_event_id:17582523")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import requests
import json
r = requests.get("https://api.sportradar.com/basketball/trial/stream/events/subscribe",
params = {'api_key': 'your_api_key', 'format': 'json', 'sr:sport_event_id:17582523': 'test_this_thing'},
allow_redirects=False)
redirect_url = r.headers['Location']
r = requests.get(redirect_url, stream=True)
for line in r.iter_lines():
# filter out keep-alive new lines
if line:
decoded_line = line.decode('utf-8')
print(json.loads(decoded_line))
curl -L GET 'https://api.sportradar.com/basketball/trial/stream/events/subscribe?api_key={your_api_key}&format=json&sport_event_id=sr:sport_event_id:17582523'
Response Sample
The above commands return json like this.
Data Points
Metadata:
Attribute | Parent Element | Type | Description |
---|---|---|---|
channel | metadata | String | Sport of the stream connection ex. basketball |
competition_id | metadata | String | Unique Id of a competition ex. sr:competition:19980 |
event_id | metadata | String | Type of timeline event. Reference enum_event_type in our Global Basketball OpenAPI Spec for a complete list of event types ex. match_started , turnover , won_jump_ball |
format | metadata | String | Format type of the responsejson , xml |
season_id | metadata | String | Unique Id of a season ex. sr:season:106289 |
sport_event_id | metadata | String | Unique Id of a sport event ex. sr:sport_event_id:49324739 |
sport_id | metadata | String | Unique Id of a sport ex. sr:sport:1 |
from | heartbeat | Integer | Unix timestamp of the beginning of a heartbeat message ex. 1713804799 |
to | heartbeat | Integer | Unix timestamp of the end of a heartbeat message ex. 1713804804 |
interval | heartbeat | Integer | Interval of a heartbeat message in seconds |
type | heartbeat | String | Type of heartbeat message ex. events , statistics |
package | heartbeat | String | Package of a heartbeat message ex. basketball-v2 |
Game Timeline:
Attribute | Parent Element | Type | Description |
---|---|---|---|
away_score | event | Integer | Score for the away team after a timeline event |
break_name | event | String | Brief description of a break event ex. 1st_pause |
competitor | event | String | Designation of a competitor for a timeline eventhome , away |
home_score | event | Integer | Score for the home team after a timeline event |
id | event | Integer | Unique ID for a timeline event ex. 1721786685 |
match_clock | event | String | Clock value for a timeline event, in minutes and seconds ex. 11:59 |
match_time | event | Integer | Clock value of a timeline event, in minutes ex. 12 |
period | event | Integer | Period number of a timeline event |
period_name | event | String | Period name of a timeline event, appearing at the beginning of a period ex. 2nd_quarter |
points | event | Integer | Number of points for a timeline event. Value could be related to attempt_missed or score_change under event.type .ex. 1 , 2 , 3 |
time | event | Date-time | Timestamp of a timeline event ex. 2024-04-16T20:49:49+00:00 |
type | event | String | Type of timeline event. Reference enum_event_type in our Global Basketball OpenAPI Spec for a complete list of event types ex. score_change , turnover , won_jump_ball |
updated | event | Boolean | Signifies this event has been updated since its original entry when true |
updated_time | event | Date-time | Timestamp of an updated time entry ex. 2024-04-22T17:17:24+00:00 |
x | event | Integer | Horizontal X coordinate of a timeline event. x is a number between 0 and 100 . |
y | event | Integer | Vertical Y coordinate of a timeline event. y is a number between 0 and 100 . |
Player Event Details:
Attribute | Parent Element | Type | Description |
---|---|---|---|
id | event - player | String | Unique player Id associated with a timeline event ex. sr:player:1153060 |
name | event - player | String | Player name associated with a timeline event ex. Russell, Mercedes |
Sport Event Status:
Attribute | Parent Element | Type | Description |
---|---|---|---|
away_normaltime_score | sport_event_status | Integer | Score for the away team in normal time |
away_score | sport_event_status | Integer | Total score for the away team in the game |
home_normaltime_score | sport_event_status | Integer | Score for the home team in normal time |
home_score | sport_event_status | Integer | Total score for the home team in the game |
match_status | sport_event_status | String | Status within a game (sport event). Provides more detail on the state of a sport event when live than status ex. not_started , 1st_quarter , ended , cancelled See our FAQ for a complete list of statuses and their definitions. |
scount_abandoned | sport_event_status | Boolean | Signifies a game was abandoned by a scout when true |
status | sport_event_status | String | Status of a game ex. not_started , 2nd_half , ended , awaiting_penalties See our FAQ for a complete list of statuses and their definitions. |
winner_id | sport_event_status | String | Unique ID of the game winner ex. sr:competitor:44 |
Sport Event Situation:
Attribute | Parent Element | Type | Description |
---|---|---|---|
played | sport_event_status - clock | String | Game time played in a quarter/period, in minutes ex. 00:36 |
remaining | sport_event_status - clock | String | Time remaining in a quarter/period, in minutes ex. 9:21 |
away_score | sport_event_status - period_scores | Integer | Away team period score |
home_score | sport_event_status - period_scores | Integer | Home team period score |
number | sport_event_status - period_scores | Integer | Period number |
type | sport_event_status - period_scores | String | Period typeregular_period , overtime , 1st_quarter , 2nd_quarter , 3rd_quarter , 4th_quarter , 1st_half , 2nd_half , penalties , 1st_pause , 2nd_pause , 3rd_pause , awaiting_extra , awaiting_penalties , interrupted , 1st_extra , 2nd_extra |