Skip to main content
Version: 0.1.5

NBA — additional Python functions

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

Highlights​

FunctionSummary
bref_players_statsPlayer season statistics for an entire league season.
bref_standingsConference standings for a season, both conferences stacked.
bref_teams_statsTeam season statistics from the league season page.
compile_nba_seasonCompile a full season's possession stint matrix (cached + resumable + throttled).
espn_nba_player_statsPull an NBA athlete's ESPN season stat line as one wide row.
espn_nba_scheduleespn_nba_schedule - look up the NBA schedule for a given date from ESPN
espn_nba_teamsespn_nba_teams - look up NBA teams
most_recent_nba_seasonReturn the most recent NBA season year based on today's date.

ESPN​

FunctionSummary
espn_nba_game_rostersespn_nba_game_rosters() - Pull the game by id.
espn_nba_pbpespn_nba_pbp() - Pull the game by id - Data from API endpoints - nba/playbyplay, nba/summary
scoreboard_event_parsingInternal helper that flattens an ESPN NBA scoreboard event dict into a

sportsdataverse-data releases​

FunctionSummary
load_nba_stats_leaguedashLoad one asset family of the nba_stats_leaguedash release.

NBA Stats API​

FunctionSummary
nba_live_boxscoreFetch and parse NBA cdn.nba.com liveData boxscore for a game.
nba_live_pbpFetch and parse NBA cdn.nba.com liveData play-by-play for a game.

Fox Sports API​

FunctionSummary
fox_nba_boxscoreNBA boxscore (long: one row per player-stat).
fox_nba_event_matchupFox Sports nba pregame team-stat comparison (one row per stat).
fox_nba_event_recapFox Sports nba postgame top performers (one row per player).
fox_nba_event_standingsFox Sports nba the two teams' standings context.
fox_nba_league_conferencesFox Sports nba conference / group directory.
fox_nba_league_headerFox Sports nba league header (one row).
fox_nba_league_leadersNBA statistical leaders (stats-con); who=player|team.
fox_nba_league_oddsFox Sports nba league odds board (one row per team per game).
fox_nba_league_player_newsFox Sports nba league-wide player news feed.
fox_nba_league_pollsFox Sports nba rankings / polls rendered as standings tables.
fox_nba_league_scheduleFox Sports nba league schedule nav selections.
fox_nba_league_scoresFox Sports nba league scores nav selections.
fox_nba_league_standingsFox Sports nba league-wide standings tables.
fox_nba_league_stat_leadersFox Sports nba league stats landing leaders.
fox_nba_oddsNBA game odds six-pack (spread / to-win / total per team).
fox_nba_pbpNBA play-by-play (one row per play; period-based).
fox_nba_scoreboardFox Sports nba scoreboard nav selections (weeks / dates / groups).
fox_nba_scorechipFox Sports nba compact live score chip (raw dict -- live-only, uncaptured shape).
fox_nba_scores_segmentFox Sports nba one row per game in a scoreboard segment.
fox_nba_standingsNBA standings for a team's conference/division.
fox_nba_team_gamelogNBA team game log (long: one row per game-stat).
fox_nba_team_headerFox Sports nba team header (one row).
fox_nba_team_rosterNBA team roster (one row per player).
fox_nba_team_statsNBA team stat leaders by category.
fox_nba_teamnavFox Sports nba team directory (one row per team).
fox_nba_teamsNBA team directory (fox_team_id / fox_team_name / fox_section).

Basketball-Reference​

FunctionSummary
bref_awardsEnd-of-season award voting, all awards stacked into one frame.
bref_draftNBA draft results with each pick's career totals and advanced metrics.
bref_injuriesThe current NBA injury report.
bref_player_biosThe player index for one last-name initial -- bios plus the id slugs.
bref_player_game_logA player's regular-season game-by-game log.
bref_team_rosterA team's roster for one season.

RealGM​

FunctionSummary
realgm_close_browserClose the cached headless browser, if one is open.
realgm_coachesCurrent NBA head coaches.
realgm_draftResults of one past NBA draft.
realgm_draft_prospectsCurrent NBA draft-prospect statistics.
realgm_early_entryThe current NBA draft early-entrant and withdrawal list.
realgm_future_free_agentsRealGM's projected future NBA free-agent classes, with each player's agent.
realgm_gmsCurrent NBA general managers.
realgm_individual_gamesThe all-time best individual NBA games leaderboard.
realgm_individual_seasonsThe all-time best individual NBA seasons leaderboard.
realgm_player_statsSeason player-statistics leaderboard for one stat family and season segment.
realgm_playersThe active NBA player index from RealGM.
realgm_players_abroadNBA-affiliated players currently playing overseas.
realgm_rookie_scaleThe current NBA rookie-scale salary table.
realgm_salary_capNBA salary-cap history and projections.
realgm_standingsCurrent NBA standings, both conferences stacked.
realgm_team_statsSeason team statistics for one stat family and season segment.
realgm_teamsThe NBA team index with division and conference.
realgm_transactionsThe NBA league transactions log.

Public model datasets​

FunctionSummary
load_darko_dpmParse a DARKO DPM leaderboard CSV (e.g. 2026-darko-dpm-leaderboard.csv).
load_dunks_threes_statsParse a Dunks & Threes counting-stats CSV (e.g. 2025_Dunks_&_Threes_Stats.csv).
load_epmParse a Dunks & Threes EPM CSV ({season}_EPM_data.csv).
load_lebron_dailyParse a LEBRON daily-snapshot CSV (e.g. lebron_daily_2026-07-02.csv).
load_lebron_seasonParse a LEBRON season-file CSV (e.g. lebron-data-2026.csv).
load_rapm_ryan_davisParse a Ryan Davis published RAPM CSV (single-season or multi-year window).
normalize_player_nameFold a player display name to a join-safe key.

Play-by-play processing​

FunctionSummary
build_athlete_identity_lookupR build_athlete_identity_lookup: athlete_id -> identity from team rosters.
build_nba_player_identity_lookupR build_identity_lookup(season): athlete_id -> identity from the
nba_pbp_diskLoad a previously cached ESPN NBA summary JSON for a game from disk.
nba_v3_to_v2_pbpConvert a v3 playbyplayv3 payload into the full v2-schema pbp frame.

Models and calculators​

FunctionSummary
AdjRapmModelPrior-informed RAPM: ridge toward a per-player box prior with an RTO posterior.
AgingCurveEmpirical aging deltas: delta_by_age[a] = expected rating change aging a -> a+1.
ExternalValidityResultConcurrent-validity correlation of model ratings against a published oracle metric.
ForecastResultForecast-accuracy metrics: predicted-vs-actual next-season rating over held-out transitions.
LeagueConstantsPer-league_id fitted constants for the NBA prediction & market stack.
MeasureSpecPer-model column map for a leaguedashptstats measure.
NbaBpmModelA RatingsModel scoring a fold via faithful BPM 2.0.
NbaSpmModelA RatingsModel that scores a fold via fitted SPM coefficients.
RidgeRapmModel5179.47467923, 13894.95494373, 37275.93720315, 100000. ])) -> 'None'`
SpmCoefficientsFitted SPM coefficients (box features -> offense/defense RAPM, per-100).
ValidationReportHolds all oracle results for a single model evaluation run.
WalkForwardResultOracle 6: walk-forward ("predict tomorrow") retrodiction over a season timeline.
adjust_efficiencyIterative opponent-adjusted rating -> AdjOffRtg / AdjDefRtg / AdjNet per team-season.
adjust_paceOpponent-adjusted pace (possessions/game) per team-season.
as_of_ratings_splitFilter a results frame to games strictly before a cutoff date (leakage boundary).
calibrate_pts_per_winRegress team wins on season point margin; return points-per-marginal-win.
calibrate_replacement_levelSolve for the replacement_level that makes summed league WAR hit a target.
darko_forecast_accuracyHoldout forecast accuracy: for each transition, forecast N+1 from history <= N vs actual.
decay_weightsExponential time-decay sample weights w = 0.5 ** (days_ago / half_life).
expected_possessionsExpected possessions for a matchup (Pythagorean-tempo blend).
external_validityOracle 5: correlate a model's ratings against a published external metric.
fit_aging_curveFit the aging curve by the delta method: avg YoY rating change grouped by starting age.
get_constantsReturn the LeagueConstants for a league_id.
get_shrinkage_kShooter-talent shrinkage k for a league.
in_game_featuresPer-play in-game win-probability features from a load_nba_pbp frame.
luck_adjusted_responseAttach a per-possession la_points expected-points response.
nba_adj_rapm5179.47467923, 13894.95494373, 37275.93720315, 100000. ]), n_samples: 'int' = 200, seed: 'int' = 0, return_as_pandas: 'bool' = False) -> …
nba_aging_curveLoad the bundled per-age value-multiplier curve.
nba_bpmFaithful BPM 2.0 per player, at season or single-game granularity.
nba_career_trajectoryAge-adjust player-season values with the bundled aging curve.
nba_darkoProject each player's next-season rating via a per-player Kalman filter + aging curve.
nba_decay_rapmTime-decay RAPM: ridge weighted by 0.5 ** (days_ago / half_life_days).
nba_draft_modelProject prospect career value + draft probability from combine measurements.
nba_expected_turnoversExpected TOV + residual ball-security skill from Synergy play-type mix.
nba_four_factor_rapmFour-factor RAPM: four independent ridge fits (efg/ftr/orbd/tov) on the SAME design.
nba_in_game_win_probPer-play home win probability from the bundled in-game model.
nba_la_rapmLuck-adjusted RAPM: ridge on an expected-points response (high-variance shooting regressed).
nba_matchup_drapmMatchup-based defensive RAPM (offense-quality-controlled).
nba_predict_gamesVectorized pregame predictions for a schedule of games.
nba_rookie_projectionProject rookie/sophomore value by composing draft x aging x availability.
nba_spmApply fitted SPM coefficients to per-100 box features -> OSPM/DSPM/SPM.
nba_team_ratingsOpponent-adjusted team ratings (AdjOffRtg/AdjDefRtg/AdjNet/AdjPace), as-of-date aware.
nba_warPoints-above-replacement -> wins for each player.
predict_marginExpected home-minus-away margin from two adjusted net ratings.
predict_totalExpected total points from adjusted ratings and paces.
raw_game_efficiencyPer-team, per-game possessions + raw offensive/defensive rating.
render_reportRender a ValidationReport as a human-readable markdown validation card.
train_spmRidge-fit box features onto o_rapm and d_rapm (two regressions).
validate_modelRun the selected oracles and assemble a ValidationReport.
walk_forwardOracle 6: time-ordered "predict tomorrow" retrodiction.
win_prob_from_marginHome win probability from an expected margin (normal-CDF closed form).

Analytics​

FunctionSummary
add_ctg_shot_zonesAppend CTG's shot-location zone (ctg_shot_zone) to an enhanced PBP frame.
add_play_contextBuild possessions and enrich them with the full CTG play-context surface.
add_start_type_detailAppend the full pbpstats start-type taxonomy to a possession frame.
add_transitionFlag possessions that started in transition, and time their initial play.
box_featuresAggregate per-player per-100-possession box features over a set of games.
build_play_context_shotsBuild the per-shot frame carrying CTG's play context.
build_possession_shootingBuild the per-shooter companion frame from an enhanced play-by-play DataFrame.
clutch_deltaClutch net-rating delta vs a full-game baseline, per (season, team_id).
flag_garbage_timeFlag CTG garbage time (excluded from CTG stats by default).
flag_heave_possessionsFlag CTG's "projected heave possessions" (excluded from CTG stats by default).
hoopshype_salariesLeague-wide NBA player salaries from HoopsHype.
lineup_play_contextRoll possessions up into a per-5-man-lineup Play-Context table.
make_prob_by_contextMarginal FG% tables by defender distance and by shot clock.
make_prob_jointIndependence-combined defender x shot-clock make probability.
nba_availabilityProject games-available % for a season (or seasons) from career GP history.
nba_box_logsFetch per-player and per-team game logs for a season (bulk, one call each).
nba_foul_drawingExpected FTA + residual foul-drawing skill from Synergy play-type mix.
nba_l2mFetch and parse an NBA Last Two Minute report from official.nba.com.
nba_l2m_gamesFetch the list of games with Last Two Minute reports for an NBA season.
nba_play_contextFetch one game and return its possessions with the full CTG play-context surface.
nba_player_agesPer-player age for a season (bulk), for the DARKO aging curve.
nba_player_identityHuman-readable identity for every player in a season's box logs.
nba_player_positionsFetch league-wide listed positions for a season as numeric 1-5.
nba_player_propsPer-player expected prop lines + team pace projection for a matchup.
nba_playtype_ratingsSeason play-type-adjusted offensive/defensive team ratings.
nba_ratings_panelPlayer-ratings-through-date long panel: one row per (player_id, date).
nba_raw_store_season_frameRead a committed SEASON-LEVEL capture from the raw store, parsed to a frame.
nba_referee_assignmentsFetch and parse NBA referee assignments for a given date from official.nba.com.
nba_shot_valueOne-call shot-value spine: fetch, score, and run all five models.
nba_shot_value_lineupsScored per-shot frame for one 5-man lineup (shotchartlineupdetail).
nba_team_clutchOpponent-agnostic clutch skill (shrunk clutch net-rating delta) per team.
nba_tracking_drive_valueDrive value over expected + rim-pressure, per player-season.
nba_tracking_pass_valueExpected-assists / passer value: ast_oe per player-season.
nba_tracking_reb_oeRebounding-over-expected: reb_oe plus OREB/DREB splits, per player-season.
nba_tracking_rim_protect_valueRim-protection / shot-defend points-saved over expected, per player-season.
nba_tracking_shot_diet_valueCatch-&-shoot vs pull-up points-over-expected, per player-season.
nba_tracking_touch_valueTouch / possession-time value over expected, per player-season.
nbadraft_mock_draftThe current consensus mock draft from NBADraft.net.
player_play_contextPer-player offensive On/Off Play-Context table (CTG's On/Off page, offense half).
player_ratesPer-player per-minute rate stats from box logs.
players_on_court_from_pbpReconstruct the 5-on-5 on-court lineup from pbp subs + boxscore starters.
players_on_court_from_quarter_boxscoresReconstruct the 5-on-5 on-court lineup, seeding each period exactly where possible.
players_on_court_from_rotationReconstruct the 5-on-5 on-court lineup via the rotation (gamerotation) algorithm.
prob_overProbability a stat finishes strictly above line.
project_player_lineProject a player's expected counting line from per-minute rates.
prop_distributionDistribution family + parameters for a projected stat mean.
ratings_as_ofFit model on every possession dated on or before asof and return ratings.
rotowire_injuriesThe current NBA injury report from RotoWire.
score_shot_xpointsScore each shot with expected points from the league-average baseline.
shooter_talentRegressed shooter true-talent: make%-above-expected, shrunk to the mean.
shot_selection_qualityPlayer shot-selection quality: mean expected value vs the league mean.
shrink_clutchEmpirical-Bayes / James-Stein shrinkage of clutch_delta toward zero.
spotrac_team_capTeam salary-cap allocations from Spotrac.
starters_on_court_countsCount, per possession, how many starters are on the floor across BOTH teams.
team_pace_projectionExpected possessions for a matchup (Phase-3 expected_possessions).
team_play_contextRoll possessions up into CTG's team Play-Context table.
xpoints_baselineLeague-average FG% baseline table keyed by the three shot-zone columns.
zone_value_mapPer-player per-zone value map: points and expected points per shot.

Dates and seasons​

FunctionSummary
year_to_seasonConvert a season START year (e.g. 2023) to the NBA's hyphenated label

IDs and crosswalks​

FunctionSummary
nba_player_crosswalkBuild the NBA cross-source player crosswalk (ESPN / NBA Stats / Fox).
nba_schedule_crosswalkBuild the NBA cross-source schedule crosswalk (ESPN / NBA Stats).
nba_team_crosswalkBuild the NBA cross-source team crosswalk (ESPN / NBA Stats / Fox).