Skip to main content

MLB — additional Python functions — Baseball Savant (Statcast)

mlb_statcast_player​

mlb_statcast_player(player_id: 'int', stats: 'Optional[str]' = None, *, section: 'str' = 'statcast', raw: 'bool' = False, return_as_pandas: 'bool' = False, **kwargs: 'Any') -> "'Union[pl.DataFrame, pd.DataFrame, str]'"

GET /savant-player/{player_id} and parse one embedded table into a tidy frame.

Returns a tidy frame by default (the parsed Statcast page); pass raw=True to get the underlying HTML string instead (the page embeds ~12 other tables you can mine yourself, or feed to sportsdataverse.mlb.parse_mlb_statcast_player with a different section).

Parameters

ParameterTypeDefaultDescription
player_idintMLBAM player id (shared with the Stats API personId).
statsOptional[str]Noneoptional stats query value to scope the embedded payload.
sectionstr'statcast'which embedded serverVals table to flatten (default "statcast", the seasonal aggregate; e.g. "statcastGameLogs").
rawboolFalsereturn the raw page HTML string instead of a parsed frame.
return_as_pandasboolFalsereturn a pandas DataFrame instead of polars.

Returns

A polars (or pandas) DataFrame of the player's Statcast metrics by default (zero rows when the page/section is absent); the raw HTML str when raw=True.

col_nametypedescription
aggregateInt64Aggregate.
yearInt64Season year.
yearhiddenInt64Yearhidden.
player_idInt64MLBAM player id.
ageInt64Player age.
bat_sideStringBatter side (R/L/S).
pitch_handStringPitcher handedness (R/L).
monthStringMonth.
grouping_codeStringGrouping code.
grouping_catStringGrouping cat.
pitch_countInt64Pitch count.
in_zone_percentFloat64In zone rate.
out_zone_percentFloat64Out zone rate.
edge_percentFloat64Edge rate.
z_swing_percentFloat64Z swing rate.
oz_swing_percentFloat64Oz swing rate.
iz_contact_percentFloat64Iz contact rate.
oz_contact_percentFloat64Oz contact rate.
whiff_percentFloat64Whiff rate (swings and misses / swings).
f_strike_percentFloat64F strike rate.
f_swing_percentFloat64F swing rate.
swing_percentFloat64Swing rate.
meatball_swing_percentInt64Meatball swing rate.
meatball_percentFloat64Meatball rate.
z_swing_miss_percentFloat64Z swing miss rate.
oz_swing_miss_percentFloat64Oz swing miss rate.
in_zoneInt64In zone.
out_zoneInt64Out zone.
edgeInt64Edge.
popupsInt64Popups.
flyballsInt64Flyballs.
linedrivesInt64Linedrives.
groundballsInt64Groundballs.
airballsInt64Airballs.
popups_percentFloat64Popups rate.
flyballs_percentFloat64Flyballs rate.
linedrives_percentFloat64Linedrives rate.
groundballs_percentFloat64Groundballs rate.
airballs_percentFloat64Airballs rate.
pull_percentFloat64Pull rate.
straightaway_percentFloat64Straightaway rate.
opposite_percentFloat64Opposite rate.
pull_percent_airballsFloat64Pull percent airballs.
straightaway_percent_airballsFloat64Straightaway percent airballs.
opposite_percent_airballsInt64Opposite percent airballs.
pull_percent_groundballsFloat64Pull percent groundballs.
straightaway_percent_groundballsFloat64Straightaway percent groundballs.
opposite_percent_groundballsFloat64Opposite percent groundballs.
pull_percent_popupsFloat64Pull percent popups.
straightaway_percent_popupsFloat64Straightaway percent popups.
opposite_percent_popupsFloat64Opposite percent popups.
pull_percent_flyballsFloat64Pull percent flyballs.
straightaway_percent_flyballsFloat64Straightaway percent flyballs.
opposite_percent_flyballsFloat64Opposite percent flyballs.
pull_percent_linedrivesInt64Pull percent linedrives.
straightaway_percent_linedrivesInt64Straightaway percent linedrives.
opposite_percent_linedrivesInt64Opposite percent linedrives.
poorlyweak_percentInt64Poorlyweak rate.
poorlytopped_percentFloat64Poorlytopped rate.
poorlyunder_percentFloat64Poorlyunder rate.
flareburner_percentFloat64Flareburner rate.
solidcontact_percentFloat64Solidcontact rate.
hr_flyballs_percentFloat64Hr flyballs rate.
in_zone_swingInt64In zone swing.
out_zone_swingInt64Out zone swing.
in_zone_swing_missInt64In zone swing miss.
out_zone_swing_missInt64Out zone swing miss.
pitch_count_fastballInt64Pitch count fastball.
pitch_count_offspeedInt64Pitch count offspeed.
pitch_count_breakingInt64Pitch count breaking.
paInt64Plate appearances.
abInt64At-bats.
hitInt64Hit.
singleInt64Singles.
doubleInt64Doubles.
tripleInt64Triples.
home_runInt64Home run.
walkInt64Walk.
strikeoutInt64Strikeout.
hbpInt64Hbp.
k_percentFloat64Strikeout rate.
bb_percentFloat64Walk rate.
sz_judgeFloat64Sz judge.
batted_ballInt64Batted ball.
barrelInt64Barrel.
barrel_batted_rateFloat64Barrels per batted ball.
barrels_per_paFloat64Barrels per pa.
launch_angle_avgFloat64Launch angle avg.
exit_velocity_avgFloat64Exit velocity avg.
exit_velocity_maxFloat64Exit velocity max.
hard_hit_percentFloat64Hard-hit rate (95+ mph EV).
sweet_spot_percentFloat64Sweet-spot rate (8-32 deg launch angle).
baFloat64Batting average.
xbaFloat64Expected batting average.
baconFloat64Bacon.
xbaconFloat64Expected batting average on contact.
babipFloat64BABIP.
obpFloat64On-base percentage.
slgFloat64Slugging percentage.
xobpFloat64Expected on-base percentage.
xslgFloat64Expected slugging.
isoFloat64Isolated power.
xisoFloat64Expected isolated power.
wobaFloat64Weighted on-base average.
xwobaFloat64Expected wOBA.
wobaconFloat64Wobacon.
xwobaconFloat64Xwobacon.
xbadiffFloat64Xbadiff.
xslgdiffFloat64Xslgdiff.
wobadiffFloat64Wobadiff.
player_typeStringPlayer type.
eraStringEra.
xeraStringExpected ERA.
avg_hyper_speedFloat64Avg hyper speed.
avg_best_speedFloat64Avg best speed.
distance_hr_avgInt64Distance hr avg.
sprint_speedFloat64Sprint speed (ft/sec, top 50% of competitive runs).
pop_2bStringPop 2b.
arm_cs_2bStringArm cs 2b.
strike_rateStringCalled-strike rate.
outs_above_averageInt64Outs Above Average.
jump_v_avgInt64Jump v avg.
max_arm_strengthStringMax arm strength (mph).
arm_overallStringArm overall.
xhrFloat64Xhr.
swing_take_run_valueInt64Swing take run value.
blocks_above_averageStringBlocks above average.
cs_above_averageStringCs above average.
fastball_veloStringFastball velo.
fastball_spinStringFastball spin.
fastball_extensionStringFastball extension.
curveball_spinStringCurveball spin.
pitch_run_value_fastballFloat64Pitch run value fastball.
pitch_run_value_breakingFloat64Pitch run value breaking.
pitch_run_value_offspeedFloat64Pitch run value offspeed.
group_fastball_veloFloat64Group fastball velo.
group_breaking_veloFloat64Group breaking velo.
group_offspeed_veloFloat64Group offspeed velo.
pitch_usage_fastballFloat64Pitch usage fastball.
pitch_usage_breakingFloat64Pitch usage breaking.
pitch_usage_offspeedFloat64Pitch usage offspeed.
fielding_run_valueInt64Fielding run value.
runner_run_valueInt64Runner run value.
fielding_run_value_armInt64Fielding run value arm.
fielding_run_value_framingStringFielding run value framing.
runner_runs_sbInt64Runner runs sb.
runner_runs_xbInt64Runner runs xb.
net_bases_runnerInt64Net bases runner.
net_bases_pitcherStringNet bases pitcher.
fast_swing_rateStringFast-swing rate (>=75 mph).
squared_up_contactStringSquared up contact.
squared_up_swingStringSquared up swing.
blasts_contactStringBlasts contact.
blasts_swingStringBlasts swing.
swordsStringSwords.
avg_swing_speedStringAvg swing speed.
avg_swing_lengthStringAvg swing length.
attack_angleStringAttack angle (deg, bat path at contact).
vertical_swing_pathStringVertical swing path.
accelerationStringAcceleration.
horizontal_swing_pathStringHorizontal swing path.
attack_directionStringAttack direction (deg, pull/oppo).
ideal_angle_rateStringIdeal angle rate.
n_squared_upStringNumber of squared up.
n_blastsStringNumber of blasts.
arm_angleStringArm angle.
is_qualifiedInt64Is qualified.
percent_rank_barrel_unroundedStringPercent rank barrel unrounded.
percent_rank_barrel_batted_rate_unroundedStringPercent rank barrel batted rate unrounded.
percent_rank_exit_velocity_avg_unroundedStringPercent rank exit velocity avg unrounded.
percent_rank_exit_velocity_max_unroundedFloat64Percent rank exit velocity max unrounded.
percent_rank_launch_angle_avg_unroundedStringPercent rank launch angle avg unrounded.
percent_rank_xba_unroundedStringPercent rank xba unrounded.
percent_rank_xslg_unroundedStringPercent rank xslg unrounded.
percent_rank_xwoba_unroundedStringPercent rank xwoba unrounded.
percent_rank_woba_unroundedStringPercent rank woba unrounded.
percent_rank_hard_hit_percent_unroundedStringPercent rank hard hit percent unrounded.
percent_rank_xwobacon_unroundedStringPercent rank xwobacon unrounded.
percent_rank_wobacon_unroundedStringPercent rank wobacon unrounded.
percent_rank_k_percent_unroundedStringPercent rank k percent unrounded.
percent_rank_bb_percent_unroundedStringPercent rank bb percent unrounded.
percent_rank_sz_judge_unroundedStringPercent rank sz judge unrounded.
percent_rank_whiff_percent_unroundedStringPercent rank whiff percent unrounded.
percent_rank_chase_percent_unroundedStringPercent rank chase percent unrounded.
percent_rank_ba_unroundedStringPercent rank ba unrounded.
percent_rank_bacon_unroundedStringPercent rank bacon unrounded.
percent_rank_xbacon_unroundedStringPercent rank xbacon unrounded.
percent_rank_babip_unroundedStringPercent rank babip unrounded.
percent_rank_obp_unroundedStringPercent rank obp unrounded.
percent_rank_slg_unroundedStringPercent rank slg unrounded.
percent_rank_xobp_unroundedStringPercent rank xobp unrounded.
percent_rank_iso_unroundedStringPercent rank iso unrounded.
percent_rank_xiso_unroundedStringPercent rank xiso unrounded.
percent_rank_sweet_spot_percent_unroundedStringPercent rank sweet spot percent unrounded.
percent_rank_distance_hr_avg_unroundedStringPercent rank distance hr avg unrounded.
percent_rank_groundballs_percent_unroundedStringPercent rank groundballs percent unrounded.
percent_rank_airballs_percent_unroundedStringPercent rank airballs percent unrounded.
percent_rank_avg_hyper_speed_unroundedStringPercent rank avg hyper speed unrounded.
percent_rank_avg_best_speed_unroundedStringPercent rank avg best speed unrounded.
percent_rank_pitch_run_value_fastball_unroundedStringPercent rank pitch run value fastball unrounded.
percent_rank_pitch_run_value_breaking_unroundedStringPercent rank pitch run value breaking unrounded.
percent_rank_pitch_run_value_offspeed_unroundedStringPercent rank pitch run value offspeed unrounded.
percent_rank_barrelStringPercent rank barrel.
percent_rank_barrel_batted_rateStringPercent rank barrel batted rate.
percent_rank_exit_velocity_avgStringPercent rank exit velocity avg.
percent_rank_exit_velocity_maxInt64Percent rank exit velocity max.
percent_rank_launch_angle_avgStringPercent rank launch angle avg.
percent_rank_xbaStringPercent rank xba.
percent_rank_xslgStringPercent rank xslg.
percent_rank_xwobaStringPercent rank xwoba.
percent_rank_wobaStringPercent rank woba.
percent_rank_hard_hit_percentStringPercent rank hard hit rate.
percent_rank_xwobaconStringPercent rank xwobacon.
percent_rank_wobaconStringPercent rank wobacon.
percent_rank_k_percentStringPercent rank k rate.
percent_rank_bb_percentStringPercent rank bb rate.
percent_rank_sz_judgeStringPercent rank sz judge.
percent_rank_whiff_percentStringPercent rank whiff rate.
percent_rank_chase_percentStringPercent rank chase rate.
percent_rank_baStringPercent rank ba.
percent_rank_baconStringPercent rank bacon.
percent_rank_xbaconStringPercent rank xbacon.
percent_rank_babipStringPercent rank babip.
percent_rank_obpStringPercent rank obp.
percent_rank_slgStringPercent rank slg.
percent_rank_xobpStringPercent rank xobp.
percent_rank_isoStringPercent rank iso.
percent_rank_xisoStringPercent rank xiso.
percent_rank_sweet_spot_percentStringPercent rank sweet spot rate.
percent_rank_distance_hr_avgStringPercent rank distance hr avg.
percent_rank_groundballs_percentStringPercent rank groundballs rate.
percent_rank_airballs_percentStringPercent rank airballs rate.
percent_rank_avg_hyper_speedStringPercent rank avg hyper speed.
percent_rank_avg_best_speedStringPercent rank avg best speed.
percent_rank_pitch_run_value_fastballStringPercent rank pitch run value fastball.
percent_rank_pitch_run_value_breakingStringPercent rank pitch run value breaking.
percent_rank_pitch_run_value_offspeedStringPercent rank pitch run value offspeed.
percent_speed_orderInt64Percent speed order.
percent_rank_speed_orderInt64Percent rank speed order.
percent_rank_pop_2bStringPercent rank pop 2b.
percent_rank_arm_cs_2bStringPercent rank arm cs 2b.
percent_rank_oaaStringPercent rank oaa.
percent_rank_framingStringPercent rank framing.
percent_rank_jumpStringPercent rank jump.
percent_rank_fastball_veloStringPercent rank fastball velo.
percent_rank_fastball_spinStringPercent rank fastball spin.
percent_rank_fastball_extensionStringPercent rank fastball extension.
percent_rank_cu_spinStringPercent rank cu spin.
percent_rank_xeraStringPercent rank xera.
percent_rank_arm_maxStringPercent rank arm max.
percent_rank_arm_overallStringPercent rank arm overall.
percent_rank_xhrStringPercent rank xhr.
percent_rank_swing_take_run_valueStringPercent rank swing take run value.
percent_rank_blocks_above_averageStringPercent rank blocks above average.
percent_rank_cs_above_averageStringPercent rank cs above average.
percent_rank_fielding_run_valueStringPercent rank fielding run value.
percent_rank_runner_run_valueStringPercent rank runner run value.
percent_rank_fielding_run_value_armStringPercent rank fielding run value arm.
percent_rank_fielding_run_value_framingStringPercent rank fielding run value framing.
percent_rank_swing_speedStringPercent rank swing speed.
percent_rank_swing_lengthStringPercent rank swing length.
percent_rank_squared_up_swingStringPercent rank squared up swing.
percent_rank_attack_angleStringPercent rank attack angle.
percent_rank_vertical_swing_pathStringPercent rank vertical swing path.
percent_rank_accelerationStringPercent rank acceleration.
percent_rank_ideal_angle_rateStringPercent rank ideal angle rate.

Example

from sportsdataverse.mlb import mlb_statcast_player
df = mlb_statcast_player(592450)
html = mlb_statcast_player(592450, raw=True)

mlb_statcast_search(start_dt: 'str', end_dt: 'str', *, player_type: 'str' = 'batter', chunk_days: 'int' = 7, return_as_pandas: 'bool' = False, **filters: 'Any') -> "'Union[pl.DataFrame, pd.DataFrame]'"

Pitch-by-pitch MLB Statcast search (/statcast_search/csv), date-chunked.

A window starting before STATCAST_SEARCH_FLOOR (2008-03-25, the first PITCHf/x regular-season day) is clamped to the floor with a UserWarning; Savant answers earlier dates with empty CSVs, which used to come back as a silent zero-row frame.

Savant caps a single /statcast_search/csv response at 25,000 rows with no pagination. This splits the date range into chunk_days windows, halving any window that hits the cap, and stitches the chunks back together.

Parameters

ParameterTypeDefaultDescription
start_dtstr
end_dtstr
player_typestr'batter'"batter" (default) or "pitcher".
chunk_daysint7initial window size in days.
return_as_pandasboolFalsereturn a pandas DataFrame instead of polars.

Returns

A polars (or pandas) DataFrame, one row per pitch. A window with no games returns zero rows with the documented columns and dtypes (MLBAM ids Int64), so it stacks onto a populated one with either relaxed concat.

col_nametypedescription
pitch_typeStringAbbreviation of the pitch type thrown (e.g. FF, SL, CH).
game_dateStringGame date (YYYY-MM-DD).
release_speedFloat64Pitch velocity out of the hand (mph).
release_pos_xFloat64Horizontal release position of the ball, catcher's perspective (feet).
release_pos_zFloat64Vertical release position of the ball, catcher's perspective (feet).
player_nameStringName of the player_type-side player, Last, First -- the batter under the default player_type="batter", the pitcher under player_type="pitcher".
batterInt64MLBAM player id of the batter.
pitcherInt64MLBAM player id of the pitcher.
eventsStringNested list of non-game events.
descriptionStringLong-form description text.
spin_dirFloat64Deprecated spin direction field, no longer populated.
spin_rate_deprecatedFloat64Deprecated legacy spin-rate field, no longer populated.
break_angle_deprecatedFloat64Deprecated legacy break-angle field, no longer populated.
break_length_deprecatedFloat64Deprecated legacy break-length field, no longer populated.
zoneInt64Strike-zone region the pitch crossed (1-14 Gameday zone).
desStringFull text description of the play.
game_typeStringGame type code (R, P, etc.).
standStringSide of the plate the batter is standing (L or R).
p_throwsStringHand the pitcher throws with (L or R).
home_teamStringHome team name.
away_teamStringAway team name.
typeStringRecord type / category.
hit_locationFloat64Fielder position number that fielded the ball.
bb_typeStringBatted-ball type (ground_ball, line_drive, fly_ball, popup).
ballsInt64Ball count before the pitch.
strikesInt64Strike count before the pitch.
game_yearInt64Season year of the game.
pfx_xFloat64Horizontal pitch movement from the catcher's perspective (feet).
pfx_zFloat64Vertical pitch movement from the catcher's perspective (feet).
plate_xFloat64Horizontal position of the pitch crossing the plate (feet from center).
plate_zFloat64Vertical position of the pitch crossing the plate (feet above ground).
on_3bInt64MLBAM ID of the runner on third base, if any.
on_2bInt64MLBAM ID of the runner on second base, if any.
on_1bInt64MLBAM ID of the runner on first base, if any.
outs_when_upInt64Number of outs when the batter came to the plate.
inningInt64Inning number.
inning_topbotStringHalf of the inning (Top or Bot).
hc_xFloat64Hit coordinate X on the field diagram.
hc_yFloat64Hit coordinate Y on the field diagram.
tfs_deprecatedFloat64Deprecated time-from-start field, no longer populated.
tfs_zulu_deprecatedFloat64Deprecated Zulu time-from-start field, no longer populated.
umpireFloat64Deprecated umpire field, no longer populated.
sv_idFloat64Deprecated Sportvision/Statcast pitch identifier, no longer populated.
vx0Float64Velocity of the pitch in the x-direction at y=50 ft (ft/s).
vy0Float64Velocity of the pitch in the y-direction at y=50 ft (ft/s).
vz0Float64Velocity of the pitch in the z-direction at y=50 ft (ft/s).
axFloat64Acceleration of the pitch in the x-direction at y=50 ft (ft/s^2).
ayFloat64Acceleration of the pitch in the y-direction at y=50 ft (ft/s^2).
azFloat64Acceleration of the pitch in the z-direction at y=50 ft (ft/s^2).
sz_topFloat64Top of the batter's strike zone for the pitch (feet).
sz_botFloat64Bottom of the batter's strike zone for the pitch (feet).
hit_distance_scFloat64Statcast-measured projected distance of the batted ball (feet).
launch_speedFloat64Exit velocity of the batted ball (mph).
launch_angleFloat64Vertical launch angle of the batted ball (degrees).
effective_speedFloat64Perceived velocity adjusted for release extension (mph).
release_spin_rateInt64Spin rate of the pitch at release (rpm).
release_extensionFloat64Distance toward the plate at release (feet).
game_pkInt64Unique game identifier.
fielder_2Int64MLBAM ID of the catcher.
fielder_3Int64MLBAM ID of the first baseman.
fielder_4Int64MLBAM ID of the second baseman.
fielder_5Int64MLBAM ID of the third baseman.
fielder_6Int64MLBAM ID of the shortstop.
fielder_7Int64MLBAM ID of the left fielder.
fielder_8Int64MLBAM ID of the center fielder.
fielder_9Int64MLBAM ID of the right fielder.
release_pos_yFloat64Release position of the ball toward the plate (feet).
estimated_ba_using_speedangleFloat64Expected batting average based on exit velocity and launch angle.
estimated_woba_using_speedangleFloat64Expected wOBA based on exit velocity and launch angle.
woba_valueFloat64wOBA value assigned to the event.
woba_denomFloat64wOBA denominator (plate-appearance weight) for the event.
babip_valueFloat64BABIP value assigned to the event (0 or 1).
iso_valueFloat64Isolated power value assigned to the event.
launch_speed_angleFloat64Batted-ball classification code (1-6) from exit velocity and angle.
at_bat_numberInt64Sequential plate-appearance number within the game.
pitch_numberInt64Pitch number within the plate appearance.
pitch_nameStringFull name of the pitch type (e.g. 4-Seam Fastball, Slider).
home_scoreInt64Home team score before the pitch (see post_home_score).
away_scoreInt64Away team score before the pitch (see post_away_score).
bat_scoreInt64Batting team score before the pitch.
fld_scoreInt64Fielding team score before the pitch.
post_away_scoreInt64Away team score after the pitch.
post_home_scoreInt64Home team score after the pitch.
post_bat_scoreInt64Batting team score after the pitch.
post_fld_scoreInt64Fielding team score after the pitch.
if_fielding_alignmentStringInfield defensive alignment (Standard, Strategic, Infield shift).
of_fielding_alignmentStringOutfield defensive alignment (Standard, Strategic, 4th outfielder).
spin_axisInt64Spin axis of the pitch as a clock-face angle (degrees).
delta_home_win_expFloat64Change in home team win expectancy on the play.
delta_run_expFloat64Change in run expectancy on the play.
bat_speedFloat64Bat speed at the point of contact (mph).
swing_lengthFloat64Length of the swing path to contact (feet).
miss_distanceFloat64Distance between the bat and the ball on a swing-and-miss, in inches (Savant bat-tracking field); populated only on swinging-strike pitches and null on every other pitch.
estimated_slg_using_speedangleFloat64Expected slugging based on exit velocity and launch angle.
delta_pitcher_run_expFloat64Change in run expectancy credited to the pitcher.
hyper_speedFloat64Adjusted (90th-percentile) exit velocity (mph).
home_score_diffInt64Home team score minus away team score before the pitch.
bat_score_diffInt64Batting team score minus fielding team score before the pitch.
home_win_expFloat64Home team win expectancy before the play.
bat_win_expFloat64Batting team win expectancy before the play.
age_pit_legacyInt64Pitcher age using the legacy calculation.
age_bat_legacyInt64Batter age using the legacy calculation.
age_pitInt64Pitcher age for the season.
age_batInt64Batter age for the season.
n_thruorder_pitcherInt64Times through the order the pitcher is facing the lineup.
n_priorpa_thisgame_player_at_batInt64Number of prior plate appearances by the batter in the game.
pitcher_days_since_prev_gameInt64Days since the pitcher's previous game appearance.
batter_days_since_prev_gameInt64Days since the batter's previous game appearance.
pitcher_days_until_next_gameInt64Days until the pitcher's next game appearance.
batter_days_until_next_gameInt64Days until the batter's next game appearance.
api_break_z_with_gravityFloat64Vertical pitch break including gravity (inches).
api_break_x_armFloat64Horizontal pitch break to the pitcher's arm side (inches).
api_break_x_batter_inFloat64Horizontal pitch break toward/away from the batter (inches).
arm_angleFloat64Pitcher's arm angle at release (degrees).
attack_angleFloat64Angle of the bat's path at contact (degrees).
attack_directionFloat64Horizontal direction of the swing at contact (degrees).
swing_path_tiltFloat64Vertical tilt of the swing path (degrees).
intercept_ball_minus_batter_pos_x_inchesFloat64Horizontal offset of ball-bat intercept from batter position (inches).
intercept_ball_minus_batter_pos_y_inchesFloat64Depth offset of ball-bat intercept from batter position (inches).

Raises

ExceptionDescription
AssetFetchErrorWhen Savant answers an error status for a chunk after download's retries, or a 200 body that is not a Statcast CSV (an HTML or error page); an outage is never reported as an empty window.

Example

from sportsdataverse.mlb import mlb_statcast_search
df = mlb_statcast_search("2024-06-15", "2024-06-16", batters_lookup=592450)

mlb_statcast_search_minors​

mlb_statcast_search_minors(start_dt: 'str', end_dt: 'str', *, player_type: 'str' = 'batter', chunk_days: 'int' = 7, return_as_pandas: 'bool' = False, **filters: 'Any') -> "'Union[pl.DataFrame, pd.DataFrame]'"

Minor-league Statcast search (/statcast-search-minors/csv), date-chunked.

Same shape, columns, and 25,000-row chunking as mlb_statcast_search, against the MiLB CSV route with Savant's minors=true&wbc=false population flags sent for you (the route path alone returns MLB games). The route pins those two flags and overrides a minors=/wbc= passed through **filters; every other filter rides along. Narrow further with hfLevel ("AAA|", "AA|", "A+|", "A|") and hfSea filters.

Parameters

ParameterTypeDefaultDescription
start_dtstr
end_dtstr
player_typestr'batter'"batter" (default) or "pitcher".
chunk_daysint7initial window size in days.
return_as_pandasboolFalsereturn a pandas DataFrame instead of polars.

Returns

A polars (or pandas) DataFrame, one row per minor-league pitch. A window with no games returns zero rows with the documented columns and dtypes (MLBAM ids Int64), so it stacks onto a populated one with either relaxed concat.

col_nametypedescription
pitch_typeStringAbbreviation of the pitch type thrown (e.g. FF, SL, CH).
game_dateStringGame date (YYYY-MM-DD).
release_speedFloat64Pitch velocity out of the hand (mph).
release_pos_xFloat64Horizontal release position of the ball, catcher's perspective (feet).
release_pos_zFloat64Vertical release position of the ball, catcher's perspective (feet).
player_nameStringName of the player_type-side player, Last, First -- the batter under the default player_type="batter", the pitcher under player_type="pitcher".
batterInt64MLBAM player id of the batter.
pitcherInt64MLBAM player id of the pitcher.
eventsStringNested list of non-game events.
descriptionStringLong-form description text.
spin_dirFloat64Deprecated spin direction field, no longer populated.
spin_rate_deprecatedFloat64Deprecated legacy spin-rate field, no longer populated.
break_angle_deprecatedFloat64Deprecated legacy break-angle field, no longer populated.
break_length_deprecatedFloat64Deprecated legacy break-length field, no longer populated.
zoneInt64Strike-zone region the pitch crossed (1-14 Gameday zone).
desStringFull text description of the play.
game_typeStringGame type code (R, P, etc.).
standStringSide of the plate the batter is standing (L or R).
p_throwsStringHand the pitcher throws with (L or R).
home_teamStringHome team name.
away_teamStringAway team name.
typeStringRecord type / category.
hit_locationFloat64Fielder position number that fielded the ball.
bb_typeStringBatted-ball type (ground_ball, line_drive, fly_ball, popup).
ballsInt64Ball count before the pitch.
strikesInt64Strike count before the pitch.
game_yearInt64Season year of the game.
pfx_xFloat64Horizontal pitch movement from the catcher's perspective (feet).
pfx_zFloat64Vertical pitch movement from the catcher's perspective (feet).
plate_xFloat64Horizontal position of the pitch crossing the plate (feet from center).
plate_zFloat64Vertical position of the pitch crossing the plate (feet above ground).
on_3bInt64MLBAM ID of the runner on third base, if any.
on_2bInt64MLBAM ID of the runner on second base, if any.
on_1bInt64MLBAM ID of the runner on first base, if any.
outs_when_upInt64Number of outs when the batter came to the plate.
inningInt64Inning number.
inning_topbotStringHalf of the inning (Top or Bot).
hc_xFloat64Hit coordinate X on the field diagram.
hc_yFloat64Hit coordinate Y on the field diagram.
tfs_deprecatedFloat64Deprecated time-from-start field, no longer populated.
tfs_zulu_deprecatedFloat64Deprecated Zulu time-from-start field, no longer populated.
umpireFloat64Deprecated umpire field, no longer populated.
sv_idFloat64Deprecated Sportvision/Statcast pitch identifier, no longer populated.
vx0Float64Velocity of the pitch in the x-direction at y=50 ft (ft/s).
vy0Float64Velocity of the pitch in the y-direction at y=50 ft (ft/s).
vz0Float64Velocity of the pitch in the z-direction at y=50 ft (ft/s).
axFloat64Acceleration of the pitch in the x-direction at y=50 ft (ft/s^2).
ayFloat64Acceleration of the pitch in the y-direction at y=50 ft (ft/s^2).
azFloat64Acceleration of the pitch in the z-direction at y=50 ft (ft/s^2).
sz_topFloat64Top of the batter's strike zone for the pitch (feet).
sz_botFloat64Bottom of the batter's strike zone for the pitch (feet).
hit_distance_scFloat64Statcast-measured projected distance of the batted ball (feet).
launch_speedFloat64Exit velocity of the batted ball (mph).
launch_angleFloat64Vertical launch angle of the batted ball (degrees).
effective_speedFloat64Perceived velocity adjusted for release extension (mph).
release_spin_rateInt64Spin rate of the pitch at release (rpm).
release_extensionFloat64Distance toward the plate at release (feet).
game_pkInt64Unique game identifier.
fielder_2Int64MLBAM ID of the catcher.
fielder_3Int64MLBAM ID of the first baseman.
fielder_4Int64MLBAM ID of the second baseman.
fielder_5Int64MLBAM ID of the third baseman.
fielder_6Int64MLBAM ID of the shortstop.
fielder_7Int64MLBAM ID of the left fielder.
fielder_8Int64MLBAM ID of the center fielder.
fielder_9Int64MLBAM ID of the right fielder.
release_pos_yFloat64Release position of the ball toward the plate (feet).
estimated_ba_using_speedangleFloat64Expected batting average based on exit velocity and launch angle.
estimated_woba_using_speedangleFloat64Expected wOBA based on exit velocity and launch angle.
woba_valueFloat64wOBA value assigned to the event.
woba_denomFloat64wOBA denominator (plate-appearance weight) for the event.
babip_valueFloat64BABIP value assigned to the event (0 or 1).
iso_valueFloat64Isolated power value assigned to the event.
launch_speed_angleFloat64Batted-ball classification code (1-6) from exit velocity and angle.
at_bat_numberInt64Sequential plate-appearance number within the game.
pitch_numberInt64Pitch number within the plate appearance.
pitch_nameStringFull name of the pitch type (e.g. 4-Seam Fastball, Slider).
home_scoreInt64Home team score before the pitch (see post_home_score).
away_scoreInt64Away team score before the pitch (see post_away_score).
bat_scoreInt64Batting team score before the pitch.
fld_scoreInt64Fielding team score before the pitch.
post_away_scoreInt64Away team score after the pitch.
post_home_scoreInt64Home team score after the pitch.
post_bat_scoreInt64Batting team score after the pitch.
post_fld_scoreInt64Fielding team score after the pitch.
if_fielding_alignmentStringInfield defensive alignment (Standard, Strategic, Infield shift).
of_fielding_alignmentStringOutfield defensive alignment (Standard, Strategic, 4th outfielder).
spin_axisInt64Spin axis of the pitch as a clock-face angle (degrees).
delta_home_win_expFloat64Change in home team win expectancy on the play.
delta_run_expFloat64Change in run expectancy on the play.
bat_speedFloat64Bat speed at the point of contact (mph).
swing_lengthFloat64Length of the swing path to contact (feet).
miss_distanceFloat64Distance between the bat and the ball on a swing-and-miss, in inches (Savant bat-tracking field); null on pitches without a tracked swing-and-miss (about 90% of sampled rows).
estimated_slg_using_speedangleFloat64Expected slugging based on exit velocity and launch angle.
delta_pitcher_run_expFloat64Change in run expectancy credited to the pitcher.
hyper_speedFloat64Adjusted (90th-percentile) exit velocity (mph).
home_score_diffInt64Home team score minus away team score before the pitch.
bat_score_diffInt64Batting team score minus fielding team score before the pitch.
home_win_expFloat64Home team win expectancy before the play.
bat_win_expFloat64Batting team win expectancy before the play.
age_pit_legacyInt64Pitcher age using the legacy calculation.
age_bat_legacyInt64Batter age using the legacy calculation.
age_pitInt64Pitcher age for the season.
age_batInt64Batter age for the season.
n_thruorder_pitcherInt64Times through the order the pitcher is facing the lineup.
n_priorpa_thisgame_player_at_batInt64Number of prior plate appearances by the batter in the game.
pitcher_days_since_prev_gameInt64Days since the pitcher's previous game appearance.
batter_days_since_prev_gameInt64Days since the batter's previous game appearance.
pitcher_days_until_next_gameInt64Days until the pitcher's next game appearance.
batter_days_until_next_gameInt64Days until the batter's next game appearance.
api_break_z_with_gravityFloat64Vertical pitch break including gravity (inches).
api_break_x_armFloat64Horizontal pitch break to the pitcher's arm side (inches).
api_break_x_batter_inFloat64Horizontal pitch break toward/away from the batter (inches).
arm_angleFloat64Pitcher's arm angle at release (degrees).
attack_angleFloat64Angle of the bat's path at contact (degrees).
attack_directionFloat64Horizontal direction of the swing at contact (degrees).
swing_path_tiltFloat64Vertical tilt of the swing path (degrees).
intercept_ball_minus_batter_pos_x_inchesFloat64Horizontal offset of ball-bat intercept from batter position (inches).
intercept_ball_minus_batter_pos_y_inchesFloat64Depth offset of ball-bat intercept from batter position (inches).

Raises

ExceptionDescription
AssetFetchErrorWhen Savant answers an error status for a chunk after download's retries, or a 200 body that is not a Statcast CSV (an HTML or error page); an outage is never reported as an empty window.

Example

from sportsdataverse.mlb import mlb_statcast_search_minors
df = mlb_statcast_search_minors("2024-06-01", "2024-06-02")

mlb_statcast_search_wbc​

mlb_statcast_search_wbc(start_dt: 'str', end_dt: 'str', *, player_type: 'str' = 'batter', chunk_days: 'int' = 7, return_as_pandas: 'bool' = False, **filters: 'Any') -> "'Union[pl.DataFrame, pd.DataFrame]'"

World Baseball Classic Statcast search (/statcast-search-world-baseball-classic/csv).

Same shape, columns, and 25,000-row chunking as mlb_statcast_search, against the WBC CSV route with Savant's minors=false&wbc=true population flags sent for you (the route path alone returns MLB spring training). The route pins those two flags and overrides a minors=/wbc= passed through **filters; every other filter rides along. Pass WBC date windows (e.g. March of a WBC year); game_type is the tournament round (F pool play, D quarterfinals, L semifinals, W championship).

Parameters

ParameterTypeDefaultDescription
start_dtstr
end_dtstr
player_typestr'batter'"batter" (default) or "pitcher".
chunk_daysint7initial window size in days.
return_as_pandasboolFalsereturn a pandas DataFrame instead of polars.

Returns

A polars (or pandas) DataFrame, one row per WBC pitch. A window with no games returns zero rows with the documented columns and dtypes (MLBAM ids Int64), so it stacks onto a populated one with either relaxed concat.

col_nametypedescription
pitch_typeStringAbbreviation of the pitch type thrown (e.g. FF, SL, CH).
game_dateStringGame date (YYYY-MM-DD).
release_speedFloat64Pitch velocity out of the hand (mph).
release_pos_xFloat64Horizontal release position of the ball, catcher's perspective (feet).
release_pos_zFloat64Vertical release position of the ball, catcher's perspective (feet).
player_nameStringName of the player_type-side player, Last, First -- the batter under the default player_type="batter", the pitcher under player_type="pitcher".
batterInt64MLBAM player id of the batter.
pitcherInt64MLBAM player id of the pitcher.
eventsStringNested list of non-game events.
descriptionStringLong-form description text.
spin_dirFloat64Deprecated spin direction field, no longer populated.
spin_rate_deprecatedFloat64Deprecated legacy spin-rate field, no longer populated.
break_angle_deprecatedFloat64Deprecated legacy break-angle field, no longer populated.
break_length_deprecatedFloat64Deprecated legacy break-length field, no longer populated.
zoneInt64Strike-zone region the pitch crossed (1-14 Gameday zone).
desStringFull text description of the play.
game_typeStringGame type code (R, P, etc.).
standStringSide of the plate the batter is standing (L or R).
p_throwsStringHand the pitcher throws with (L or R).
home_teamStringHome team name.
away_teamStringAway team name.
typeStringRecord type / category.
hit_locationFloat64Fielder position number that fielded the ball.
bb_typeStringBatted-ball type (ground_ball, line_drive, fly_ball, popup).
ballsInt64Ball count before the pitch.
strikesInt64Strike count before the pitch.
game_yearInt64Season year of the game.
pfx_xFloat64Horizontal pitch movement from the catcher's perspective (feet).
pfx_zFloat64Vertical pitch movement from the catcher's perspective (feet).
plate_xFloat64Horizontal position of the pitch crossing the plate (feet from center).
plate_zFloat64Vertical position of the pitch crossing the plate (feet above ground).
on_3bInt64MLBAM ID of the runner on third base, if any.
on_2bInt64MLBAM ID of the runner on second base, if any.
on_1bInt64MLBAM ID of the runner on first base, if any.
outs_when_upInt64Number of outs when the batter came to the plate.
inningInt64Inning number.
inning_topbotStringHalf of the inning (Top or Bot).
hc_xFloat64Hit coordinate X on the field diagram.
hc_yFloat64Hit coordinate Y on the field diagram.
tfs_deprecatedFloat64Deprecated time-from-start field, no longer populated.
tfs_zulu_deprecatedFloat64Deprecated Zulu time-from-start field, no longer populated.
umpireFloat64Deprecated umpire field, no longer populated.
sv_idFloat64Deprecated Sportvision/Statcast pitch identifier, no longer populated.
vx0Float64Velocity of the pitch in the x-direction at y=50 ft (ft/s).
vy0Float64Velocity of the pitch in the y-direction at y=50 ft (ft/s).
vz0Float64Velocity of the pitch in the z-direction at y=50 ft (ft/s).
axFloat64Acceleration of the pitch in the x-direction at y=50 ft (ft/s^2).
ayFloat64Acceleration of the pitch in the y-direction at y=50 ft (ft/s^2).
azFloat64Acceleration of the pitch in the z-direction at y=50 ft (ft/s^2).
sz_topFloat64Top of the batter's strike zone for the pitch (feet).
sz_botFloat64Bottom of the batter's strike zone for the pitch (feet).
hit_distance_scFloat64Statcast-measured projected distance of the batted ball (feet).
launch_speedFloat64Exit velocity of the batted ball (mph).
launch_angleFloat64Vertical launch angle of the batted ball (degrees).
effective_speedFloat64Perceived velocity adjusted for release extension (mph).
release_spin_rateInt64Spin rate of the pitch at release (rpm).
release_extensionFloat64Distance toward the plate at release (feet).
game_pkInt64Unique game identifier.
fielder_2Int64MLBAM ID of the catcher.
fielder_3Int64MLBAM ID of the first baseman.
fielder_4Int64MLBAM ID of the second baseman.
fielder_5Int64MLBAM ID of the third baseman.
fielder_6Int64MLBAM ID of the shortstop.
fielder_7Int64MLBAM ID of the left fielder.
fielder_8Int64MLBAM ID of the center fielder.
fielder_9Int64MLBAM ID of the right fielder.
release_pos_yFloat64Release position of the ball toward the plate (feet).
estimated_ba_using_speedangleFloat64Expected batting average based on exit velocity and launch angle.
estimated_woba_using_speedangleFloat64Expected wOBA based on exit velocity and launch angle.
woba_valueFloat64wOBA value assigned to the event.
woba_denomFloat64wOBA denominator (plate-appearance weight) for the event.
babip_valueFloat64BABIP value assigned to the event (0 or 1).
iso_valueFloat64Isolated power value assigned to the event.
launch_speed_angleFloat64Batted-ball classification code (1-6) from exit velocity and angle.
at_bat_numberInt64Sequential plate-appearance number within the game.
pitch_numberInt64Pitch number within the plate appearance.
pitch_nameStringFull name of the pitch type (e.g. 4-Seam Fastball, Slider).
home_scoreInt64Home team score before the pitch (see post_home_score).
away_scoreInt64Away team score before the pitch (see post_away_score).
bat_scoreInt64Batting team score before the pitch.
fld_scoreInt64Fielding team score before the pitch.
post_away_scoreInt64Away team score after the pitch.
post_home_scoreInt64Home team score after the pitch.
post_bat_scoreInt64Batting team score after the pitch.
post_fld_scoreInt64Fielding team score after the pitch.
if_fielding_alignmentStringInfield defensive alignment (Standard, Strategic, Infield shift).
of_fielding_alignmentStringOutfield defensive alignment (Standard, Strategic, 4th outfielder).
spin_axisInt64Spin axis of the pitch as a clock-face angle (degrees).
delta_home_win_expFloat64Change in home team win expectancy on the play.
delta_run_expFloat64Change in run expectancy on the play.
bat_speedFloat64Bat speed at the point of contact (mph).
swing_lengthFloat64Length of the swing path to contact (feet).
miss_distanceFloat64Distance between the bat and the ball on a swing-and-miss, in inches (Savant bat-tracking field); all null in the sampled WBC pitches (2023-03-08), and coverage for later WBC tournaments is unverified.
estimated_slg_using_speedangleFloat64Expected slugging based on exit velocity and launch angle.
delta_pitcher_run_expFloat64Change in run expectancy credited to the pitcher.
hyper_speedFloat64Adjusted (90th-percentile) exit velocity (mph).
home_score_diffInt64Home team score minus away team score before the pitch.
bat_score_diffInt64Batting team score minus fielding team score before the pitch.
home_win_expFloat64Home team win expectancy before the play.
bat_win_expFloat64Batting team win expectancy before the play.
age_pit_legacyInt64Pitcher age using the legacy calculation.
age_bat_legacyInt64Batter age using the legacy calculation.
age_pitInt64Pitcher age for the season.
age_batInt64Batter age for the season.
n_thruorder_pitcherInt64Times through the order the pitcher is facing the lineup.
n_priorpa_thisgame_player_at_batInt64Number of prior plate appearances by the batter in the game.
pitcher_days_since_prev_gameInt64Days since the pitcher's previous game appearance.
batter_days_since_prev_gameInt64Days since the batter's previous game appearance.
pitcher_days_until_next_gameInt64Days until the pitcher's next game appearance.
batter_days_until_next_gameInt64Days until the batter's next game appearance.
api_break_z_with_gravityFloat64Vertical pitch break including gravity (inches).
api_break_x_armFloat64Horizontal pitch break to the pitcher's arm side (inches).
api_break_x_batter_inFloat64Horizontal pitch break toward/away from the batter (inches).
arm_angleFloat64Pitcher's arm angle at release (degrees).
attack_angleFloat64Angle of the bat's path at contact (degrees).
attack_directionFloat64Horizontal direction of the swing at contact (degrees).
swing_path_tiltFloat64Vertical tilt of the swing path (degrees).
intercept_ball_minus_batter_pos_x_inchesFloat64Horizontal offset of ball-bat intercept from batter position (inches).
intercept_ball_minus_batter_pos_y_inchesFloat64Depth offset of ball-bat intercept from batter position (inches).

Raises

ExceptionDescription
AssetFetchErrorWhen Savant answers an error status for a chunk after download's retries, or a 200 body that is not a Statcast CSV (an HTML or error page); an outage is never reported as an empty window.

Example

from sportsdataverse.mlb import mlb_statcast_search_wbc
df = mlb_statcast_search_wbc("2023-03-08", "2023-03-22")