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_nametypes
datecharacter
total_itemsinteger
total_eventsinteger
total_gamesinteger
total_games_in_progressinteger
game_pkinteger
linkcharacter
game_typecharacter
seasoncharacter
game_datecharacter
official_datecharacter
game_numberinteger
public_facinglogical
double_headercharacter
gameday_typecharacter
tiebreakercharacter
calendar_event_idcharacter
season_displaycharacter
day_nightcharacter
scheduled_inningsinteger
reverse_home_away_statuslogical
inning_break_lengthinteger
games_in_seriesinteger
series_game_numberinteger
series_descriptioncharacter
record_sourcecharacter
if_necessarycharacter
if_necessary_descriptioncharacter
status_abstract_game_statecharacter
status_coded_game_statecharacter
status_detailed_statecharacter
status_status_codecharacter
status_start_time_tbdlogical
status_reasoncharacter
status_abstract_game_codecharacter
teams_away_split_squadlogical
teams_away_series_numberinteger
teams_away_league_record_winsinteger
teams_away_league_record_lossesinteger
teams_away_league_record_pctcharacter
teams_away_team_idinteger
teams_away_team_namecharacter
teams_away_team_linkcharacter
teams_home_split_squadlogical
teams_home_series_numberinteger
teams_home_league_record_winsinteger
teams_home_league_record_lossesinteger
teams_home_league_record_pctcharacter
teams_home_team_idinteger
teams_home_team_namecharacter
teams_home_team_linkcharacter
venue_idinteger
venue_namecharacter
venue_linkcharacter
content_linkcharacter
is_tielogical
descriptioncharacter
teams_away_scoreinteger
teams_away_is_winnerlogical
teams_home_scoreinteger
teams_home_is_winnerlogical
reschedule_datecharacter
reschedule_game_datecharacter
rescheduled_fromcharacter
rescheduled_from_datecharacter
resume_datecharacter
resume_game_datecharacter
resumed_fromcharacter
resumed_from_datecharacter
eventslist

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 1.2.0 ──
#>  Data updated: 2022-04-30 07:16:31 UTC
#> # A tibble: 3,010 × 70
#>    date    total_items total_events total_games total_games_in_… game_pk
#>    <chr>         <int>        <int>       <int>            <int>   <int>
#>  1 2019-0…           1            0           1                0  566071
#>  2 2019-0…           4            0           4                0  568310
#>  3 2019-0…           4            0           4                0  568403
#>  4 2019-0…           4            0           4                0  568440
#>  5 2019-0…           4            0           4                0  566356
#>  6 2019-0…          16            0          16                0  564914
#>  7 2019-0…          16            0          16                0  567043
#>  8 2019-0…          16            0          16                0  567344
#>  9 2019-0…          16            0          16                0  565011
#> 10 2019-0…          16            0          16                0  566849
#> # … with 3,000 more rows, and 64 more variables: 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>,
#> #   scheduled_innings <int>, reverse_home_away_status <lgl>,
#> #   inning_break_length <int>, games_in_series <int>, …
# }