Skip to main content

NHL — ESPN web API (v3)

sportsdataverse.nhl — 5 endpoints.

espn_nhl_player_overview​

ESPN endpoint.

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

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/hockey/nhl/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_idintegerESPN athlete identifier (echoed from arg).
athlete_display_namecharacterPlayer display name.
athlete_short_namecharacterPlayer short name.
athlete_positioncharacterPosition abbreviation.
athlete_jerseycharacterJersey number.
athlete_team_idintegerESPN team identifier.
athlete_team_abbreviationcharacterTeam abbreviation.
split_namecharacterSplit name (e.g. "All Splits").
split_categorycharacterSplit category name (e.g. split, location).
games_playedcharacterGames played.
avg_minutescharacter
field_goal_pctcharacter
three_point_pctcharacter
free_throw_pctcharacter
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_nhl_player_overview(athlete_id='4239')

espn_nhl_player_stats_v3​

ESPN endpoint.

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

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/hockey/nhl/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.

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_nhl_player_stats_v3(athlete_id='4239')

espn_nhl_player_gamelog​

ESPN endpoint.

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

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/hockey/nhl/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_idintegerSeason type id (1=pre, 2=reg, 3=post, 4=off).
season_type_namecharacter
categorycharacterStat leader category.
event_idintegerESPN event id (echoed from arg).
event_datecharacter
home_awaycharacterHome or away indicator.
scorecharacterFinal score string.
opponent_idintegerESPN opponent team identifier.
opponent_abbreviationcharacter
opponent_display_namecharacter
game_resultcharacterGame result for the player's team (W/L/OT).
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_nhl_player_gamelog(athlete_id='4239')

espn_nhl_player_splits​

ESPN endpoint.

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

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/hockey/nhl/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_namecharacterPlayer display name.
display_namescharacter
filterscharacter
labelscharacter
namescharacter
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_nhl_player_splits(athlete_id='4239')

espn_nhl_leaders​

ESPN endpoint.

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

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/hockey/nhl/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_gamesdoubleGames Played (ESPN 'general' category): Total games played.
general_plus_minusdoublePlus/Minus Rating (ESPN 'general' category).
general_time_on_ice_per_gamedoubleTime On Ice Per Game (ESPN 'general' category): Total time on ice per game.
general_shiftsdoubleShifts (ESPN 'general' category): Total shifts.
general_productiondoubleProduction (ESPN 'general' category): Total production.
general_winsdoubleWins (ESPN 'general' category).
general_lossesdoubleLosses (ESPN 'general' category).
general_time_on_icedoubleTime On Ice (ESPN 'general' category): Total time on ice.
offensive_goalsdoubleGoals (ESPN 'offensive' category): Total goals scored.
offensive_assistsdoubleAssists (ESPN 'Assists', offensive category): passes that lead directly to a score in basketball; goal assists in hockey.
offensive_pointsdoublePoints (ESPN 'Points', offensive category): points scored in basketball; goals plus assists in hockey.
offensive_power_play_goalsdoublePower Play Goals (ESPN 'offensive' category): Total power play goals.
offensive_power_play_assistsdoublePower Play Assists (ESPN 'offensive' category): Total power play assists.
offensive_shots_totaldoubleShots (ESPN 'offensive' category): Total shots.
offensive_shooting_pctdoubleShooting Percentage (ESPN 'offensive' category): Percentage of shots scored.
offensive_game_winning_goalsdoubleGame-Winning Goals (ESPN 'offensive' category): Total game-winning goals.
offensive_faceoffs_wondoubleFaceoffs Won (ESPN 'offensive' category): Total faceoffs won.
offensive_faceoffs_lostdoubleFaceoffs Lost (ESPN 'offensive' category): Total faceoffs lost.
offensive_faceoff_percentdoubleFaceoff Win Percent (ESPN 'offensive' category): Percentage of faceoffs won.
offensive_shootout_attemptsdoubleShootout Attempts (ESPN 'offensive' category): Total shootout attempts.
offensive_shootout_goalsdoubleShootout Goals (ESPN 'offensive' category): Total shootout goals.
offensive_shootout_shot_pctdoubleShootout Shot Percentage (ESPN 'offensive' category): Percentage of shootout goals made.
defensive_overtime_lossesdoubleOvertime Losses (ESPN 'defensive' category): Total games lost in overtime.
defensive_avg_goals_againstdoubleGoals Against Average (ESPN 'defensive' category).
defensive_shots_againstdoubleShots Against (ESPN 'defensive' category): Total shots against.
defensive_goals_againstdoubleGoals Against (ESPN 'defensive' category): Total goals against.
defensive_savesdoubleSaves (ESPN 'defensive' category): Total saves.
defensive_save_pctdoubleSave Percentage (ESPN 'defensive' category): Percentage of shots saved.
defensive_shootout_shots_againstdoubleShootout Shots Against (ESPN 'defensive' category): Total shootout shots against.
defensive_shootout_savesdoubleShootout Saves (ESPN 'defensive' category): Total shootout saves.
defensive_shootout_save_pctdoubleShootout Save Percentage (ESPN 'defensive' category): Percentage of shootout shots saved.
defensive_shutoutsdoubleShutouts (ESPN 'defensive' category): Total shutouts.
penalties_penalty_minutesdoublePenalty Minutes (ESPN 'penalties' category): Total penalty minutes.

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_nhl_leaders()