The schedule lists the games. A box score is one game. You take gamePk from GET /v1/mlb/schedule and this call returns each club’s team block, including the batting line: runs, hits, home runs, strikeouts, and walks.
gamePk is required. The schedule sample for 2021-07-30 includes game 633094. The box score example used below is game 633282.
👉 To access this endpoint, you must obtain an API key: https://steadyapi.com/register
Authentication
Every call uses a Bearer token from your SteadyAPI dashboard.
Documentation:
https://docs.steadyapi.com/#authenticating-requests
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
Where this fits
Start at GET /v1/mlb/schedule. Keep objects on body that contain gamePk, and ignore the events value. Pass that gamePk here. Play-by-play is GET /v1/mlb/games-playbyplay with the same parameter. The schedule row already has the inning score and status.detailedState. Open a box score when you need the batting line, not to learn who played.
Box score for one game
Endpoint: GET /v1/mlb/games-boxscore
Documentation:
https://docs.steadyapi.com/#baseball-mlb-GETapi-v1-mlb-games-boxscore
Parameters
gamePk— required game id
There is no date parameter. The game id is the whole query. A missing or non-numeric gamePk is rejected. The response is body.away and body.home, not a list of games.
Python
import requests
url = "https://api.steadyapi.com/v1/mlb/games-boxscore"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
response = requests.get(url, headers=headers, params={"gamePk": game["gamePk"]})
response.raise_for_status()
body = response.json().get("body", {})
for side in ("away", "home"):
club = body.get(side, {})
team = club.get("team", {})
batting = club.get("teamStats", {}).get("batting", {})
print(side, team.get("name"), "R", batting.get("runs"), "H", batting.get("hits"))
Annotated sample
{
"away": {
"team": { "name": "Chicago White Sox", "abbreviation": "CWS" },
"teamStats": {
"batting": { "runs": 7, "hits": 8, "homeRuns": 3, "strikeOuts": 11, "baseOnBalls": 5 }
}
},
"home": {
"team": { "name": "Baltimore Orioles" }
}
}
Read body.away and body.home the same way. team.name and team.abbreviation identify the club. The line you usually show is teamStats.batting: runs, hits, homeRuns, strikeOuts, and baseOnBalls. The White Sox side of game 633282 has 7 runs, 8 hits, and 3 home runs. The home club in that example is the Baltimore Orioles. Player tables and pitching sit beside batting on a full box score. Ignore them until you need a pitcher line. This response does not include gamePk again. Keep the id you sent.
Practical use
body is the two clubs, not a list. body["away"]["team"]["name"] is the visitor. There is no games array to loop.
A scheduled game can return a team block before the batting line is filled in. Check that teamStats.batting exists before you read runs. The schedule’s status.detailedState tells you whether the game is final.
Do not pass an NHL game id or an MLB officialDate as gamePk. The id is the integer on the schedule object, such as 633094 or 633282.
👉 Get your API key and open a box score: https://steadyapi.com/register