Skip to contents

This function allows you to query Statcast data as provided on https://baseballsavant.mlb.com

Usage

statcast_search(
  start_date = Sys.Date() - 1,
  end_date = Sys.Date(),
  playerid = NULL,
  player_type = "batter",
  ...
)

statcast_search.default(
  start_date = Sys.Date() - 1,
  end_date = Sys.Date(),
  playerid = NULL,
  player_type = "batter",
  ...
)

statcast_search_batters(start_date, end_date, batterid = NULL, ...)

statcast_search_pitchers(start_date, end_date, pitcherid = NULL, ...)

Arguments

start_date

Date of first game for which you want data. Format must be in YYYY-MM-DD format.

end_date

Date of last game for which you want data. Format must be in YYYY-MM-DD format.

playerid

The MLBAM ID for the player whose data you want to query.

player_type

The player type. Can be batter or pitcher. Default is batter

...

currently ignored

batterid

The MLBAM ID for the batter whose data you want to query.

pitcherid

The MLBAM ID for the pitcher whose data you want to query.

Value

Returns a tibble with Statcast data with the following columns:

col_nametypesdescription
pitch_typecharacterAbbreviation of the pitch type thrown (e.g. FF, SL, CH).
game_dateDateDate the game was played.
release_speednumericPitch velocity out of the hand (mph).
release_pos_xnumericHorizontal release position of the ball, catcher's perspective (feet).
release_pos_znumericVertical release position of the ball, catcher's perspective (feet).
player_namecharacterPitcher (or batter, by query) name, Last, First.
batternumericMLBAM ID for the batter.
pitchernumericMLBAM ID for the pitcher.
eventscharacterPlate-appearance outcome (e.g. single, strikeout, home_run).
descriptioncharacterPitch-level result description (e.g. ball, called_strike, hit_into_play).
spin_dirlogicalDeprecated spin direction field, no longer populated.
spin_rate_deprecatedlogicalDeprecated legacy spin-rate field, no longer populated.
break_angle_deprecatedlogicalDeprecated legacy break-angle field, no longer populated.
break_length_deprecatedlogicalDeprecated legacy break-length field, no longer populated.
zonenumericStrike-zone region the pitch crossed (1-14 Gameday zone).
descharacterFull text description of the play.
game_typecharacterType of game: R (regular), PO/F/D/L/W (postseason), S (spring).
standcharacterSide of the plate the batter is standing (L or R).
p_throwscharacterHand the pitcher throws with (L or R).
home_teamcharacterHome team abbreviation.
away_teamcharacterAway team abbreviation.
typecharacterPitch result code: B (ball), S (strike), X (in play).
hit_locationintegerFielder position number that fielded the ball.
bb_typecharacterBatted-ball type (ground_ball, line_drive, fly_ball, popup).
ballsintegerBall count before the pitch.
strikesintegerStrike count before the pitch.
game_yearintegerSeason year of the game.
pfx_xnumericHorizontal pitch movement from the catcher's perspective (feet).
pfx_znumericVertical pitch movement from the catcher's perspective (feet).
plate_xnumericHorizontal position of the pitch crossing the plate (feet from center).
plate_znumericVertical position of the pitch crossing the plate (feet above ground).
on_3bnumericMLBAM ID of the runner on third base, if any.
on_2bnumericMLBAM ID of the runner on second base, if any.
on_1bnumericMLBAM ID of the runner on first base, if any.
outs_when_upintegerNumber of outs when the batter came to the plate.
inningnumericInning number.
inning_topbotcharacterHalf of the inning (Top or Bot).
hc_xnumericHit coordinate X on the field diagram.
hc_ynumericHit coordinate Y on the field diagram.
tfs_deprecatedlogicalDeprecated time-from-start field, no longer populated.
tfs_zulu_deprecatedlogicalDeprecated Zulu time-from-start field, no longer populated.
umpirelogicalDeprecated umpire field, no longer populated.
sv_idlogicalDeprecated Sportvision/Statcast pitch identifier, no longer populated.
vx0numericVelocity of the pitch in the x-direction at y=50 ft (ft/s).
vy0numericVelocity of the pitch in the y-direction at y=50 ft (ft/s).
vz0numericVelocity of the pitch in the z-direction at y=50 ft (ft/s).
axnumericAcceleration of the pitch in the x-direction at y=50 ft (ft/s^2).
aynumericAcceleration of the pitch in the y-direction at y=50 ft (ft/s^2).
aznumericAcceleration of the pitch in the z-direction at y=50 ft (ft/s^2).
sz_topnumericTop of the batter's strike zone for the pitch (feet).
sz_botnumericBottom of the batter's strike zone for the pitch (feet).
hit_distance_scnumericStatcast-measured projected distance of the batted ball (feet).
launch_speednumericExit velocity of the batted ball (mph).
launch_anglenumericVertical launch angle of the batted ball (degrees).
effective_speednumericPerceived velocity adjusted for release extension (mph).
release_spin_ratenumericSpin rate of the pitch at release (rpm).
release_extensionnumericDistance toward the plate at release (feet).
game_pknumericUnique MLB game identifier.
fielder_2numericMLBAM ID of the catcher.
fielder_3numericMLBAM ID of the first baseman.
fielder_4numericMLBAM ID of the second baseman.
fielder_5numericMLBAM ID of the third baseman.
fielder_6numericMLBAM ID of the shortstop.
fielder_7numericMLBAM ID of the left fielder.
fielder_8numericMLBAM ID of the center fielder.
fielder_9numericMLBAM ID of the right fielder.
release_pos_ynumericRelease position of the ball toward the plate (feet).
estimated_ba_using_speedanglenumericExpected batting average based on exit velocity and launch angle.
estimated_woba_using_speedanglenumericExpected wOBA based on exit velocity and launch angle.
woba_valuenumericwOBA value assigned to the event.
woba_denomintegerwOBA denominator (plate-appearance weight) for the event.
babip_valueintegerBABIP value assigned to the event (0 or 1).
iso_valueintegerIsolated power value assigned to the event.
launch_speed_angleintegerBatted-ball classification code (1-6) from exit velocity and angle.
at_bat_numbernumericSequential plate-appearance number within the game.
pitch_numbernumericPitch number within the plate appearance.
pitch_namecharacterFull name of the pitch type (e.g. 4-Seam Fastball, Slider).
home_scorenumericHome team score before the pitch.
away_scorenumericAway team score before the pitch.
bat_scorenumericBatting team score before the pitch.
fld_scorenumericFielding team score before the pitch.
post_away_scorenumericAway team score after the pitch.
post_home_scorenumericHome team score after the pitch.
post_bat_scorenumericBatting team score after the pitch.
post_fld_scorenumericFielding team score after the pitch.
if_fielding_alignmentcharacterInfield defensive alignment (Standard, Strategic, Infield shift).
of_fielding_alignmentcharacterOutfield defensive alignment (Standard, Strategic, 4th outfielder).
spin_axisnumericSpin axis of the pitch as a clock-face angle (degrees).
delta_home_win_expnumericChange in home team win expectancy on the play.
delta_run_expnumericChange in run expectancy on the play.
bat_speednumericBat speed at the point of contact (mph).
swing_lengthnumericLength of the swing path to contact (feet).
estimated_slg_using_speedanglenumericExpected slugging based on exit velocity and launch angle.
delta_pitcher_run_expnumericChange in run expectancy credited to the pitcher.
hyper_speednumericAdjusted (90th-percentile) exit velocity (mph).
home_score_diffintegerHome team score minus away team score before the pitch.
bat_score_diffintegerBatting team score minus fielding team score before the pitch.
home_win_expnumericHome team win expectancy before the play.
bat_win_expnumericBatting team win expectancy before the play.
age_pit_legacyintegerPitcher age using the legacy calculation.
age_bat_legacyintegerBatter age using the legacy calculation.
age_pitintegerPitcher age for the season.
age_batintegerBatter age for the season.
n_thruorder_pitcherintegerTimes through the order the pitcher is facing the lineup.
n_priorpa_thisgame_player_at_batintegerNumber of prior plate appearances by the batter in the game.
pitcher_days_since_prev_gameintegerDays since the pitcher's previous game appearance.
batter_days_since_prev_gameintegerDays since the batter's previous game appearance.
pitcher_days_until_next_gameintegerDays until the pitcher's next game appearance.
batter_days_until_next_gameintegerDays until the batter's next game appearance.
api_break_z_with_gravitynumericVertical pitch break including gravity (inches).
api_break_x_armnumericHorizontal pitch break to the pitcher's arm side (inches).
api_break_x_batter_innumericHorizontal pitch break toward/away from the batter (inches).
arm_anglenumericPitcher's arm angle at release (degrees).
attack_anglenumericAngle of the bat's path at contact (degrees).
attack_directionnumericHorizontal direction of the swing at contact (degrees).
swing_path_tiltnumericVertical tilt of the swing path (degrees).
intercept_ball_minus_batter_pos_x_inchesnumericHorizontal offset of ball-bat intercept from batter position (inches).
intercept_ball_minus_batter_pos_y_inchesnumericDepth offset of ball-bat intercept from batter position (inches).

Returns a tibble with Statcast data.

Returns a tibble with the same Statcast pitch-level columns as statcast_search(), filtered to the requested batter. See the statcast_search() return value for the full column-by-column reference.

Returns a tibble with the same Statcast pitch-level columns as statcast_search(), filtered to the requested pitcher. See the statcast_search() return value for the full column-by-column reference.

Examples

# \donttest{
  ### Harper
  try(statcast_search(start_date = "2022-10-06", 
                      end_date = "2022-10-16", 
                      playerid = 547180, 
                      player_type = 'batter'))
#> ── MLB Baseball Savant Statcast Search data from baseballsavant.mlb.com 
#>  Data updated: 2026-06-12 14:10:06 UTC
#> # A tibble: 82 × 118
#>    pitch_type game_date  release_speed release_pos_x release_pos_z
#>    <chr>      <date>             <dbl>         <dbl>         <dbl>
#>  1 FF         2022-10-15          96.4         -2.61          5.49
#>  2 CU         2022-10-15          83.3         -2.7           5.36
#>  3 FF         2022-10-15          96.2         -2.72          5.57
#>  4 FF         2022-10-15          96.1         -2.67          5.39
#>  5 FF         2022-10-15          95.8         -2.62          5.45
#>  6 FC         2022-10-15          93.4         -1.05          6.88
#>  7 FC         2022-10-15          93.1         -1.16          6.87
#>  8 FC         2022-10-15          92.3         -1.1           6.86
#>  9 FF         2022-10-15          95.8         -1.47          5.64
#> 10 FC         2022-10-15          91           -2.09          5.64
#> # ℹ 72 more rows
#> # ℹ 113 more variables: player_name <chr>, batter <dbl>, pitcher <dbl>,
#> #   events <chr>, description <chr>, spin_dir <lgl>,
#> #   spin_rate_deprecated <lgl>, break_angle_deprecated <lgl>,
#> #   break_length_deprecated <lgl>, zone <dbl>, des <chr>,
#> #   game_type <chr>, stand <chr>, p_throws <chr>, home_team <chr>,
#> #   away_team <chr>, type <chr>, hit_location <int>, bb_type <chr>, …
  ### Framber
  try(statcast_search(start_date = "2022-10-06", 
                      end_date = "2022-10-16", 
                      playerid = 664285, 
                      player_type = 'pitcher'))
#> ── MLB Baseball Savant Statcast Search data from baseballsavant.mlb.com 
#>  Data updated: 2026-06-12 14:10:06 UTC
#> # A tibble: 92 × 118
#>    pitch_type game_date  release_speed release_pos_x release_pos_z
#>    <chr>      <date>             <dbl>         <dbl>         <dbl>
#>  1 CU         2022-10-13          78.1          1.09          6.06
#>  2 SI         2022-10-13          94.7          0.86          6.15
#>  3 CU         2022-10-13          79.4          0.95          6.02
#>  4 CU         2022-10-13          79.1          1.04          6.19
#>  5 CU         2022-10-13          81.4          0.93          6.06
#>  6 CU         2022-10-13          80.6          1.03          6.05
#>  7 SI         2022-10-13          95.4          0.71          6.19
#>  8 CU         2022-10-13          80.6          0.86          6.11
#>  9 CH         2022-10-13          91.6          0.73          6.19
#> 10 CU         2022-10-13          81            0.84          6.13
#> # ℹ 82 more rows
#> # ℹ 113 more variables: player_name <chr>, batter <dbl>, pitcher <dbl>,
#> #   events <chr>, description <chr>, spin_dir <lgl>,
#> #   spin_rate_deprecated <lgl>, break_angle_deprecated <lgl>,
#> #   break_length_deprecated <lgl>, zone <dbl>, des <chr>,
#> #   game_type <chr>, stand <chr>, p_throws <chr>, home_team <chr>,
#> #   away_team <chr>, type <chr>, hit_location <int>, bb_type <chr>, …
  ### Daily
  try(statcast_search(start_date = "2022-11-04", 
                      end_date = "2022-11-06"))
#> ── MLB Baseball Savant Statcast Search data from baseballsavant.mlb.com 
#>  Data updated: 2026-06-12 14:10:06 UTC
#> # A tibble: 250 × 118
#>    pitch_type game_date  release_speed release_pos_x release_pos_z
#>    <chr>      <date>             <dbl>         <dbl>         <dbl>
#>  1 CU         2022-11-05          80.8          1.01          6.1 
#>  2 SL         2022-11-05          85.3          0.96          6.13
#>  3 SI         2022-11-05          95.7          0.73          6.3 
#>  4 SL         2022-11-05          84.5          1.09          6.04
#>  5 CU         2022-11-05          79.1          0.99          6.2 
#>  6 CH         2022-11-05          87.5          1.04          6.16
#>  7 SI         2022-11-05          94.3          0.99          6.26
#>  8 CU         2022-11-05          78.9          1.09          6.13
#>  9 CU         2022-11-05          81.1          1.25          6.18
#> 10 SI         2022-11-05          95.7          0.62          6.34
#> # ℹ 240 more rows
#> # ℹ 113 more variables: player_name <chr>, batter <dbl>, pitcher <dbl>,
#> #   events <chr>, description <chr>, spin_dir <lgl>,
#> #   spin_rate_deprecated <lgl>, break_angle_deprecated <lgl>,
#> #   break_length_deprecated <lgl>, zone <dbl>, des <chr>,
#> #   game_type <chr>, stand <chr>, p_throws <chr>, home_team <chr>,
#> #   away_team <chr>, type <chr>, hit_location <int>, bb_type <chr>, …
# }
# \donttest{
  try({
    correa <- statcast_search_batters(start_date = "2016-04-06",
      end_date = "2016-04-15", batterid = 621043)
    daily <- statcast_search_batters(start_date = "2016-04-06",
      end_date = "2016-04-06", batterid = NULL)
  })
# }
# \donttest{
  try({
    x <- statcast_search_pitchers(start_date = "2016-04-06",
      end_date = "2016-04-15", pitcherid = 592789)
    daily <- statcast_search_pitchers(start_date = "2016-04-06",
      end_date = "2016-04-06", pitcherid = NULL)
  })
# }