Skip to contents

Acquire pitch-by-pitch data between two timecodes for Major and Minor League games

Usage

mlb_pbp_diff(game_pk, start_timecode, end_timecode)

Arguments

game_pk

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

start_timecode

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

end_timecode

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

Value

Returns a tibble that includes over 100 columns of data provided by the MLB Stats API at a pitch level between the start_timecode and end_timecode

col_nametypes
game_pknumeric
game_datecharacter
indexinteger
startTimecharacter
endTimecharacter
isPitchlogical
typecharacter
playIdcharacter
pitchNumberinteger
details.descriptioncharacter
details.eventcharacter
details.awayScoreinteger
details.homeScoreinteger
details.isScoringPlaylogical
details.hasReviewlogical
details.codecharacter
details.ballColorcharacter
details.isInPlaylogical
details.isStrikelogical
details.isBalllogical
details.call.codecharacter
details.call.descriptioncharacter
count.balls.startinteger
count.strikes.startinteger
count.outs.startinteger
player.idinteger
player.linkcharacter
pitchData.strikeZoneTopnumeric
pitchData.strikeZoneBottomnumeric
details.fromCatcherlogical
pitchData.coordinates.xnumeric
pitchData.coordinates.ynumeric
hitData.trajectorycharacter
hitData.hardnesscharacter
hitData.locationcharacter
hitData.coordinates.coordXnumeric
hitData.coordinates.coordYnumeric
actionPlayIdcharacter
details.eventTypecharacter
details.runnerGoinglogical
position.codecharacter
position.namecharacter
position.typecharacter
position.abbreviationcharacter
battingOrdercharacter
atBatIndexcharacter
result.typecharacter
result.eventcharacter
result.eventTypecharacter
result.descriptioncharacter
result.rbiinteger
result.awayScoreinteger
result.homeScoreinteger
about.atBatIndexinteger
about.halfInningcharacter
about.inninginteger
about.startTimecharacter
about.endTimecharacter
about.isCompletelogical
about.isScoringPlaylogical
about.hasReviewlogical
about.hasOutlogical
about.captivatingIndexinteger
count.balls.endinteger
count.strikes.endinteger
count.outs.endinteger
matchup.batter.idinteger
matchup.batter.fullNamecharacter
matchup.batter.linkcharacter
matchup.batSide.codecharacter
matchup.batSide.descriptioncharacter
matchup.pitcher.idinteger
matchup.pitcher.fullNamecharacter
matchup.pitcher.linkcharacter
matchup.pitchHand.codecharacter
matchup.pitchHand.descriptioncharacter
matchup.splits.battercharacter
matchup.splits.pitchercharacter
matchup.splits.menOnBasecharacter
batted.ball.resultfactor
home_teamcharacter
home_level_idinteger
home_level_namecharacter
home_parentOrg_idinteger
home_parentOrg_namecharacter
home_league_idinteger
home_league_namecharacter
away_teamcharacter
away_level_idinteger
away_level_namecharacter
away_parentOrg_idinteger
away_parentOrg_namecharacter
away_league_idinteger
away_league_namecharacter
batting_teamcharacter
fielding_teamcharacter
last.pitch.of.abcharacter
pfxIdcharacter
details.trailColorcharacter
details.type.codecharacter
details.type.descriptioncharacter
pitchData.startSpeednumeric
pitchData.endSpeednumeric
pitchData.zoneinteger
pitchData.typeConfidencenumeric
pitchData.plateTimenumeric
pitchData.extensionnumeric
pitchData.coordinates.aYnumeric
pitchData.coordinates.aZnumeric
pitchData.coordinates.pfxXnumeric
pitchData.coordinates.pfxZnumeric
pitchData.coordinates.pXnumeric
pitchData.coordinates.pZnumeric
pitchData.coordinates.vX0numeric
pitchData.coordinates.vY0numeric
pitchData.coordinates.vZ0numeric
pitchData.coordinates.x0numeric
pitchData.coordinates.y0numeric
pitchData.coordinates.z0numeric
pitchData.coordinates.aXnumeric
pitchData.breaks.breakAnglenumeric
pitchData.breaks.breakLengthnumeric
pitchData.breaks.breakYnumeric
pitchData.breaks.spinRateinteger
pitchData.breaks.spinDirectioninteger
hitData.launchSpeednumeric
hitData.launchAnglenumeric
hitData.totalDistancenumeric
injuryTypecharacter
umpire.idinteger
umpire.linkcharacter
about.isTopInninglogical
matchup.postOnFirst.idinteger
matchup.postOnFirst.fullNamecharacter
matchup.postOnFirst.linkcharacter

Examples

# \donttest{
  try(mlb_pbp_diff(game_pk = 632970, 
                   start_timecode = "20210808_231704", 
                   end_timecode = "20210808_233711"))
#> ── MLB Play-by-Play diff data from MLB.com ────────── baseballr 1.6.0 ──
#>  Data updated: 2024-04-13 21:56:35 UTC
#> # A tibble: 50 × 141
#>    game_pk game_date  index startTime       endTime isPitch type  playId
#>      <dbl> <chr>      <int> <chr>           <chr>   <lgl>   <chr> <chr> 
#>  1  632970 2021-08-08     2 2021-08-08T23:… 2021-0… TRUE    pitch 0c67e…
#>  2  632970 2021-08-08     1 2021-08-08T23:… 2021-0… TRUE    pitch 51631…
#>  3  632970 2021-08-08     0 2021-08-08T23:… 2021-0… TRUE    pitch e3edf…
#>  4  632970 2021-08-08     2 2021-08-08T23:… 2021-0… TRUE    pitch 65870…
#>  5  632970 2021-08-08     1 2021-08-08T23:… 2021-0… TRUE    pitch d5fc8…
#>  6  632970 2021-08-08     0 2021-08-08T23:… 2021-0… TRUE    pitch 0a6c9…
#>  7  632970 2021-08-08     4 2021-08-08T23:… 2021-0… TRUE    pitch 506d0…
#>  8  632970 2021-08-08     3 2021-08-08T23:… 2021-0… TRUE    pitch 24f33…
#>  9  632970 2021-08-08     2 2021-08-08T23:… 2021-0… TRUE    pitch aae6b…
#> 10  632970 2021-08-08     1 2021-08-08T23:… 2021-0… TRUE    pitch 63658…
#> # ℹ 40 more rows
#> # ℹ 133 more variables: pitchNumber <int>, details.description <chr>,
#> #   details.event <chr>, details.awayScore <int>,
#> #   details.homeScore <int>, details.isScoringPlay <lgl>,
#> #   details.hasReview <lgl>, details.code <chr>,
#> #   details.ballColor <chr>, details.isInPlay <lgl>,
#> #   details.isStrike <lgl>, details.isBall <lgl>, …
# }