Skip to main content
Version: 0.2.0

NHL — NHL Web API — Web

nhl_web_pbp​

Pull the play-by-play feed for one NHL game.

Endpoint URL: GET https://api-web.nhle.com/v1/gamecenter/{game_id}/play-by-play

Valid URL: https://api-web.nhle.com/v1/gamecenter/2024020001/play-by-play

API ParameterPythonPatternRequiredNullableDescription
game_idgame_idYgame_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
event_idInt64ESPN event id (echoed from arg).
time_in_periodStringTime elapsed in the period when the shot occurred.
time_remainingString
situation_codeString
home_team_defending_sideStringIce end ('left' or 'right') that the home team is defending in the current period, used to orient x/y coordinates in the NHL api-web play-by-play feed.
type_codeInt64Numeric event-type code identifying the category of play (e.g., goal, shot, hit, penalty, faceoff) in the NHL api-web play-by-play feed.
type_desc_keyStringString key describing the event type category (e.g., 'goal', 'shot-on-goal', 'hit', 'faceoff') in the NHL api-web play-by-play feed.
sort_orderInt64
period_descriptor_numberInt64Period number.
period_descriptor_period_typeStringPeriod type (e.g., REG, OT).
period_descriptor_max_regulation_periodsInt64Maximum number of regulation periods.
details_event_owner_team_idInt64NHL api-web team identifier for the team credited with or responsible for the play event in the play-by-play feed.
details_losing_player_idInt64NHL api-web player identifier for the skater who lost the faceoff on a faceoff event in the play-by-play feed.
details_winning_player_idInt64NHL api-web player identifier for the skater who won the faceoff on a faceoff event in the play-by-play feed.
details_x_coordFloat64Horizontal rink coordinate (feet from centre ice, positive toward right side) of the play event location in the NHL api-web play-by-play feed.
details_y_coordFloat64Vertical rink coordinate (feet from centre ice, positive toward one end) of the play event location in the NHL api-web play-by-play feed.
details_zone_codeStringIce zone where the play event occurred, coded as 'O' (offensive), 'D' (defensive), or 'N' (neutral) relative to the event owner team in the play-by-play feed.
details_shot_typeStringClassification of the shot attempt (e.g., wrist shot, slap shot, backhand, deflection) as provided in the NHL api-web play-by-play details.
details_shooting_player_idInt64NHL api-web player identifier for the skater who took the shot on a shot-on-goal, missed-shot, or blocked-shot event in the play-by-play feed.
details_goalie_in_net_idInt64NHL api-web player identifier for the goaltender who was in the net at the time of the shot, goal, or missed-shot event in the play-by-play feed.
details_away_sogFloat64Cumulative shots on goal by the away team at the moment of the play event in the NHL api-web play-by-play feed.
details_home_sogFloat64Cumulative shots on goal by the home team at the moment of the play event in the NHL api-web play-by-play feed.
details_reasonStringPrimary reason or description for the play event (e.g., specific penalty infraction name) as provided in the NHL api-web play-by-play details.
details_blocking_player_idInt64NHL api-web player identifier for the skater who blocked a shot on the blocked-shot event in the play-by-play feed.
details_hitting_player_idInt64NHL api-web player identifier for the skater who delivered the body check on a hit event in the play-by-play feed.
details_hittee_player_idInt64NHL api-web player identifier for the skater who received the body check on a hit event in the play-by-play feed.
details_player_idInt64NHL api-web player identifier for the primary player involved in the play event (used on giveaway, takeaway, and similar single-player events).
details_type_codeStringStructured sub-type code providing additional classification within the play event category in the NHL api-web play-by-play feed.
details_desc_keyStringShort descriptor key providing additional classification of the play event (e.g., penalty type or shot outcome) in the NHL api-web play-by-play feed.
details_durationFloat64Duration of the penalty in minutes as specified in the play event details of the NHL api-web play-by-play feed.
details_committed_by_player_idInt64NHL api-web player identifier for the player who committed the infraction on a penalty event in the play-by-play feed.
details_drawn_by_player_idInt64NHL api-web player identifier for the player who drew (was the victim of) the penalty on a penalty event in the play-by-play feed.
ppt_replay_urlStringURL to the power-play tracking replay video associated with this play event in the NHL api-web play-by-play feed.
details_scoring_player_idInt64NHL api-web player identifier for the skater who scored the goal on a goal event in the play-by-play feed.
details_scoring_player_totalFloat64Running season goal total for the scoring player at the time of the goal event in the NHL api-web play-by-play feed.
details_assist1_player_idInt64NHL api-web player identifier for the primary (first) assist credited on a goal event in the play-by-play feed.
details_assist1_player_totalFloat64Running season assist total for the primary assist player at the time of the goal event in the play-by-play feed.
details_assist2_player_idInt64NHL api-web player identifier for the secondary (second) assist credited on a goal event in the play-by-play feed.
details_assist2_player_totalFloat64Running season assist total for the secondary assist player at the time of the goal event in the play-by-play feed.
details_away_scoreFloat64Cumulative away-team score at the moment of the play event in the NHL api-web play-by-play feed.
details_home_scoreFloat64Cumulative home-team score at the moment of the play event in the NHL api-web play-by-play feed.
details_highlight_clip_sharing_urlStringPublic sharing URL for the English-language broadcast highlight clip of this play event from the NHL api-web play-by-play feed.
details_highlight_clipFloat64NHL api-web identifier for the broadcast highlight clip associated with this play event in the play-by-play feed (English feed).
details_discrete_clipFloat64NHL api-web clip identifier for the discrete video clip of this play event in the play-by-play feed (English feed).
details_discrete_clip_frFloat64NHL api-web clip identifier for the discrete video clip of this play event in the play-by-play feed (French feed).
details_highlight_clip_sharing_url_frStringPublic sharing URL for the French-language broadcast highlight clip of this play event from the NHL api-web play-by-play feed.
details_highlight_clip_frFloat64NHL api-web identifier for the broadcast highlight clip associated with this play event in the play-by-play feed (French feed).
details_secondary_reasonStringSecondary descriptive reason or sub-classification for the play event as provided in the NHL api-web play-by-play details (e.g., penalty sub-type).

return_parsed=False — the raw JSON payload: a dict, or a list for the endpoints that answer an array (nhl_postal_lookup, nhl_smartlinks).

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​

nhl_web_pbp(game_id=2024020001)

nhl_web_schedule​

Pull the week-of NHL schedule rooted at date.

Endpoint URL: GET https://api-web.nhle.com/v1/schedule/{date}

Valid URL: https://api-web.nhle.com/v1/schedule/now

API ParameterPythonPatternRequiredNullableDescription
datedateYdate 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
schedule_dateStringCalendar date of the game in YYYY-MM-DD format as returned by the NHL api-web schedule endpoint.
idInt64Unique player identifier.
seasonInt64Season year (echoed from arg).
game_typeInt64Game type the row belongs to.
neutral_siteBooleanWhether the game is at a neutral site.
start_time_utcStringScheduled start time in UTC.
eastern_utc_offsetStringEastern time UTC offset.
venue_utc_offsetStringVenue UTC offset.
venue_timezoneStringVenue time zone.
game_stateStringGame state (e.g., FINAL, LIVE).
game_schedule_stateStringSchedule state of the game.
tv_broadcastsStringNested list of TV broadcast details.
series_urlStringNHL api-web URL path to the dedicated page for the playoff series associated with this scheduled game.
three_min_recapStringLink to the three-minute recap.
game_center_linkStringLink to the NHL game center page.
venue_defaultStringVenue name (default language).
away_team_idInt64Away team identifier.
away_team_common_name_defaultStringAway team common name (default language).
away_team_place_name_defaultStringAway team place name (default language).
away_team_place_name_with_preposition_defaultStringAway team place name with preposition (default).
away_team_place_name_with_preposition_frStringAway team place name with preposition (French).
away_team_abbrevStringAway team abbreviation.
away_team_logoStringURL to the away team logo.
away_team_dark_logoStringURL to the away team dark logo.
away_team_away_split_squadBooleanWhether the away team is a split squad.
away_team_scoreInt64Away team final score.
home_team_idInt64Home team identifier.
home_team_common_name_defaultStringHome team common name (default language).
home_team_place_name_defaultStringHome team place name (default language).
home_team_place_name_frStringHome team place name (French).
home_team_place_name_with_preposition_defaultStringHome team place name with preposition (default).
home_team_place_name_with_preposition_frStringHome team place name with preposition (French).
home_team_abbrevStringHome team abbreviation.
home_team_logoStringURL to the home team logo.
home_team_dark_logoStringURL to the home team dark logo.
home_team_home_split_squadBooleanWhether the home team is a split squad.
home_team_scoreInt64Home team final score.
period_descriptor_numberInt64Period number.
period_descriptor_period_typeStringPeriod type (e.g., REG, OT).
period_descriptor_max_regulation_periodsInt64Maximum number of regulation periods.
game_outcome_last_period_typeStringPeriod type in which the game ended.
winning_goalie_player_idInt64Winning goalie player identifier.
winning_goalie_first_initial_defaultStringWinning goalie first initial (default language).
winning_goalie_last_name_defaultStringWinning goalie last name (default language).
winning_goalie_last_name_csStringWinning goalie last name (Czech).
winning_goalie_last_name_fiStringWinning goalie last name (Finnish).
winning_goalie_last_name_skStringWinning goalie last name (Slovak).
winning_goal_scorer_player_idInt64Winning goal scorer player identifier.
winning_goal_scorer_first_initial_defaultStringWinning goal scorer first initial (default).
winning_goal_scorer_last_name_defaultStringWinning goal scorer last name (default language).
series_status_roundInt64Playoff round number (1 through 4) for the series containing this scheduled game from the NHL api-web schedule endpoint.
series_status_series_abbrevStringShort abbreviation identifying the specific playoff series slot within the bracket for this scheduled game from the NHL api-web schedule endpoint.
series_status_series_titleStringHuman-readable display title for the playoff series containing this scheduled game (e.g., 'Eastern Conference Second Round').
series_status_series_letterStringSingle-letter label assigned to the playoff series in the bracket structure for this scheduled game from the NHL api-web schedule endpoint.
series_status_needed_to_winInt64Number of additional wins needed by the series leader to clinch and advance at the time of this scheduled game from the NHL api-web schedule endpoint.
series_status_top_seed_team_abbrevStringThree-letter team abbreviation for the higher-seeded team in the playoff series associated with this scheduled game.
series_status_top_seed_winsInt64Number of wins accumulated by the higher-seeded team in the playoff series as of this scheduled game from the NHL api-web schedule endpoint.
series_status_bottom_seed_team_abbrevStringThree-letter team abbreviation for the lower-seeded team in the playoff series associated with this scheduled game.
series_status_bottom_seed_winsInt64Number of wins accumulated by the lower-seeded team in the playoff series as of this scheduled game from the NHL api-web schedule endpoint.
series_status_game_number_of_seriesInt64Sequential game number within the playoff series for this scheduled game (e.g., 1 through 7 for a best-of-seven) from the NHL api-web schedule endpoint.

return_parsed=False — the raw JSON payload: a dict, or a list for the endpoints that answer an array (nhl_postal_lookup, nhl_smartlinks).

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​

nhl_web_schedule()