This endpoint retrieves real-time team and player game-level statistics for all live games.
Syntax
https://api.sportradar.com/basketball/{access_level}/stream/statistics/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/statistics/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/statistics/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/statistics/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/statistics/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/statistics/subscribe",
params = {'api_key': 'your_api_key', 'format': 'json', 'sport_event_id': 'sr:sport_event_id:17582523'},
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/statistics/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 | Description of a push statistic 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 |
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 |
Player:
Attribute | Parent Element | Type | Description |
---|---|---|---|
id | statistics - competitor - players | String | Unique ID of a player ex. sr:player:608026 |
name | statistics - competitor - players | String | Name of a player ex. Tavares, Edy |
Competitor:
Attribute | Parent Element | Type | Description |
---|---|---|---|
abbreviation | statistics - competitors | String | Abbreviation for a competitor name ex. RMA (Real Madrid) |
age_group | statistics - competitors | String | Age group of a competitor, when applicable ex. U23 |
country | statistics - competitors | String | Country of a competitor ex. Spain |
country_code | statistics - competitors | String | Country code of a competitor ex. ESP (Spain) |
division | statistics - competitors | Integer | Division number for a competitor |
gender | statistics - competitors | String | Gender for a competitormale , female |
id | statistics - competitors | String | Unique ID for a competitor ex. sr:competitor:3540 (Real Madrid) |
name | statistics - competitors | String | Name for a competitor ex. Real Madrid |
qualifier | statistics - competitors | String | Designation of a competitor for a sport eventhome , away |
state | statistics - competitors | String | State of a competitor ex. TX (Texas) |
Game Stats (Team):
Attribute | Parent Element | Type | Description |
---|---|---|---|
assists | competitors - statistics | Integer | Number of assists for a team in a game |
ball_possession | competitors - statistics | Integer | Percentage of team ball possession for a game |
biggest_lead | competitors - statistics | Integer | Biggest lead in points for a team in a game |
defensive_rebounds | competitors - statistics | Integer | Number of defensive rebounds for a team in a game |
fouls | competitors - statistics | Integer | Number of fouls for a team in a game |
free_throw_attempts_successful | competitors - statistics | Integer | Number of free throws for a team in a game |
free_throw_attempts_total | competitors - statistics | Integer | Number of free throw attempts for a team in a game |
offensive_rebounds | competitors - statistics | Integer | Number of offensive rebounds for a team in a game |
rebounds | competitors - statistics | Integer | Number of total rebounds (offense + defense) for a team in a game |
shots_blocked | competitors - statistics | Integer | Number of shots blocked for a team in a game |
steals | competitors - statistics | Integer | Number of steals for a team in a game |
team_leads | competitors - statistics | Integer | Number of times a team had a lead in a game |
team_rebounds | competitors - statistics | Integer | Number of team rebounds in a game |
team_turnovers | competitors - statistics | Integer | Number of team turnovers in a game |
three_point_attempts_successful | competitors - statistics | Integer | Number of three pointers for a team in a game |
three_point_attempts_total | competitors - statistics | Integer | Number of three point attempts for a team in a game |
time_spent_in_lead | competitors - statistics | Integer | Number of minutes a team led in a game |
timeouts | competitors - statistics | Integer | Number of timeouts used for a team in a game |
turnovers | competitors - statistics | Integer | Number of turnovers for a team in a game |
two_point_attempts_successful | competitors - statistics | Integer | Number of two pointers for a team in a game |
two_point_attempts_total | competitors - statistics | Integer | Number of two point attempts for a team in a game |
Game Stats (Player):
Attribute | Parent Element | Type | Description |
---|---|---|---|
assists | players - statistics | Integer | Number of assists for a player in a game |
blocks | players - statistics | Integer | Number of shots blocked for a player in a game |
defensive_rebounds | players - statistics | Integer | Number of defensive rebounds for a player in a game |
field_goals_attempted | players - statistics | Integer | Number of field goal attempts for a player in a game |
field_goals_made | players - statistics | Integer | Number of field goals for a player in a game |
free_throws_attempted | players - statistics | Integer | Number of free throw attempts for a player in a game |
free_throws_made | players - statistics | Integer | Number of free throws for a player in a game |
minutes | players - statistics | Integer | Number of minutes played for a player in a game |
offensive_rebounds | players - statistics | Integer | Number of offensive rebounds for a player in a game |
personal_fouls | players - statistics | Integer | Number of personal fouls for a player in a game |
points | players - statistics | Integer | Number of points for a player in a game |
steals | players - statistics | Integer | Number of steals for a player in a game |
technical_fouls | players - statistics | Integer | Number of technical fouls for a player in a game |
three_pointers_attempted | players - statistics | Integer | Number of three point attempts for a player in a game |
three_pointers_made | players - statistics | Integer | Number of three pointers for a player in a game |
total_rebounds | players - statistics | Integer | Number of total rebounds (offense + defense) for a player in a game |
turnovers | players - statistics | Integer | Number of turnovers for a player in a game |