Skip to main content

MLB — MLB Stats API — Game

mlb_game_context_metrics​

GET /api/v1/game/{gamePk}/contextMetrics — WP, leverage index, in-game context.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/game/{game_pk}/contextMetrics

Valid URL: https://statsapi.mlb.com/api/v1/game/716390/contextMetrics

API ParameterPythonPatternRequiredNullableDescription
game_pkgame_pkYgame_pk path parameter.
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame (parser: parse_mlb_api_list); pass return_as_pandas=True for a pandas.DataFrame. return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_context_metrics(game_pk=716390)

Last validated n/a.

mlb_game_content​

GET /api/v1/game/{gamePk}/content — articles, highlights, editorial content.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/game/{game_pk}/content

Valid URL: https://statsapi.mlb.com/api/v1/game/716390/content

API ParameterPythonPatternRequiredNullableDescription
game_pkgame_pkYgame_pk path parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame (parser: parse_mlb_api_list); pass return_as_pandas=True for a pandas.DataFrame. return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_content(game_pk=716390)

Last validated n/a.

mlb_game_timestamps​

Retrieve all of the play timecodes for a game in GUMBO feed.

Endpoint URL: GET https://statsapi.mlb.com/api/v1.1/game/{game_pk}/feed/live/timestamps

Valid URL: https://statsapi.mlb.com/api/v1.1/game/716390/feed/live/timestamps

API ParameterPythonPatternRequiredNullableDescription
game_pkgame_pkYgame_pk path parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
timecodecharacterA timestamp string representing a specific point in time used to query the MLB Stats API for game state changes.

return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_timestamps(game_pk=716390)

Last validated n/a.

mlb_game_changes​

View corrected non Statcast information for games

Endpoint URL: GET https://statsapi.mlb.com/api/v1/game/changes

Valid URL: https://statsapi.mlb.com/api/v1/game/changes?updatedSince=2023-09-01T00%3A00%3A00Z&sportId=1

API ParameterPythonPatternRequiredNullableDescription
updatedSinceupdated_sinceYupdatedSince query parameter.
sportIdsport_idYsportId query parameter.
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
schedule_datecharacterThe calendar date for which schedule changes are being reported, identifying when rescheduled or suspended games occurred.
game_pkintegerUnique game identifier.
game_guidcharacterGlobally unique game identifier (GUID).
linkcharacterAPI link to the game feed.
game_typecharacterGame type code (R, P, etc.).
seasoncharacterSeason year.
game_datecharacterGame date (YYYY-MM-DD).
official_datecharacterOfficial game date (YYYY-MM-DD).
is_tielogicalWhether the game ended in a tie.
game_numberintegerGame number within a doubleheader.
public_facinglogicalWhether the game is public-facing.
double_headercharacterDoubleheader indicator ('N', 'S', 'Y').
gameday_typecharacterGameday data feed type.
tiebreakercharacterWhether the game is a tiebreaker.
calendar_event_idcharacterCalendar event identifier.
season_displaycharacterDisplay string for the season.
day_nightcharacterDay or night game indicator.
scheduled_inningsintegerScheduled number of innings.
reverse_home_away_statuslogicalWhether home/away teams are reversed.
inning_break_lengthintegerLength of inning breaks in seconds.
games_in_seriesdoubleNumber of games in the series.
series_game_numberdoubleGame number within the series.
series_descriptioncharacterDescription of the series.
record_sourcecharacterSource of the schedule record.
if_necessarycharacterWhether the game is played only if necessary.
if_necessary_descriptioncharacterDescription of the if-necessary status.
status_abstract_game_statecharacterAbstract game state (e.g. 'Final').
status_coded_game_statecharacterCoded game state.
status_detailed_statecharacterDetailed game state.
status_status_codecharacterStatus code for the game.
status_start_time_tbdlogicalWhether the start time is TBD.
status_abstract_game_codecharacterAbstract game state code.
teams_away_team_idintegerAway team MLBAM ID.
teams_away_team_namecharacterAway team name.
teams_away_team_linkcharacterAPI link to the away team.
teams_away_league_record_winsintegerAway team league-record wins.
teams_away_league_record_lossesintegerAway team league-record losses.
teams_away_league_record_tiesintegerAway team league-record ties.
teams_away_league_record_pctcharacterAway team winning percentage.
teams_away_scoreintegerAway team score.
teams_away_is_winnerlogicalWhether the away team won.
teams_away_split_squadlogicalWhether the away team is a split squad.
teams_away_series_numberdoubleAway team's series number.
teams_home_team_idintegerHome team MLBAM ID.
teams_home_team_namecharacterHome team name.
teams_home_team_linkcharacterAPI link to the home team.
teams_home_league_record_winsintegerHome team league-record wins.
teams_home_league_record_lossesintegerHome team league-record losses.
teams_home_league_record_tiesintegerHome team league-record ties.
teams_home_league_record_pctcharacterHome team winning percentage.
teams_home_scoreintegerHome team score.
teams_home_is_winnerlogicalWhether the home team won.
teams_home_split_squadlogicalWhether the home team is a split squad.
teams_home_series_numberdoubleHome team's series number.
venue_idintegerMLBAM venue ID.
venue_namecharacterVenue name.
venue_linkcharacterAPI link to the venue.
content_linkcharacterAPI link to the game content.
rescheduled_fromcharacterOriginal date-time the game was rescheduled from.
rescheduled_from_datecharacterOriginal date the game was rescheduled from.
descriptioncharacterLong-form description text.
status_reasoncharacterReason for the game status (e.g. 'Rain').
resumed_fromcharacterOriginal date-time if the game was resumed.
resumed_from_datecharacterOriginal date if the game was resumed.

return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_changes(sport_id=1, updated_since='2023-09-01T00:00:00Z')

Last validated n/a.

mlb_game_guids​

View Statcast data for a specific game.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/game/{game_pk}/guids

Valid URL: https://statsapi.mlb.com/api/v1/game/716390/guids

API ParameterPythonPatternRequiredNullableDescription
game_pkgame_pkYgame_pk path parameter.
gameModeIdgame_mode_idYgameModeId query parameter.
updatedSinceupdated_sinceYupdatedSince query parameter.
isPitchis_pitchYisPitch query parameter.
isHitis_hitYisHit query parameter.
isPickoffis_pickoffYisPickoff query parameter.
hydratehydrateYhydrate query parameter.
parsed/rawparsed_rawYparsed/raw query parameter.
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame (parser: parse_mlb_api_list); pass return_as_pandas=True for a pandas.DataFrame. return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_guids(game_pk=716390)

Last validated n/a.

mlb_game_color​

View game color commentary info.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/game/{game_pk}/feed/color

Valid URL: https://statsapi.mlb.com/api/v1/game/716390/feed/color

API ParameterPythonPatternRequiredNullableDescription
game_pkgame_pkYgame_pk path parameter.
timecodetimecodeYtimecode query parameter.
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame (parser: parse_mlb_api_list); pass return_as_pandas=True for a pandas.DataFrame. return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_color(game_pk=716390)

Last validated n/a.

mlb_game_color_diff​

View game color feed.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/game/{game_pk}/feed/color/diffPatch

Valid URL: https://statsapi.mlb.com/api/v1/game/716390/feed/color/diffPatch

API ParameterPythonPatternRequiredNullableDescription
game_pkgame_pkYgame_pk path parameter.
startTimecodestart_timecodeYstartTimecode query parameter.
endTimecodeend_timecodeYendTimecode query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame (parser: parse_mlb_api_list); pass return_as_pandas=True for a pandas.DataFrame. return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_color_diff(game_pk=716390)

Last validated n/a.

mlb_game_color_timestamps​

View all of the color timecodes for a game.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/game/{game_pk}/feed/color/timestamps

Valid URL: https://statsapi.mlb.com/api/v1/game/716390/feed/color/timestamps

API ParameterPythonPatternRequiredNullableDescription
game_pkgame_pkYgame_pk path parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame (parser: parse_mlb_api_timecodes); pass return_as_pandas=True for a pandas.DataFrame. return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_color_timestamps(game_pk=716390)

Last validated n/a.

mlb_game_pace​

View time of game info.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/gamePace

Valid URL: https://statsapi.mlb.com/api/v1/gamePace?season=2023

API ParameterPythonPatternRequiredNullableDescription
seasonseasonYSeason year (e.g. 2024).
teamIdsteam_idsYteamIds query parameter.
leagueIdsleague_idsYleagueIds query parameter.
leagueListIdleague_list_idYleagueListId query parameter.
sportIdsport_idYsportId query parameter.
gameTypegame_typeYgameType query parameter.
startDatestart_dateYstartDate query parameter.
endDateend_dateYendDate query parameter.
venueIdsvenue_idsYvenueIds query parameter.
orgTypeorg_typeYorgType query parameter.
includeChildreninclude_childrenYincludeChildren query parameter.
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
hits_per9_inndoubleAverage number of hits allowed per nine innings across all games in the sample period.
runs_per9_inndoubleAverage number of runs scored per nine innings across all games in the sample period.
pitches_per9_inndoubleAverage number of pitches thrown per nine innings across all games in the sample period.
plate_appearances_per9_inndoubleAverage number of plate appearances occurring per nine innings across all games in the sample period.
hits_per_gamedoubleHits per game.
runs_per_gamedoubleRuns per game.
innings_played_per_gamedoubleInnings played per game.
pitches_per_gamedoublePitches per game.
pitchers_per_gamedoublePitchers used per game.
plate_appearances_per_gamedoublePlate appearances per game.
total_game_timecharacterTotal game time (HHH:MM:SS).
total_innings_playeddoubleTotal innings played.
total_hitsintegerTotal hits.
total_runsintegerTotal runs.
total_plate_appearancesintegerTotal plate appearances.
total_pitchersintegerTotal pitchers used.
total_pitchesintegerTotal pitches thrown.
total_gamesintegerTotal games on the date.
total7_inn_gamesintegerTotal number of seven-inning games played (including doubleheader games).
total9_inn_gamesdoubleTotal number of nine-inning games played in the sample period.
total_extra_inn_gamesintegerTotal extra-inning games.
time_per_gamecharacterAverage time per game (HH:MM:SS).
time_per_pitchcharacterAverage time per pitch (HH:MM:SS).
time_per_hitcharacterAverage time per hit (HH:MM:SS).
time_per_runcharacterAverage time per run (HH:MM:SS).
time_per_plate_appearancecharacterAverage time per plate appearance (HH:MM:SS).
time_per9_inncharacterAverage elapsed clock time per nine-inning game formatted as hours and minutes.
time_per77_plate_appearancescharacterAverage time per 77 plate appearances, used as a normalized pace benchmark by MLB.
total_extra_inn_timecharacterTotal extra-inning time (HHH:MM:SS).
time_per7_inn_game_without_extra_inncharacterAverage elapsed clock time per seven-inning game excluding games that went to extra innings.
total9_inn_games_completed_earlyintegerNumber of nine-inning games that were called or suspended before completing nine full innings.
total9_inn_games_without_extra_inndoubleNumber of nine-inning games completed without requiring extra innings.
total9_inn_games_scheduledintegerTotal number of nine-inning games that were scheduled in the sample period.
hits_per_rundoubleHits per run.
pitches_per_pitcherdoublePitches per pitcher.
seasoncharacterSeason year.
sport_idintegerSport MLBAM ID.
sport_codecharacterShort sport code (e.g. 'mlb', 'aaa').
sport_linkcharacterAPI link to the sport.
pr_portal_calculated_fields_total7_inn_gamesintegerCalculated total count of seven-inning games as tallied by the MLB Stats API pace portal.
pr_portal_calculated_fields_total9_inn_gamesdoubleCalculated total count of nine-inning games as tallied by the MLB Stats API pace portal.
pr_portal_calculated_fields_total_extra_inn_gamesintegerPortal-calculated total extra-inning games.
pr_portal_calculated_fields_time_per7_inn_gamecharacterCalculated average game time per seven-inning game as produced by the MLB Stats API pace portal.
pr_portal_calculated_fields_time_per9_inn_gamecharacterCalculated average game time per nine-inning game as produced by the MLB Stats API pace portal.
pr_portal_calculated_fields_time_per_extra_inn_gamecharacterPortal-calculated time per extra-inning game.
time_per7_inn_gamecharacterAverage elapsed clock time per seven-inning game formatted as hours and minutes.
total7_inn_games_scheduleddoubleTotal number of seven-inning games that were scheduled in the sample period.
total7_inn_games_without_extra_inndoubleNumber of seven-inning games completed without requiring extra innings.
total7_inn_games_completed_earlydoubleNumber of seven-inning games that were called or completed before the full seven innings were played.

return_parsed=False — the raw JSON Dict payload, unparsed.

Example​

mlb_game_pace(season='2023')

Last validated n/a.