Skip to contents

One game's event timeline: goals with assists, penalties, goaltender changes, revoked goals.

Usage

nl_pbp(game_id, return_parsed = TRUE)

Arguments

game_id

SIHF game id, 14 digits <season(4)><competition(4)><sequence(6)> (game_id in nl_schedule(); the same id as the SIHF family's game_id), e.g. 20261105000325. A whole number or a digit string; 14 digits are exact as a double, so do not format them through integer.

return_parsed

Logical. TRUE (the default) returns the fastRhockey_data tibble; FALSE returns the raw JSON body as a nested list (api keys already dropped).

Value

A fastRhockey_data tibble (34 columns) with the columns below, or the raw JSON body when return_parsed = FALSE. A valid but empty payload returns a zero-row tibble with these columns.

col_nametypedescription
game_idnumericSIHF game id <season(4)><competition(4)><sequence(6)> (whole number; e.g. 20261105000325, 1105 = National League). The same id as the sihf family's game_id; its first four digits are the season END year.
event_indexinteger1-based position of the event in the game's timeline.
team_sidecharacterhome or away: the side of the team this row belongs to.
game_secondsintegerElapsed game time of the event in seconds, from the MMSS time (822 = 8:22 -> 502).
team_idnumericSIHF team id (whole number; e.g. 101151 = HC Davos). The same key space as the sihf family's team_id.
home_teamlogicalEvent belongs to the home team
timecharacterGame clock elapsed as an MMSS string without separator ('822' = 8:22, '5954' = 59:54)
video_timeintegerSeconds into the game video; 0 when there is no clip
video_vimeo_idnumericClip of this event. Vimeo video id (whole number): vimeo.com/<id>.
actioncharacterEvent type: goal, foul (penalty), in / out (goaltender enters / leaves), revokedGoal
foul_typeintegerSIHF penalty code (116-125 in the sample); 0 on non-penalty events
foul_minutesintegerPenalty minutes; 0 on non-penalty events
player_first_namecharacterShooter's first name, from the game's lineup.
player_last_namecharacterShooter's last name, from the game's lineup.
player_numbercharacterShooter's sweater number, from the game's lineup (a string).
player_totalintegerScorer's goals this season including this one; 0 on non-goal events
periodintegerPeriod number, an integer (the parent third is a string)
overtimeintegerOvertime period number; 0 in regulation
goal_situationcharacterGoal kind; 'normal' on every sampled event
home_team_resultintegerHome score after the event
away_team_resultintegerAway score after the event
assist1_first_namecharacterFirst assist: first name
assist1_last_namecharacterFirst assist: last name
assist1_numbercharacterFirst assist: sweater number, a string
assist1_totalintegerFirst assister's assists this season including this one
assist2_first_namecharacterSecond assist: first name
assist2_last_namecharacterSecond assist: last name
assist2_numbercharacterSecond assist: sweater number, a string
assist2_totalintegerSecond assister's assists this season including this one
situationcharacterGoal tags, comma-separated: EQ (even strength), PP1 (power play), GWG (game-winning goal); null on non-goals
revoked_goal_typeintegerRevoked-goal category code (1 on every sampled event)
revoked_goal_sub_typeintegerRevoked-goal reason code (1 on the revoked goal, 0 elsewhere)
review_successfulcharacterVideo-review outcome; unobserved: null or empty in every sampled row
review_goal_countslogicalGoal stood after review

Details

Polite use. www.nationalleague.ch/robots.txt disallows /api, so keep use light and incremental. Requests are spaced at least one second apart (on every attempt, retries included). Check the site's terms of use before any bulk download or redistribution. Crawl incrementally: fetch a finished game once (keyed by game_id), find new games with one nl_schedule() call per run, and fetch season tables at most once per game day.

Seasons are END years and go on the wire unchanged. Ids (*_id) are whole-number numeric (a 14-digit game_id exceeds R's 32-bit integer); every other whole-number column is integer. The club backend key the API ships in /teams/{id}/info is dropped before parsing and never returned.

Endpoint: GET https://www.nationalleague.ch/api/games/{gameId}.

The six game-page wrappers (nl_game_overview(), nl_pbp(), nl_lineups(), nl_player_box(), nl_team_stats(), nl_shots()) each read the same /games/{gameId} body, one request each.

Errors

Raises a classed condition (all inherit fastRhockey_error): fastRhockey_no_data for a 404 or an empty answer (no games or rows for that season, team or phase), fastRhockey_asset_fetch for a failed fetch, an error object in a 200, a body without the ids it must carry, or an answer for another season, team, game or player, and fastRhockey_bad_request for a 400/422 or an argument that is not a whole number.

Examples

# \donttest{
  try(nl_pbp(game_id = 20261105000325))
#> ── National League Play-by-Play Information from nationalleague.ch ─────────────
#> ℹ Data updated: 2026-11-02 03:51:45 UTC
#> # A tibble: 17 × 34
#>    game_id event_index team_side game_seconds team_id home_team time  video_time
#>      <dbl>       <int> <chr>            <int>   <dbl> <lgl>     <chr>      <int>
#>  1 2.03e13           1 home               502  101151 TRUE      822          588
#>  2 2.03e13           2 away               825  102127 FALSE     1345           0
#>  3 2.03e13           3 away              1347  102127 FALSE     2227        2993
#>  4 2.03e13           4 home              1374  101151 TRUE      2254        3092
#>  5 2.03e13           5 away              1453  102127 FALSE     2413        3248
#>  6 2.03e13           6 home              1558  101151 TRUE      2558           0
#>  7 2.03e13           7 away              1607  102127 FALSE     2647        3581
#>  8 2.03e13           8 home              1798  101151 TRUE      2958           0
#>  9 2.03e13           9 away              2184  102127 FALSE     3624           0
#> 10 2.03e13          10 away              2184  102127 FALSE     3624           0
#> 11 2.03e13          11 home              2648  101151 TRUE      4408        6276
#> 12 2.03e13          12 away              2726  102127 FALSE     4526           0
#> 13 2.03e13          13 home              2783  101151 TRUE      4623        6529
#> 14 2.03e13          14 away              3243  102127 FALSE     5403           0
#> 15 2.03e13          15 away              3477  102127 FALSE     5757           0
#> 16 2.03e13          16 home              3559  101151 TRUE      5919           0
#> 17 2.03e13          17 home              3562  101151 TRUE      5922           0
#> # ℹ 26 more variables: video_vimeo_id <dbl>, action <chr>, foul_type <int>,
#> #   foul_minutes <int>, player_first_name <chr>, player_last_name <chr>,
#> #   player_number <chr>, player_total <int>, period <int>, overtime <int>,
#> #   goal_situation <chr>, home_team_result <int>, away_team_result <int>,
#> #   assist1_first_name <chr>, assist1_last_name <chr>, assist1_number <chr>,
#> #   assist1_total <int>, assist2_first_name <chr>, assist2_last_name <chr>,
#> #   assist2_number <chr>, assist2_total <int>, situation <chr>, …
# }