Skip to main content
Version: 0.1.5

MLB — additional Python functions

Hand-written wrappers, loaders, and helpers in sportsdataverse.mlb not covered by the generated API-endpoint reference above.

ESPN​

FunctionSummary
espn_mlb_game_rostersespn_mlb_game_rosters - pull the active game rosters for both teams.
espn_mlb_pbpespn_mlb_pbp - pull the full ESPN game-summary payload for one MLB game.
espn_mlb_player_statsPull an MLB athlete's ESPN season stat line as one wide row.
espn_mlb_scheduleespn_mlb_schedule - look up the MLB schedule for a given date or season-year.
espn_mlb_teamsespn_mlb_teams - look up MLB teams from ESPN's Site v2 API.

MLB Stats API​

FunctionSummary
mlb_attendanceGET /api/v1/attendance — game attendance figures.
mlb_divisionsGET /api/v1/divisions — list divisions.
mlb_draft_prospectsGET /api/v1/draft/prospects/{year} — draft prospect list for a year.
mlb_pbp_diffGET /api/v1/game/{gamePk}/feed/live/diffPatch — JSON-patch diff of the live feed.
mlb_pbp_liveGET /api/v1.1/game/{gamePk}/feed/live — live firehose (v1.1).
mlb_person_statsGET /api/v1/people/{personId}/stats — player aggregate stats.
mlb_scheduleGET /api/v1/schedule — schedule of games for a date, range, team, or season.
mlb_seasonsGET /api/v1/seasons — list of seasons for a sport.
mlb_standingsGET /api/v1/standings — league standings.
mlb_statsGET /api/v1/stats — generic stats query.
mlb_stats_leadersGET /api/v1/stats/leaders — top-N leaders for a stat category.
mlb_stats_streaksGET /api/v1/stats/streaks — active or historical streaks.
mlb_team_leadersGET /api/v1/teams/{teamId}/leaders — team leaders.
mlb_team_statsGET /api/v1/teams/{teamId}/stats — team-level stats.
mlb_teamsGET /api/v1/teams — list teams. sport_id=1 = MLB.

Baseball Savant (Statcast)​

FunctionSummary
mlb_statcast_playerGET /savant-player/{player_id} and parse one embedded table into a tidy frame.
mlb_statcast_searchPitch-by-pitch MLB Statcast search (/statcast_search/csv), date-chunked.
mlb_statcast_search_minorsMinor-league Statcast search (/statcast-search-minors/csv), date-chunked.
mlb_statcast_search_wbcWorld Baseball Classic Statcast search (/statcast-search-world-baseball-classic/csv).

Fox Sports API​

FunctionSummary
fox_mlb_event_matchupFox Sports mlb pregame team-stat comparison (one row per stat).
fox_mlb_event_recapFox Sports mlb postgame top performers (one row per player).
fox_mlb_event_standingsFox Sports mlb the two teams' standings context.
fox_mlb_league_conferencesFox Sports mlb conference / group directory.
fox_mlb_league_headerFox Sports mlb league header (one row).
fox_mlb_league_leadersMLB statistical leaders (stats-con); who=player|team.
fox_mlb_league_oddsFox Sports mlb league odds board (one row per team per game).
fox_mlb_league_player_newsFox Sports mlb league-wide player news feed.
fox_mlb_league_pollsFox Sports mlb rankings / polls rendered as standings tables.
fox_mlb_league_scheduleFox Sports mlb league schedule nav selections.
fox_mlb_league_scoresFox Sports mlb league scores nav selections.
fox_mlb_league_standingsFox Sports mlb league-wide standings tables.
fox_mlb_league_stat_leadersFox Sports mlb league stats landing leaders.
fox_mlb_oddsMLB game odds six-pack (run line / to-win / total per team).
fox_mlb_scoreboardFox Sports mlb scoreboard nav selections (weeks / dates / groups).
fox_mlb_scorechipFox Sports mlb compact live score chip (raw dict -- live-only, uncaptured shape).
fox_mlb_scores_segmentFox Sports mlb one row per game in a scoreboard segment.
fox_mlb_standingsMLB standings for a team's division/league.
fox_mlb_team_gamelogMLB team game log (long: one row per game-stat).
fox_mlb_team_headerFox Sports mlb team header (one row).
fox_mlb_team_rosterMLB team roster (one row per player).
fox_mlb_team_statsMLB team stat leaders by category.
fox_mlb_teamnavFox Sports mlb team directory (one row per team).

Models and calculators​

FunctionSummary
as_of_splitLeakage boundary: rows strictly before cutoff_date only.
build_we_tableEmpirical, Laplace-smoothed home win-expectancy table.
count_strike_run_valueBall-to-strike run-expectancy delta per count, from delta_run_exp.
event_run_valueEmpirical run value of an event set, from mean delta_run_exp.
maeMean absolute error between two arrays.
mlb_batter_projectionNext-season xwOBA projection (Marcel + delta-method aging) for every batter.
mlb_command_plusScore pitches with the bundled Command+/Location+ (②) run-value model.
mlb_expected_home_runsPer player-season park-neutral xHR, park-adjusted xHR, and HR-above-expected.
mlb_expected_statsPer player-season xwOBA/xBA/xSLG from an on-the-fly EV x LA empirical grid.
mlb_pitch_classifyPer-pitcher Gaussian-mixture pitch reclassification.
mlb_prop_strikeoutsExpected pitcher/team strikeouts via a K/9-and-opponent-K-rate blend.
mlb_prop_team_runsExpected team runs via a log5-style rate blend.
mlb_propsExpected team runs + strikeouts for a slate of matchups.
mlb_pythagenpatPythagenpat expected win percentage (Smyth-Patriot, run-environment adaptive exponent).
mlb_pythagenpat_tablePer-(season, team) pythagenpat table from game-level results.
mlb_run_expectancy_matrixEmpirical RE24 run-expectancy matrix by base-out state.
mlb_stuff_plusScore pitches with the bundled Stuff+ (①) run-value model.
mlb_swing_decisionPer player-season swing/take run value + selective-aggression (SEAGER analog).
mlb_team_eloAs-of-date iterative Elo run-differential rating.
mlb_team_projectionCombined pythagenpat + Elo team projection.
mlb_win_expectancyPer-play home win expectancy from the empirical state table.
mlb_win_probability_addedPer-play win-probability-added from a mlb_win_expectancy frame.
pbp_base_out_statesReconstruct pre-play base-out state from statsapi play-by-play.
pearson_corrPearson correlation coefficient between two 1-D arrays.
prop_over_probP(realized count > line) under a Poisson(expected) model.
spearman_corrSpearman rank correlation between two arrays.

Analytics​

FunctionSummary
add_sequence_featuresAdd within-game sequence, times-through-order, and workload features.
advancement_opportunitiesExtract first-to-third / second-to-home / tag-up opportunities and outcomes.
bip_trajectory_featuresAdd spray angle / hit distance / launch-angle bin / out label / position.
called_strike_prob_gridEmpirical called-strike-probability grid over (stand, plate_x, pz_norm).
catch_prob_surfaceEmpirical catch-probability surface over (position, distance, spray, launch angle).
fit_zone_modelFit a logistic P(called strike | zone coordinates) on called pitches.
mlb_baserunning_valuePer-runner baserunning runs from extra-bases-taken above expected.
mlb_catcher_blockingPer-catcher blocking runs from a dirt-pitch block-probability model.
mlb_catcher_framingPer-catcher framing runs from a smooth called-strike logistic (Savant method).
mlb_catcher_throwingPer-catcher caught-stealing (throwing) value = caught-stealing above average.
mlb_fielding_oaaPer-fielder outs above average from a per-position catch-probability logistic.
mlb_injury_riskComposite pitcher injury-risk index from leakage-safe trailing trends.
mlb_pitch_eraCombined xERA + SIERA-like estimator (model ③).
mlb_pitch_tunnelingPer-pitch release/plate distance from the previous pitch + tunnel ratio.
mlb_sequence_run_valueMean run value grouped by the ordered (prev_pitch_type, pitch_type) sequence.
mlb_stolen_base_valuePer-runner stolen-base run value: realized-vs-expected run contribution.
mlb_times_through_orderPer-pitch fitted times-through-order fatigue adjustment.
mlb_umpire_biasPer-umpire called-strike bias residual (observed minus expected).
mlb_umpire_called_strike_probP(called strike) per pitch from the zone logistic.
pitch_featuresBuild the per-pitch feature substrate every pitching model consumes.
pitcher_appearance_trendsLeakage-safe per-appearance trailing velocity/workload trends.
predict_sb_successAs-of-date predictive P(success): the surface is fit on history strictly before cutoff_date.
sb_attempts_from_pitchesExtract stolen-base / caught-stealing attempts from pitch-level Statcast rows.
sb_success_surfaceEmpirical P(stolen-base success) surface over (sprint speed, pop time, base).
siera_likeSIERA-like ERA estimator from K%/BB%/GB% (experimental / provisional).
tto_penalty_tableObserved mean run value by times-through-order, with the penalty vs TTO=1.

Dates and seasons​

FunctionSummary
most_recent_mlb_seasonmost_recent_mlb_season - return the most recent / current MLB season year.