MLB Push Linescores provides real-time high level scoring by inning.
Syntax
https://api.sportradar.com/mlb/{access_level}/stream/en/linescore/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.
Parameter | Description |
---|---|
match | Game id Example: match=sd:match:7779b2fe-70ad-4823-8c6d-9e2453576e2a |
status | Game statusinprogress , created Example: status=inprogress |
Code Samples
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sportradar.com/mlb/trial/stream/en/linescore/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/mlb/trial/stream/en/linescore/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/mlb/trial/stream/en/linescore/subscribe?api_key={your_api_key}'
Samples with Query String Params
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.sportradar.com/mlb/trial/stream/en/linescore/subscribe?api_key={your_api_key}&status=inprogress&match=sd:match:7779b2fe-70ad-4823-8c6d-9e2453576e2a")
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/mlb/trial/stream/en/linescore/subscribe",
params = {'api_key': 'your_api_key', 'status': 'inprogress', 'match': 'sd:match:7779b2fe-70ad-4823-8c6d-9e2453576e2a'},
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/mlb/trial/stream/en/linescore/subscribe?api_key={your_api_key}&status=inprogress&match=sd:match:7779b2fe-70ad-4823-8c6d-9e2453576e2a'
Response Sample
The above commands return json like this.
Data Points
Metadata:
Attribute | Parent Element | Type | Description |
---|---|---|---|
league | metadata | String | Alias of a league ex. MLB |
locale | metadata | String | Language code ex. en (English) |
match | metadata | GUID | Unique ID of a game ex. sd:match:30ad883f-aeaf-4e6b-9fd9-a1cc0b6c4679 |
operation | metadata | String | Operation of an updatecreate , update , delete |
status | metadata | String | The status of a gamescheduled , inprogress , complete , closed , wdelay , fdelay , odelay , canceled , unnecessary , if-necessary , postponed , suspended , maintenance |
version | metadata | String | Version of the API ex. v6.5 |
Boxscore:
Attribute | Parent Element | Type | Description |
---|---|---|---|
abbr | away | String | Abbreviation of the away team ex. MIN (Minnesota) |
errors | away | Integer | Number of errors for the away team |
hits | away | Integer | Number of hits for the away team |
id | away | GUID | Unique ID of the away team ex. 29dd9a87-5bcc-4774-80c3-7f50d985068b |
id | away -probable_pitcher | GUID | Unique ID of the away team's probable pitcher ex. 515af486-d938-4cb6-90e4-943323a5737c |
market | away | String | Market name of the away team ex. Colorado |
name | away | String | Team name of the away team ex. Rockies |
runs | away | Integer | Number of runs for the away team in the game |
abbr | home | String | Abbreviation of the home team ex. CLE (Cleveland) |
errors | home | Integer | Number of errors for the home team |
hits | home | Integer | Number of hits for the home team |
id | home | GUID | Unique ID of the home team ex. 29dd9a87-5bcc-4774-80c3-7f50d985068b |
id | home -probable_pitcher | GUID | Unique ID of the home team's probable pitcher ex. 515af486-d938-4cb6-90e4-943323a5737c |
market | home | String | Market name of the home team ex. Cleveland |
name | home | String | Team name of the home team ex. Guardians |
runs | home | Integer | Number of runs for the home team in the game |
away | linescore | Integer | Number of runs for the away team in the game |
home | linescore | Integer | Number of runs for the home team in the game |
inning | linescore | Integer | Number of the current inning |
abbr | team | String | Abbreviation of a team ex. TB (Tampa Bay) |
id | team | GUID | Unique ID of a team ex. bdc11650-6f74-49c4-875e-778aeb7632d9 |
market | team | String | Market name of a team ex. Tampa Bay |
name | team | String | Team name ex. Rays |
Game:
Attribute | Parent Element | Type | Description |
---|---|---|---|
away_team | game | GUID | Unique ID of the away team ex. 29dd9a87-5bcc-4774-80c3-7f50d985068b |
coverage | game | String | Coverage level of a gamefull , boxscore |
double_header | game | Boolean | Signifies whether a game is part of a double header |
day_night | game | String | Signifies a day or night gameD , N |
entry_mode | game | String | Signifies the type of data entrySTOMP , LDE |
home_team | game | GUID | Unique ID of the home team ex. ef64da7f-cfaf-4300-87b0-9313386b977c |
id | game | GUID | Unique ID of the game ex. 1b554f5e-d8b7-4268-95da-2f4191015c84 |
game_number | game | Integer | Number of the game |
reference | game | String | Unique MLBAM ID of a game |
scheduled | game | dateTime | Scheduled date and time of a game ex. 2022-09-25T20:10:00+00:00 |
split_squad | game | Boolean | Signifies a Spring Training split squad game |
status | game | String | The status of a gamescheduled , inprogress , complete , closed , wdelay , fdelay , odelay , canceled , unnecessary , if-necessary , postponed , suspended , maintenance |
Play-By-Play - Count:
Attribute | Parent Element | Type | Description |
---|---|---|---|
balls | boxscore | Integer | Number of balls in an at bat |
outs | boxscore | Integer | Number of outs in an at bat |
inning_half | boxscore | String | Inning half of a player entering the gameT , B |
inning | boxscore | Integer | Inning of a player entering the game |
pitch_count | boxscore | Integer | Number of pitches in an at bat |
strikes | boxscore | Integer | Number of strikes in an at bat |
Current Baserunners:
Attribute | Parent Element | Type | Description |
---|---|---|---|
base | runners | Integer | Runner's base at the end of a play |
first_name | runners | String | First name of the current runner ex. Markus |
full_name | runners | String | Full name of the current runner ex. Mookie Betts |
suffix | runners | String | Name suffix of the current runner ex. Jr. |
jersey_number | runners | Integer | Number of the current runner's jersey |
last_name | runners | String | Last name of the current runner ex. Betts |
out | outcome -runner | Boolean | Signifies the runner was out on a play |
preferred_name | runners | String | Preferred name of the current runner ex. Mookie |
Current Hitter:
Attribute | Parent Element | Type | Description |
---|---|---|---|
first_name | hitter | String | First name of the current hitter ex. Markus |
full_name | hitter | String | Full name of the current hitter ex. Mookie Betts |
suffix | hitter | String | Name suffix of the current hitter ex. Jr. |
hitter_hand | hitter | Boolean | Handedness of a hittter |
jersey_number | hitter | Integer | Number of the current hitter's jersey |
last_name | hitter | String | Last name of the current hitter ex. Betts |
lineup_order | hitter | Integer | Lineup order number of the current hitter |
lineup_position | hitter | String | Lineup position of the current hitter |
preferred_name | hitter | String | Preferred name of the current hitter ex. Mookie |
Current Pitcher:
Attribute | Parent Element | Type | Description |
---|---|---|---|
first_name | pitcher | String | First name of the current pitcher ex. Clayton |
full_name | pitcher | String | Full name of the current pitcher ex. Clayton Kershaw |
suffix | pitcher | String | Name suffix of the current pitcher ex. Jr. |
jersey_number | pitcher | Integer | Number of the current pitcher's jersey |
last_name | pitcher | String | Last name of the current pitcher ex. Kershaw |
pitch_count | pitcher | Integer | Pitch count of the current pitcher |
pitch_hand | pitcher | String | Pitching hand of the current pitcher |
preferred_name | pitcher | String | Preferred name of the current pitcher ex. Clayton |