Skip to contents

Find game_pk values for professional baseball games (major and minor leagues)

Usage

mlb_schedule(season = 2019, level_ids = "1")

Arguments

season

The season for which you want to find game_pk values for MLB games

level_ids

A numeric vector with ids for each level where game_pks are desired. See below for a reference of level ids.

sport_idsport_codesport_linksport_namesport_abbreviationsort_orderactive_status
1mlb/api/v1/sports/1Major League BaseballMLB11TRUE
11aaa/api/v1/sports/11Triple-AAAA101TRUE
12aax/api/v1/sports/12Double-AAA201TRUE
13afa/api/v1/sports/13High-AA+301TRUE
14afx/api/v1/sports/14Low-AA401TRUE
16rok/api/v1/sports/16RookieROK701TRUE
17win/api/v1/sports/17Winter LeaguesWIN1301TRUE
8bbl/api/v1/sports/8Organized BaseballPros1401TRUE
21min/api/v1/sports/21Minor League BaseballMinors1402TRUE
23ind/api/v1/sports/23Independent LeaguesIND2101TRUE
51int/api/v1/sports/51International BaseballINT3501TRUE
508nat/api/v1/sports/508International Baseball (Collegiate)INTC3502TRUE
509nae/api/v1/sports/509International Baseball (18 and under)18U3503TRUE
510nas/api/v1/sports/510International Baseball (16 and under)16U3505TRUE
22bbc/api/v1/sports/22College BaseballCollege5101TRUE
586hsb/api/v1/sports/586High School BaseballH.S.6201TRUE

Value

Returns a tibble which includes game_pk values and additional information for games scheduled or played with the following columns:

col_nametypesdescription
datecharacterCalendar date for the schedule entry.
total_itemsintegerTotal schedule items on the date.
total_eventsintegerTotal non-game events on the date.
total_gamesintegerTotal games on the date.
total_games_in_progressintegerGames currently in progress on the date.
game_pkintegerUnique game identifier.
game_guidcharacterGlobally unique game identifier (GUID).
linkcharacterAPI link to the game feed.
game_typecharacterGame type code (e.g. 'R', 'S', 'W').
seasoncharacterSeason the game belongs to.
game_datecharacterGame date-time in UTC (ISO 8601).
official_datecharacterOfficial game date (YYYY-MM-DD).
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_seriesintegerNumber of games in the series.
series_game_numberintegerGame 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 (e.g. 'Cancelled').
status_status_codecharacterStatus code for the game.
status_start_time_tbdlogicalWhether the start time is TBD.
status_reasoncharacterReason for the game status (e.g. 'Rain').
status_abstract_game_codecharacterAbstract game state code.
teams_away_split_squadlogicalWhether the away team is a split squad.
teams_away_series_numberintegerAway team's series number.
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_home_split_squadlogicalWhether the home team is a split squad.
teams_home_series_numberintegerHome 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.
venue_idintegerMLBAM venue ID.
venue_namecharacterVenue name.
venue_linkcharacterAPI link to the venue.
content_linkcharacterAPI link to the game content.
is_tielogicalWhether the game ended in a tie.
descriptioncharacterGame description (often for exhibition games).
teams_away_scoreintegerAway team final score.
teams_away_is_winnerlogicalWhether the away team won.
teams_home_scoreintegerHome team final score.
teams_home_is_winnerlogicalWhether the home team won.
reschedule_datecharacterReschedule date-time, if rescheduled.
reschedule_game_datecharacterReschedule game date, if rescheduled.
rescheduled_fromcharacterOriginal date-time the game was rescheduled from.
rescheduled_from_datecharacterOriginal date the game was rescheduled from.
resume_datecharacterResume date-time, if suspended/resumed.
resume_game_datecharacterResume game date, if suspended/resumed.
resumed_fromcharacterDate-time the game was resumed from.
resumed_from_datecharacterDate the game was resumed from.
eventslistNested list of non-game events.

Level IDs

The following IDs can be passed to the level_ids argument:

1 = MLB
11 = Triple-A
12 = Doubl-A
13 = Class A Advanced
14 = Class A
15 = Class A Short Season
5442 = Rookie Advanced
16 = Rookie
17 = Winter League

Examples

# \donttest{
  try(mlb_schedule(season = "2019"))
#> ── MLB Schedule data from MLB.com ─────────────────── baseballr 2.0.0 ──
#>  Data updated: 2026-06-08 11:09:23 UTC
#> # A tibble: 3,010 × 73
#>    date      total_items total_events total_games total_games_in_progr…¹
#>    <chr>           <int>        <int>       <int>                  <int>
#>  1 2019-02-…           1            0           1                      0
#>  2 2019-02-…           4            0           4                      0
#>  3 2019-02-…           4            0           4                      0
#>  4 2019-02-…           4            0           4                      0
#>  5 2019-02-…           4            0           4                      0
#>  6 2019-02-…          16            0          16                      0
#>  7 2019-02-…          16            0          16                      0
#>  8 2019-02-…          16            0          16                      0
#>  9 2019-02-…          16            0          16                      0
#> 10 2019-02-…          16            0          16                      0
#> # ℹ 3,000 more rows
#> # ℹ abbreviated name: ¹​total_games_in_progress
#> # ℹ 68 more variables: game_pk <int>, game_guid <chr>, link <chr>,
#> #   game_type <chr>, season <chr>, game_date <chr>,
#> #   official_date <chr>, game_number <int>, public_facing <lgl>,
#> #   double_header <chr>, gameday_type <chr>, tiebreaker <chr>,
#> #   calendar_event_id <chr>, season_display <chr>, day_night <chr>, …
# }