Skip to contents

Acquire game context metrics for Major and Minor League games

Usage

mlb_game_context_metrics(game_pk, timecode)

Arguments

game_pk

The game_pk for the game requested

timecode

The time code for the MLB game (format: MMDDYYYY_HHMMSS)

Value

Returns a tibble that includes time codes from the game_pk requested

col_nametypesdescription
game_pkintegerUnique game identifier.
game_guidcharacterGlobally unique game identifier.
linkcharacterMLB Stats API relative game link.
game_typecharacterGame type code (R, P, etc.).
seasoncharacterSeason (YYYY).
game_datecharacterGame date-time (ISO 8601, UTC).
official_datecharacterOfficial game date (YYYY-MM-DD).
status_abstract_game_statecharacterAbstract game state (e.g. Final).
status_coded_game_statecharacterCoded game state.
status_detailed_statecharacterDetailed game state.
status_status_codecharacterGame status code.
status_start_time_tbdlogicalWhether the start time is TBD.
status_abstract_game_codecharacterAbstract game code.
teams_away_team_idintegerAway team MLB ID.
teams_away_team_namecharacterAway team name.
teams_away_team_linkcharacterMLB Stats API relative away team link.
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_probable_pitcher_idintegerAway probable pitcher MLB ID.
teams_away_probable_pitcher_full_namecharacterAway probable pitcher name.
teams_away_probable_pitcher_linkcharacterMLB Stats API relative away pitcher link.
teams_away_split_squadlogicalWhether the away team is a split squad.
teams_away_series_numberintegerAway team series number.
teams_home_team_idintegerHome team MLB ID.
teams_home_team_namecharacterHome team name.
teams_home_team_linkcharacterMLB Stats API relative home team link.
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_probable_pitcher_idintegerHome probable pitcher MLB ID.
teams_home_probable_pitcher_full_namecharacterHome probable pitcher name.
teams_home_probable_pitcher_linkcharacterMLB Stats API relative home pitcher link.
teams_home_split_squadlogicalWhether the home team is a split squad.
teams_home_series_numberintegerHome team series number.
venue_idintegerVenue ID.
venue_namecharacterVenue name.
venue_linkcharacterMLB Stats API relative venue link.
link_1characterMLB Stats API relative game content link.
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/Y/S).
gameday_typecharacterGameday data type code.
tiebreakercharacterTiebreaker indicator.
calendar_event_idcharacterCalendar event identifier.
season_displaycharacterDisplay season (YYYY).
day_nightcharacterDay/night designation.
scheduled_inningsintegerNumber of scheduled innings.
reverse_home_away_statuslogicalWhether home/away designation is reversed.
inning_break_lengthintegerLength of the inning break (seconds).
games_in_seriesintegerTotal games in the series.
series_game_numberintegerGame number within the series.
series_descriptioncharacterSeries description.
record_sourcecharacterSource of the record data.
if_necessarycharacterWhether the game is played only if necessary.
if_necessary_descriptioncharacterIf-necessary description.
game_idcharacterHuman-readable game ID slug.
home_win_probabilitynumericHome team win probability (percent).
away_win_probabilitynumericAway team win probability (percent).

Examples

# \donttest{
  try(mlb_game_context_metrics(game_pk = 531060, timecode = "20180803_182458"))
#> ── MLB Game Context Metrics data from MLB.com ─────── baseballr 2.0.0 ──
#>  Data updated: 2026-06-08 11:08:56 UTC
#> # A tibble: 1 × 66
#>   game_pk game_guid       link  game_type season game_date official_date
#>     <int> <chr>           <chr> <chr>     <chr>  <chr>     <chr>        
#> 1  531060 053ddbf2-26e1-… /api… R         2018   2018-08-… 2018-08-03   
#> # ℹ 59 more variables: status_abstract_game_state <chr>,
#> #   status_coded_game_state <chr>, status_detailed_state <chr>,
#> #   status_status_code <chr>, status_start_time_tbd <lgl>,
#> #   status_abstract_game_code <chr>, teams_away_team_id <int>,
#> #   teams_away_team_name <chr>, teams_away_team_link <chr>,
#> #   teams_away_league_record_wins <int>,
#> #   teams_away_league_record_losses <int>, …
# }