Skip to main content
Version: 0.0.56

NHL — additional Python functions

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

Play-by-play, schedule & rosters

espn_nhl_game_rosters(game_id: 'int', raw=False, return_as_pandas=False, **kwargs) -> 'pl.DataFrame'

espn_nhl_game_rosters() - Pull the game by id.

Parameters

ParameterTypeDefaultDescription
game_idintUnique game_id, can be obtained from espn_nhl_schedule().
rawFalse
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.

Returns

Polars dataframe of game roster data with columns: 'athlete_id', 'athlete_uid', 'athlete_guid', 'athlete_type', 'first_name', 'last_name', 'full_name', 'athlete_display_name', 'short_name', 'weight', 'display_weight', 'height', 'display_height', 'age', 'date_of_birth', 'slug', 'jersey', 'linked', 'active', 'alternate_ids_sdr', 'birth_place_city', 'birth_place_state', 'birth_place_country', 'headshot_href', 'headshot_alt', 'experience_years', 'experience_display_value', 'experience_abbreviation', 'status_id', 'status_name', 'status_type', 'status_abbreviation', 'hand_type', 'hand_abbreviation', 'hand_display_value', 'draft_display_text', 'draft_round', 'draft_year', 'draft_selection', 'player_id', 'starter', 'valid', 'did_not_play', 'display_name', 'ejected', 'athlete_href', 'position_href', 'statistics_href', 'team_id', 'team_guid', 'team_uid', 'team_slug', 'team_location', 'team_name', 'team_abbreviation', 'team_display_name', 'team_short_display_name', 'team_color', 'team_alternate_color', 'is_active', 'is_all_star', 'logo_href', 'logo_dark_href', 'game_id'

col_nametypedescription
athlete_idintegerESPN athlete identifier (echoed from arg).
athlete_uidcharacterESPN athlete UID (universal identifier).
athlete_guidcharacterESPN athlete GUID.
athlete_typecharacterAthlete type / class.
alternate_idcharacterAlternate player identifier.
first_namecharacterPlayer first name.
last_namecharacterPlayer last name.
full_namecharacterPlayer full name.
athlete_display_namecharacterPlayer display name.
short_namecharacterShort game name.
weightdoublePlayer weight in pounds.
display_weightcharacterFormatted weight string.
heightdoublePlayer height in inches.
display_heightcharacterFormatted height string.
ageintegerPlayer age.
date_of_birthcharacterDate of birth (ISO 8601).
debut_yearintegerYear of NHL debut.
slugcharacterURL slug.
jerseycharacterJersey number.
linkedlogicalTRUE if the record is linked to a related entity.
activelogicalWhether athlete is currently active.
alternate_ids_sdrcharacterAlternate ids sdr.
birth_place_citycharacterBirth place city.
birth_place_statecharacterBirth place state.
birth_place_countrycharacterBirth place country.
birth_country_abbreviationcharacterBirth country abbreviation.
headshot_hrefcharacterPlayer headshot image URL.
headshot_altcharacterHeadshot alt text.
hand_typecharacterShooting/catching hand type.
hand_abbreviationcharacterHand abbreviation.
hand_display_valuecharacterHand display value.
contracts_hrefcharacter
experience_yearsintegerExperience years.
draft_display_textcharacterDraft display text.
draft_roundintegerDraft round.
draft_yearintegerDraft year the lottery applies to.
draft_selectionintegerDraft selection.
draft_team_hrefcharacter
status_idcharacterStatus identifier.
status_namecharacterStatus name.
status_typecharacterStatus type.
status_abbreviationcharacterStatus abbreviation.
jersey_rightcharacter
display_namecharacterPlayer display name.
scratchedlogicalWhether the player was a healthy scratch.
scratch_reasoncharacterReason for scratch (if applicable).
athlete_hrefcharacter
position_hrefcharacter
statistics_hrefcharacter
team_idintegerUnique team identifier.
orderintegerDisplay order within officials list.
home_awaycharacterHome or away indicator.
winnerlogicalWhether this competitor won the game.
team_guidcharacterESPN team GUID.
team_uidcharacterESPN team uid.
team_slugcharacterTeam URL slug.
team_locationcharacterTeam city/location.
team_namecharacterTeam name.
team_nicknamecharacterTeam nickname.
team_abbreviationcharacterTeam abbreviation.
team_display_namecharacterTeam display name.
team_short_display_namecharacterTeam short display name.
team_colorcharacterTeam primary color hex.
team_alternate_colorcharacterTeam alternate color hex.
is_activelogicalWhether the team is active.
is_all_starlogicalWhether the team is an all-star team.
team_alternate_ids_sdrcharacter
logo_hrefcharacterTeam or league logo URL.
logo_dark_hrefcharacterLogo URL for dark backgrounds.
game_idintegerUnique game identifier.

Example

from sportsdataverse.nhl import espn_nhl_game_rosters
rosters = espn_nhl_game_rosters(game_id=401559395)
print(rosters.shape)
rosters.select(["athlete_display_name", "jersey", "team_abbreviation", "starter"]).head(10)

# Just the starters

import polars as pl
rosters.filter(pl.col("starter") == True).select(["athlete_display_name", "team_abbreviation"])

# Pandas round-trip

rosters_pd = espn_nhl_game_rosters(game_id=401559395, return_as_pandas=True)
rosters_pd[["athlete_display_name", "team_abbreviation", "did_not_play"]].head()

espn_nhl_pbp(game_id: 'int', raw=False, **kwargs) -> 'Dict'

espn_nhl_pbp() - Pull the game by id. Data from API endpoints - nhl/playbyplay, nhl/summary

Parameters

ParameterTypeDefaultDescription
game_idintUnique ESPN event id (NOT the NHL native game id), can be obtained from nhl_schedule().
rawFalse

Returns

Dictionary of game data with keys - "gameId", "plays", "boxscore", "header", "broadcasts", "videos", "playByPlaySource", "standings", "leaders", "seasonseries", "pickcenter", "againstTheSpread", "odds", "onIce", "gameInfo", "season"

Example

from sportsdataverse.nhl import espn_nhl_pbp
game = espn_nhl_pbp(game_id=401559395)
list(game.keys()) # 'gameId', 'plays', 'boxscore', ...

# Inspect parsed plays and a quick filter on goal events

import polars as pl
plays = pl.DataFrame(game["plays"])
print(plays.shape)
goals = plays.filter(pl.col("type.text") == "Goal")
goals.select(["period", "time", "text"]).head()

# Pull the unparsed payload for custom downstream parsing

raw = espn_nhl_pbp(game_id=401559395, raw=True)
sorted(raw.keys())[:5]

espn_nhl_player_stats(athlete_id: 'int', season: 'int', *, season_type: 'str' = 'regular', total: 'bool' = False, raw: 'bool' = False, return_as_pandas: 'bool' = False, **kwargs: 'Any') -> 'pl.DataFrame | pd.DataFrame | dict[str, Any]'

Pull an NHL athlete's ESPN season stat line as one wide row.

See sportsdataverse.wbb.espn_wbb_player_stats for full documentation of the wide return shape, the {category}_{stat} stat columns (for hockey: offensive_*, defensive_*, penalties_*, ...), the athlete / team metadata blocks, and the season_type / total parameters. For the richer multi-category web-v3 payload use sportsdataverse.nhl.espn_nhl_player_stats_v3.

Parameters

ParameterTypeDefaultDescription
athlete_idintESPN NHL athlete identifier (e.g. 3895074 for Connor McDavid).
seasonintSeason year, used in the core-v2 path.
season_typestr'regular'"regular" (type 2) or "postseason" (type 3).
totalboolFalseForward-compat totals passthrough.
rawboolFalseIf True, returns the raw core-v2 statistics JSON dict.
return_as_pandasboolFalseIf True, returns a pandas DataFrame; else polars.

Returns

A single-row wide DataFrame (polars by default). When raw=True returns the raw statistics JSON dict.

col_nametypedescription
seasonintegerSeason year (echoed from arg).
season_typecharacterSeason type code (echoed from arg).
totallogicalTotal.
athlete_idintegerESPN athlete identifier (echoed from arg).
athlete_uidcharacterESPN athlete UID (universal identifier).
athlete_guidcharacterESPN athlete GUID.
athlete_typecharacterAthlete type / class.
first_namecharacterPlayer first name.
last_namecharacterPlayer last name.
full_namecharacterPlayer full name.
display_namecharacterPlayer display name.
short_namecharacterShort game name.
weightdoublePlayer weight in pounds.
display_weightcharacterFormatted weight string.
heightdoublePlayer height in inches.
display_heightcharacterFormatted height string.
ageintegerPlayer age.
date_of_birthcharacterDate of birth (ISO 8601).
jerseycharacterJersey number.
slugcharacterURL slug.
activelogicalWhether athlete is currently active.
position_idintegerOfficial position identifier.
position_namecharacterOfficial position name (e.g. "Referee", "Linesman").
position_display_namecharacterPosition display name.
position_abbreviationcharacterPosition abbreviation.
college_namecharacterCollege name.
status_idintegerStatus identifier.
status_namecharacterStatus name.
defensive_goals_againstdouble
defensive_avg_goals_againstdouble
defensive_shots_againstdouble
defensive_avg_shots_againstdouble
defensive_shootout_savescharacter
defensive_shootout_shots_againstdouble
defensive_shootout_save_pctdouble
defensive_empty_net_goals_againstcharacter
defensive_shutoutsdouble
defensive_savesdouble
defensive_save_pctdouble
defensive_overtime_lossesdouble
defensive_blocked_shotsdouble
defensive_hitsdouble
defensive_even_strength_savesdouble
defensive_power_play_savesdouble
defensive_short_handed_savesdouble
general_gamesdoubleCareer games played.
general_game_starteddouble
general_team_games_playeddouble
general_winsdouble
general_lossesdouble
general_tiescharacter
general_plus_minusdoubleA player's estimated on-court impact on team performance measured in point differential per 100 possessions.
general_time_on_icedouble
general_time_on_ice_per_gamedouble
general_shiftsdouble
general_shifts_per_gamedouble
general_productiondouble
offensive_goalsdoubleGoals (offensive category).
offensive_avg_goalsdouble
offensive_assistsdoubleCareer assists.
offensive_shots_totaldoubleShots on goal.
offensive_avg_shotsdouble
offensive_pointsdoubleCareer points.
offensive_points_per_gamedouble
offensive_power_play_goalsdoublePower-play goals.
offensive_power_play_assistsdouble
offensive_short_handed_goalsdouble
offensive_short_handed_assistsdouble
offensive_shootout_attemptsdouble
offensive_shootout_goalsdouble
offensive_shootout_shot_pctdouble
offensive_shooting_pctdoubleShooting percentage.
offensive_total_face_offsdouble
offensive_faceoffs_wondouble
offensive_faceoffs_lostdouble
offensive_faceoff_percentdouble
offensive_game_tying_goalscharacter
offensive_game_winning_goalsdoubleGame-winning goals.
penalties_penalty_minutesdoubleCareer penalty minutes.
penalties_major_penaltiesdouble
penalties_minor_penaltiesdouble
penalties_match_penaltiesdouble
penalties_misconductsdouble
penalties_game_misconductsdouble
penalties_boarding_penaltiesdouble
penalties_unsportsmanlike_penaltiesdouble
penalties_fighting_penaltiesdouble
penalties_avg_fightsdouble
penalties_time_between_fightscharacter
penalties_instigator_penaltiesdouble
penalties_charging_penaltiesdouble
penalties_hooking_penaltiesdouble
penalties_tripping_penaltiesdouble
penalties_roughing_penaltiesdouble
penalties_holding_penaltiesdouble
penalties_interference_penaltiesdouble
penalties_slashing_penaltiesdouble
penalties_high_sticking_penaltiesdouble
penalties_cross_checking_penaltiesdouble
penalties_stick_holding_penaltiesdouble
penalties_goalie_interference_penaltiesdouble
penalties_elbowing_penaltiesdouble
penalties_diving_penaltiesdouble
rpi_winsdouble
rpi_lossesdouble
rpi_ot_lossescharacter
rpi_pointsdouble
rpi_rpicharacter
rpi_soscharacter
rpi_power_rankcharacter
rpi_points_forcharacter
rpi_points_againstcharacter
team_idintegerUnique team identifier.
team_uidcharacterESPN team uid.
team_guidcharacterESPN team GUID.
team_slugcharacterTeam URL slug.
team_locationcharacterTeam city/location.
team_namecharacterTeam name.
team_abbreviationcharacterTeam abbreviation.
team_display_namecharacterTeam display name.
team_short_display_namecharacterTeam short display name.
team_colorcharacterTeam primary color hex.
team_alternate_colorcharacterTeam alternate color hex.
team_is_activelogicalTRUE if the team is currently active.
team_logo_hrefcharacterDefault team logo URL; team_detail = TRUE only.

Example

from sportsdataverse.nhl import espn_nhl_player_stats
df = espn_nhl_player_stats(athlete_id=3895074, season=2023)
df.select(["full_name", "team_display_name", "offensive_goals"])

espn_nhl_schedule(dates=None, season_type=None, limit=500, return_as_pandas=False, **kwargs) -> 'pl.DataFrame'

espn_nhl_schedule - look up the NHL schedule for a given date

Parameters

ParameterTypeDefaultDescription
datesintNoneUsed to define different seasons. 2002 is the earliest available season.
season_typeintNoneseason type, 1 for pre-season, 2 for regular season, 3 for post-season, 4 for all-star, 5 for off-season
limitint500number of records to return, default: 500.
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.

Returns

Polars dataframe containing schedule dates for the requested season. Returns None if no games

col_nametypedescription
idcharacterUnique player identifier.
uidcharacterCompetitor uid string.
datecharacterGame date (ISO 8601 datetime string).
attendanceintegerGame attendance.
time_validlogicalWhether the start time is confirmed.
neutral_sitelogicalWhether the game is at a neutral site.
play_by_play_availablelogicalWhether play-by-play data is available.
recentlogicalWhether the game is recent.
start_datecharacterSeason start date.
broadcastcharacterBroadcast network(s).
highlightscharacterGame highlight urls.
notes_typecharacterNotes type.
notes_headlinecharacterNotes headline.
broadcast_marketcharacterBroadcast market label (e.g. 'national', 'home').
broadcast_namecharacterBroadcast name.
type_idcharacterPlay type id.
type_abbreviationcharacterPlay type abbreviation.
venue_idcharacterVenue identifier.
venue_full_namecharacterVenue full name.
venue_address_citycharacterVenue address city.
venue_address_statecharacterVenue address state / region.
venue_address_countrycharacter
venue_indoorlogicalWhether the venue is indoors.
status_clockdoubleGame clock in seconds.
status_display_clockcharacterDisplay clock string.
status_periodintegerCurrent period.
status_type_idcharacterStatus type identifier.
status_type_namecharacterStatus type name.
status_type_statecharacterStatus state (pre/in/post).
status_type_completedlogicalWhether the game is complete.
status_type_descriptioncharacterStatus description.
status_type_detailcharacterStatus detail text.
status_type_short_detailcharacterShort status detail.
format_regulation_periodsintegerFormat regulation periods.
home_idcharacterHome team ESPN identifier.
home_uidcharacterHome team's uid.
home_locationcharacterHome team city.
home_namecharacterHome team display name.
home_abbreviationcharacterHome team abbreviation.
home_display_namecharacterHome team display name.
home_short_display_namecharacterHome short display name.
home_colorcharacterHome team primary color hex.
home_alternate_colorcharacterHome team alternate color hex.
home_is_activelogicalHome team's is active.
home_venue_idcharacterUnique identifier for home venue.
home_logocharacterHome team logo URL.
home_scorecharacterHome team final score.
home_linescoresinteger
home_recordscharacter
away_idcharacterAway team ESPN identifier.
away_uidcharacterAway team's uid.
away_locationcharacterAway team city.
away_namecharacterAway team display name.
away_abbreviationcharacterAway team abbreviation.
away_display_namecharacterAway team display name.
away_short_display_namecharacterAway short display name.
away_colorcharacterAway team primary color hex.
away_alternate_colorcharacterAway team alternate color hex.
away_is_activelogicalAway team's is active.
away_venue_idcharacterUnique identifier for away venue.
away_logocharacterAway team logo URL.
away_scorecharacterAway team final score.
away_linescoresinteger
away_recordscharacter
game_idintegerUnique game identifier.
seasonintegerSeason year (echoed from arg).
season_typeintegerSeason type code (echoed from arg).

Example

from sportsdataverse.nhl import espn_nhl_schedule
sched = espn_nhl_schedule(dates=20230613) # 2023 Stanley Cup Final game date
print(sched.shape)
sched.select(["game_id", "home_name", "away_name", "status_type_description"]).head()

# Pull a regular-season slate from a season-year

reg = espn_nhl_schedule(dates=2023, season_type=2, limit=500)
reg.group_by("status_type_description").len().sort("len", descending=True)

# Pandas round-trip for one date

espn_nhl_schedule(dates=20230613, return_as_pandas=True).head()

NHL native

nhl_pbp_disk(game_id, path_to_json)

No description available.

Parameters

ParameterTypeDefaultDescription
game_id
path_to_json

nhl_records_coach_milestone_wins(wins: 'int', playoffs: 'bool' = False, **filters) -> 'Dict'

Coaches who reached a wins milestone in fewest games.

Wraps one of the /coach-fewest-games-to-{N}-wins or /coach-fewest-games-to-{N}-playoff-wins paths.

Supported wins values: 50, 100, 150, 200, 300, 400, 500, 600, 700, 800, 900, 1000 (regular season); 50, 100, 150 (playoffs).

Parameters

ParameterTypeDefaultDescription
winsintMilestone win total (e.g. 100).
playoffsboolFalseIf True, use the playoff-wins path.

Returns

Coaches who hit the milestone, sorted by games needed.

nhl_records_comeback_wins(scope: 'str' = 'league', **filters) -> 'Dict'

Comeback wins from a multi-goal deficit.

Wraps:

  • GET /comeback-league-wins when scope is "league".
  • GET /comeback-franchise-wins when scope is "franchise".

Parameters

ParameterTypeDefaultDescription
scopestr'league'"league" (default) or "franchise".

Returns

Games where the team overcame a deficit to win.

nhl_records_consecutive_goal_seasons(goals: 'int' = 50, **filters) -> 'Dict'

Skaters with the most consecutive N-goal seasons.

Wraps one of:

  • GET /consecutive-20-goal-seasons
  • GET /consecutive-30-goal-seasons
  • GET /consecutive-40-goal-seasons
  • GET /consecutive-50-goal-seasons
  • GET /consecutive-60-goal-seasons

Parameters

ParameterTypeDefaultDescription
goalsint50Goal threshold — one of 20, 30, 40, 50, 60.

Returns

Skaters sorted by consecutive-season streak.

nhl_records_fastest_goals(n_goals: 'int' = 2, **filters) -> 'Dict'

Fastest N goals by one team in a single game.

Wraps one of:

  • GET /fastest-2-goals-one-team
  • GET /fastest-3-goals-one-team
  • GET /fastest-4-goals-one-team
  • GET /fastest-5-goals-one-team

Parameters

ParameterTypeDefaultDescription
n_goalsint2Goal count — one of 2, 3, 4, 5.

Returns

Games where the milestone was set, sorted by elapsed time (fastest first).

nhl_records_fastest_goals_both_teams(n_goals: 'int' = 2, **filters) -> 'Dict'

Fastest N goals combined (both teams) in a single game.

Wraps one of:

  • GET /fastest-2-goals-both-teams
  • GET /fastest-3-goals-both-teams
  • GET /fastest-4-goals-both-teams
  • GET /fastest-5-goals-both-teams
  • GET /fastest-6-goals-both-teams

Parameters

ParameterTypeDefaultDescription
n_goalsint2Combined goal count — one of 2, 3, 4, 5, 6.

Returns

Sorted by elapsed time (fastest first).

nhl_records_games_played_streak_skaters(active_only: 'bool' = False, **filters) -> 'Dict'

Consecutive games-played streaks for skaters.

Wraps GET /games-played-streak-skaters (career) or GET /games-played-active-streak-skaters (currently active streaks).

Parameters

ParameterTypeDefaultDescription
active_onlyboolFalseIf True, return only active streaks.

Returns

Skaters sorted by streak length.

nhl_scoreboard(date: 'Optional[str]' = None, team: 'Optional[str]' = None, *, return_parsed: 'bool' = True, return_as_pandas: 'bool' = False, **kwargs) -> 'Dict'

In-game scoreboard payload (renamed from nhl_web_scoreboard).

Picks among three mutually-exclusive NHL api-web forms (kept hand-written because the URL-builder codegen can't represent the 3-way branch):

  • GET /v1/scoreboard/{team}/now -- team-scoped now (when team set),
  • GET /v1/scoreboard/{date} -- league-wide on a date,
  • GET /v1/scoreboard/now -- league-wide now (both args None).

Parameters

ParameterTypeDefaultDescription
dateOptional[str]NoneYYYY-MM-DD; None -> /now. Mutually exclusive with team.
teamOptional[str]None3-letter abbreviation; takes precedence over date.
return_parsedboolTruedispatch the raw payload through parse_nhl_web_scoreboard.
return_as_pandasboolFalsewith return_parsed, return pandas instead of polars.

Returns

A polars/pandas DataFrame by default; the raw JSON Dict when return_parsed=False.

col_nametypedescription
scoreboard_datecharacter
idintegerUnique player identifier.
seasonintegerSeason year (echoed from arg).
game_typeintegerGame type the row belongs to.
game_datecharacterGame date.
game_center_linkcharacterLink to the NHL game center page.
start_time_utccharacterScheduled start time in UTC.
eastern_utc_offsetcharacterEastern time UTC offset.
venue_utc_offsetcharacterVenue UTC offset.
tv_broadcastscharacterNested list of TV broadcast details.
game_statecharacterGame state (e.g., FINAL, LIVE).
game_schedule_statecharacterSchedule state of the game.
tickets_linkcharacter
tickets_link_frcharacter
perioddoublePeriod number.
three_min_recapcharacterLink to the three-minute recap.
three_min_recap_frcharacterLink to the French three-minute recap.
venue_defaultcharacterVenue name (default language).
away_team_idintegerAway team identifier.
away_team_name_defaultcharacter
away_team_name_frcharacter
away_team_common_name_defaultcharacterAway team common name (default language).
away_team_place_name_with_preposition_defaultcharacterAway team place name with preposition (default).
away_team_place_name_with_preposition_frcharacterAway team place name with preposition (French).
away_team_abbrevcharacterAway team abbreviation.
away_team_scoredoubleAway team final score.
away_team_logocharacterURL to the away team logo.
home_team_idintegerHome team identifier.
home_team_name_defaultcharacter
home_team_name_frcharacter
home_team_common_name_defaultcharacterHome team common name (default language).
home_team_place_name_with_preposition_defaultcharacterHome team place name with preposition (default).
home_team_place_name_with_preposition_frcharacterHome team place name with preposition (French).
home_team_abbrevcharacterHome team abbreviation.
home_team_scoredoubleHome team final score.
home_team_logocharacterURL to the home team logo.
period_descriptor_numberdoublePeriod number.
period_descriptor_period_typecharacterPeriod type (e.g., REG, OT).
period_descriptor_max_regulation_periodsdoubleMaximum number of regulation periods.
series_status_roundinteger
series_status_series_abbrevcharacter
series_status_gameinteger
series_status_top_seed_team_abbrevcharacter
series_status_top_seed_winsinteger
series_status_bottom_seed_team_abbrevcharacter
series_status_bottom_seed_winsinteger
period_descriptor_ot_periodsdouble
away_team_recordcharacterAway team's win-loss record.
home_team_recordcharacterHome team's win-loss record.

Example

>>> nhl_scoreboard(date="2024-03-01")

Dataset loaders

load_nhl_games(return_as_pandas: 'bool' = False)

Load the NHL games-in-data-repo manifest (no seasons argument).

Mirrors fastRhockey (R) load_nhl_games() which reads a manifest of every NHL game that has processed data in the data repository.

Tries the sportsdataverse-data release asset first; falls back to the raw fastRhockey-data GitHub path.

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalsereturn a pandas DataFrame instead of polars.

Returns

A polars (or pandas) DataFrame of all games in the data repository.

col_nametypedescription
game_idintegerUnique game identifier.
season_fullcharacterFull season label (e.g. 20212022).
game_typecharacterGame type the row belongs to.
game_datecharacterGame date.
game_timecharacterScheduled start time of the game.
home_team_abbrcharacterHome team abbreviation.
away_team_abbrcharacterAway team abbreviation.
home_team_namecharacterHome team name.
away_team_namecharacterAway team name.
home_scoreintegerHome team final score.
away_scoreintegerAway team final score.
game_statecharacterGame state (e.g., FINAL, LIVE).
venuecharacterVenue where the game was played.
series_lettercharacter
playoff_roundintegerPlayoff round identifier.
series_game_numberintegerSeries game number.
seasonintegerSeason year (echoed from arg).
game_jsonlogicalWhether processed game JSON is available.
game_json_urlcharacterURL to the processed game JSON.
PBPlogicalWhether play-by-play data is available.
team_boxlogicalWhether team box score data is available.
player_boxlogicalWhether player box score data is available.
skater_boxlogicalWhether skater box data is available.
goalie_boxlogicalWhether goalie box data is available.
game_infologicalWhether game info data is available.
game_rosterslogicalWhether game rosters data is available.
scoringlogicalTRUE when the play results in a score (TD, FG, safety, two-point conversion).
penaltieslogicalPenalty count.
scratcheslogical
linescorelogical
three_starslogicalWhether three stars data is available.
shiftslogicalNumber of shifts.
officialslogicalWhether officials data is available.
shots_by_periodlogicalWhether shots-by-period data is available.
shootoutlogicalWhether shootout data is available.

Example

>>> load_nhl_games()

load_nhl_goalie_box(seasons, return_as_pandas: 'bool' = False)

Alias of load_nhl_goalie_boxscores() for naming parity with fastRhockey (R).

Parameters

ParameterTypeDefaultDescription
seasons
return_as_pandasboolFalse

load_nhl_player_box(seasons, return_as_pandas: 'bool' = False)

Alias of load_nhl_player_boxscore() for naming parity with fastRhockey (R).

Parameters

ParameterTypeDefaultDescription
seasons
return_as_pandasboolFalse

load_nhl_skater_box(seasons, return_as_pandas: 'bool' = False)

Alias of load_nhl_skater_boxscores() for naming parity with fastRhockey (R).

Parameters

ParameterTypeDefaultDescription
seasons
return_as_pandasboolFalse

load_nhl_team_box(seasons, return_as_pandas: 'bool' = False)

Alias of load_nhl_team_boxscore() for naming parity with fastRhockey (R).

Parameters

ParameterTypeDefaultDescription
seasons
return_as_pandasboolFalse

Utilities & helpers

most_recent_nhl_season()

most_recent_nhl_season - return the season year for "today".

NHL seasons are labeled by the year they end in. October flips the label to next calendar year (the new season just started), otherwise the current calendar year is returned.

Returns

A season year suitable for season-aware loaders / schedule helpers.

Example

from sportsdataverse.nhl import most_recent_nhl_season, espn_nhl_calendar
season = most_recent_nhl_season()
cal = espn_nhl_calendar(season=season)
print(season, cal.height)

year_to_season(year)

year_to_season - format a starting year as the canonical YYYY-YY season string.

NHL season strings (used by statsapi / api-web.nhle.com) are of the form "2023-24". This helper converts a starting year (2023) into that string.

Parameters

ParameterTypeDefaultDescription
yearStarting calendar year of the season (e.g. 2023).

Returns

Season string formatted as "YYYY-YY".

Example

from sportsdataverse.nhl import year_to_season
year_to_season(2023) # '2023-24'
year_to_season(2009) # '2009-10'
year_to_season(1999) # '1999-00'

Other

espn_nhl_teams(return_as_pandas=False, **kwargs) -> 'pl.DataFrame'

espn_nhl_teams - look up NHL teams

Parameters

ParameterTypeDefaultDescription
return_as_pandasboolFalseIf True, returns a pandas dataframe. If False, returns a polars dataframe.

Returns

Polars dataframe containing teams for the requested league. This function caches by default, so if you want to refresh the data, use the command sportsdataverse.nhl.espn_nhl_teams.clear_cache().

col_nametypedescription
team_abbreviationcharacterTeam abbreviation.
team_alternate_colorcharacterTeam alternate color hex.
team_colorcharacterTeam primary color hex.
team_display_namecharacterTeam display name.
team_idcharacterUnique team identifier.
team_is_activelogicalTRUE if the team is currently active.
team_is_all_starlogicalTRUE if the row represents an All-Star team.
team_locationcharacterTeam city/location.
team_logosintegerTeam logo metadata.
team_namecharacterTeam name.
team_nicknamecharacterTeam nickname.
team_short_display_namecharacterTeam short display name.
team_slugcharacterTeam URL slug.
team_uidcharacterESPN team uid.

Example

from sportsdataverse.nhl import espn_nhl_teams
teams = espn_nhl_teams()
print(teams.shape)
teams.select(["team_id", "team_abbreviation", "team_display_name"]).head()

# Find Tampa Bay Lightning (team_id 14)

import polars as pl
teams.filter(pl.col("team_id") == "14").to_dicts()

# Refresh the cache (the call is ``lru_cache``'d) and round-trip to pandas

espn_nhl_teams.cache_clear()
teams_pd = espn_nhl_teams(return_as_pandas=True)
teams_pd[["team_id", "team_abbreviation", "team_display_name"]].head()

scoreboard_event_parsing(event)

No description available.

Parameters

ParameterTypeDefaultDescription
event