Skip to main content

NBA — ESPN web API (v3)

sportsdataverse.nba — 5 endpoints.

espn_nba_player_overview​

ESPN endpoint.

Endpoint URL: GET https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/{athlete_id}/overview

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/4239/overview

API ParameterPythonPatternRequiredNullableDescription
athlete_idathlete_idYathlete_id path parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
athlete_idintegerUnique athlete identifier (ESPN).
athlete_display_namecharacterAthlete display name (full).
athlete_short_namecharacterAthlete short display name.
athlete_positioncharacterAthlete position.
athlete_jerseycharacterAthlete jersey number.
athlete_team_idinteger
athlete_team_abbreviationcharacter
split_namecharacterSplit name (typically "All Splits").
split_categorycharacter
games_playedcharacterGames played.
avg_minutescharacter
field_goal_pctcharacterField goal percentage (0-1).
three_point_pctcharacter
free_throw_pctcharacterFree throw percentage (0-1).
avg_reboundscharacter
avg_assistscharacter
avg_blockscharacter
avg_stealscharacter
avg_foulscharacter
avg_turnoverscharacter
avg_pointscharacter

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

espn_nba_player_overview(athlete_id='4239')

espn_nba_player_stats_v3​

ESPN endpoint.

Endpoint URL: GET https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/{athlete_id}/stats

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/4239/stats

API ParameterPythonPatternRequiredNullableDescription
athlete_idathlete_idYathlete_id path parameter.
seasonseasonYSeason year (e.g. 2024).

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
categorycharacterESPN stat category the row belongs to (e.g., basketball "averages" / "totals" / "miscellaneous", NFL "passing", MLB "career-batting"). The stat columns after position are named from each category's own names list, so they differ by sport, and the other categories' columns are null on a row.
split_namecharacterSeason label of the row (e.g., "2010-11") on the Web v3 payload, or "Career" on the row built from the category's career totals; the split's name on payloads that ship named splits.
split_categorycharacterCategory of a named split; null on the Web v3 per-season rows.
split_valuecharacterValue of a named split; null on the Web v3 per-season rows.
seasonintegerSeason end year of the row (e.g., 2011 for 2010-11); null on the "Career" row.
team_idintegerESPN team id (Int64) the athlete played that season for; a traded player has one row per team. Null on the "Career" row.
positioncharacterPosition abbreviation the athlete was listed at for that season and team (e.g., "G"); null on the "Career" row.
games_playedcharacterGames played (GP), as ESPN ships it (a string).
games_startedcharacterGames started (GS).
avg_minutescharacterMinutes per game (MIN).
avg_field_goals_made_avg_field_goals_attemptedcharacterField goals made-attempted per game (FG), one "made-attempted" string (e.g., "3.9-9.0").
field_goal_pctcharacterField goal percentage (FG%), FGM / FGA x 100.
avg_three_point_field_goals_made_avg_three_point_field_goals_attemptedcharacterThree-point field goals made-attempted per game (3PT), one "made-attempted" string.
three_point_field_goal_pctcharacterThree-point field goal percentage (3P%), 3PM / 3PA x 100.
avg_free_throws_made_avg_free_throws_attemptedcharacterFree throws made-attempted per game (FT), one "made-attempted" string.
free_throw_pctcharacterFree throw percentage (FT%), FTM / FTA x 100.
avg_offensive_reboundscharacterOffensive rebounds per game (OR).
avg_defensive_reboundscharacterDefensive rebounds per game (DR).
avg_reboundscharacterRebounds per game (REB).
avg_assistscharacterAssists per game (AST).
avg_blockscharacterBlocks per game (BLK).
avg_stealscharacterSteals per game (STL).
avg_foulscharacterPersonal fouls per game (PF).
avg_turnoverscharacterTurnovers per game (TO).
avg_pointscharacterPoints per game (PTS).
field_goals_made_field_goals_attemptedcharacterSeason field goals made-attempted (FG), one "made-attempted" string.
three_point_field_goals_made_three_point_field_goals_attemptedcharacterSeason three-point field goals made-attempted (3PT), one "made-attempted" string.
free_throws_made_free_throws_attemptedcharacterSeason free throws made-attempted (FT), one "made-attempted" string.
offensive_reboundscharacterSeason offensive rebounds (OR).
defensive_reboundscharacterSeason defensive rebounds (DR).
total_reboundscharacterSeason rebounds (REB).
assistscharacterSeason assists (AST).
blockscharacterSeason blocked shots (BLK).
stealscharacterSeason steals (STL).
foulscharacterSeason personal fouls (PF).
turnoverscharacterSeason turnovers (TO).
pointscharacterSeason points (PTS).
double_doublecharacterGames with double figures in two of points, rebounds, assists, steals and blocks (DD2).
triple_doublecharacterGames with double figures in three of points, rebounds, assists, steals and blocks (TD3).
disqualificationscharacterTimes the athlete fouled out (DQ).
ejectionscharacterTimes the athlete was ejected (EJECT).
technical_foulscharacterTechnical fouls called on the athlete (TECH).
flagrant_foulscharacterFlagrant fouls called on the athlete (FLAG).
assist_turnover_ratiocharacterAssists per turnover (AST/TO).
steal_turnover_ratiocharacterSteals per turnover (STL/TO).
scoring_efficiencycharacterESPN's scoring efficiency (SC-EFF).
shooting_efficiencycharacterESPN's shooting efficiency (SH-EFF).

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

espn_nba_player_stats_v3(athlete_id='4239')

espn_nba_player_gamelog​

ESPN endpoint.

Endpoint URL: GET https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/{athlete_id}/gamelog

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/4239/gamelog

API ParameterPythonPatternRequiredNullableDescription
athlete_idathlete_idYathlete_id path parameter.
seasonseasonYSeason year (e.g. 2024).

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
season_type_idintegerUnique identifier for season type.
season_type_namecharacterSeason type name.
categorycharacterCategory label.
event_idintegerUnique event / game identifier (ESPN).
event_datecharacter
home_awaycharacterGame venue label ('home' or 'away').
scorecharacterFinal score.
opponent_idintegerUnique identifier for opponent.
opponent_abbreviationcharacter
opponent_display_namecharacter
game_resultcharacter
game_processedcharacter
stat_0character
stat_1character
stat_2character
stat_3character
stat_4character
stat_5character
stat_6character
stat_7character
stat_8character
stat_9character
stat_10character
stat_11character
stat_12character
stat_13character

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

espn_nba_player_gamelog(athlete_id='4239')

espn_nba_player_splits​

ESPN endpoint.

Endpoint URL: GET https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/{athlete_id}/splits

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/athletes/4239/splits

API ParameterPythonPatternRequiredNullableDescription
athlete_idathlete_idYathlete_id path parameter.
seasonseasonYSeason year (e.g. 2024).

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
descriptionscharacter
display_namecharacterDisplay name.
display_namescharacter
filterscharacter
labelscharacter
namescharacterNames.
split_categoriescharacter

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

espn_nba_player_splits(athlete_id='4239')

espn_nba_leaders​

ESPN endpoint.

Endpoint URL: GET https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/statistics/byathlete

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/basketball/nba/statistics/byathlete?limit=50&page=1

API ParameterPythonPatternRequiredNullableDescription
categorycategoryYLeaderboard population: the athletes ranked in that category, whose values it fills (other categories come back null). Football takes <group>:<category> (offense:passing, offense:rushing, offense:receiving, defense:defensive, scoring:scoring); a bare passing is rejected with HTTP 400 (ValueError). Basketball takes the bare name (offensive).
seasonseasonYSeason year (e.g. 2024).
seasontypeseason_typeYSeason phase: 1=preseason, 2=regular season, 3=postseason.
limitlimitYMaximum number of items to return.
pagepageYpage query parameter.
sortsortYSort key <category>.<statName>:<asc|desc>, the names in the payload's categories (passing.passingYards:desc, offensive.avgPoints:desc). A stat without its category is rejected with HTTP 400 (ValueError).

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
sort_orderintegerPosition of the athlete in ESPN's leaderboard order (the requested category or sort), counted across pages: (page - 1) * limit + position on the page. A position, not a rank: tied athletes still count up; ESPN's per-stat ranks stay in the raw payload (return_parsed=False).
athlete_idintegerESPN id of the athlete, the key the athlete endpoints (athlete_overview, athlete_stats) take.
athlete_uidcharacterESPN composite athlete uid (s:<sport>~l:<league>~a:<athlete id>), kept as text.
athlete_display_namecharacterAthlete's full display name.
athlete_short_namecharacterAthlete's abbreviated name (e.g. 'B. Nix').
athlete_first_namecharacterAthlete's first name.
athlete_last_namecharacterAthlete's last name.
athlete_positioncharacterAthlete's position abbreviation (e.g. QB, G, C).
athlete_statuscharacterAthlete's ESPN status name (e.g. Active, Inactive) as ESPN reports it at request time, not for the requested season.
team_idintegerESPN id of the team the athlete played for in the requested season.
team_abbreviationcharacterAbbreviation of the athlete's team in the requested season (ESPN teamShortName, e.g. ORE).
team_namecharacterNickname of the athlete's team in the requested season (ESPN teamName, e.g. Ducks).
general_games_playeddoubleGames Played (ESPN 'general' category).
general_avg_minutesdoubleMinutes Per Game (ESPN 'general' category): The average number of minutes per game.
general_avg_foulsdoubleFouls Per Game (ESPN 'general' category): The average fouls committed per game.
general_flagrant_foulsdoubleFlagrant Fouls (ESPN 'general' category): The number of fouls that the officials thought were unnecessary or excessive.
general_technical_foulsdoubleTechnical Fouls (ESPN 'general' category): The number of times an player or coach was called for a technical foul (unsportsmanlike conduct or violations).
general_ejectionsdoubleEjections (ESPN 'general' category): The number of times a player or coach is removed from the game as a result of a serious offense.
general_double_doubledoubleDouble Double (ESPN 'general' category): The number of times double digit values were accumulated in 2 of the following categories: points, rebounds, assists, steals, and blocked shots.
general_triple_doubledoubleTriple Double (ESPN 'general' category): The number of times double digit values were accumulated in 3 of the following categories: points, rebounds, assists, steals, and blocked shots.
general_minutesdoubleMinutes (ESPN 'general' category): The total number of minutes played.
general_reboundsdoubleRebounds (ESPN 'general' category): The total number of rebounds (offensive and defensive).
general_foulsdoubleFouls (ESPN 'general' category): The number of times a player had illegal contact with the opponent.
general_avg_reboundsdoubleRebounds Per Game (ESPN 'general' category): The average rebounds per game.
offensive_avg_pointsdoublePoints Per Game (ESPN 'offensive' category): The average number of points scored per game.
offensive_avg_field_goals_madedoubleAverage Field Goals Made (ESPN 'offensive' category): The average field goals made per game.
offensive_avg_field_goals_attempteddoubleAverage Field Goals Attempted (ESPN 'offensive' category): The average field goals attempted per game.
offensive_field_goal_pctdoubleField Goal Percentage (ESPN 'offensive' category): The ratio of field goals made to field goals attempted: FGM / FGA.
offensive_avg_three_point_field_goals_madedoubleAverage 3-Point Field Goals Made (ESPN 'offensive' category): The average three point field goals made per game.
offensive_avg_three_point_field_goals_attempteddoubleAverage 3-Point Field Goals Attempted (ESPN 'offensive' category): The average three point field goals attempted per game.
offensive_three_point_field_goal_pctdouble3-Point Field Goal Percentage (ESPN 'offensive' category): The ratio of 3pt field goals made to 3pt field goals attempted: 3PM / 3PA.
offensive_avg_free_throws_madedoubleAverage Free Throws Made (ESPN 'offensive' category): The average free throw shots made per game.
offensive_avg_free_throws_attempteddoubleAverage Free Throws Attempted (ESPN 'offensive' category): The average free throw shots attempted per game.
offensive_free_throw_pctdoubleFree Throw Percentage (ESPN 'offensive' category): The ratio of free throws made to free throws attempted: FTM / FTA.
offensive_avg_assistsdoubleAssists Per Game (ESPN 'offensive' category): The average assists per game.
offensive_avg_turnoversdoubleTurnovers Per Game (ESPN 'offensive' category): The average turnovers committed per game.
offensive_pointsdoublePoints (ESPN 'Points', offensive category): points scored in basketball; goals plus assists in hockey.
offensive_field_goals_madedoubleField Goals Made (ESPN 'offensive' category): The number of times a 2pt field goal was made.
offensive_field_goals_attempteddoubleField Goals Attempted (ESPN 'offensive' category): The number of times a 2pt field goal was attempted.
offensive_three_point_field_goals_madedouble3-Point Field Goals Made (ESPN 'offensive' category): The number of times a 3pt field goal was made.
offensive_three_point_field_goals_attempteddouble3-Point Field Goals Attempted (ESPN 'offensive' category): The number of times a 3pt field goal was attempted.
offensive_free_throws_madedoubleFree Throws Made (ESPN 'offensive' category): The number of times a free throw was made.
offensive_free_throws_attempteddoubleFree Throws Attempted (ESPN 'offensive' category): The number of times a free throw was attempted.
offensive_assistsdoubleAssists (ESPN 'Assists', offensive category): passes that lead directly to a score in basketball; goal assists in hockey.
offensive_turnoversdoubleTurnovers (ESPN 'offensive' category): The number of times a player loses possession to the other team.
defensive_avg_stealsdoubleSteals Per Game (ESPN 'defensive' category): The average steals per game.
defensive_avg_blocksdoubleBlocks Per Game (ESPN 'defensive' category): The average blocks per game.
defensive_stealsdoubleSteals (ESPN 'defensive' category): The number of times a defensive player forced a turnover by intercepting or deflecting a pass or a dribble of an offensive player.
defensive_blocksdoubleBlocks (ESPN 'defensive' category): Short for blocked shot, number of times when a defensive player legally deflects a field goal attempt from an offensive player.

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

espn_nba_leaders()