
Getting Started with fastRhockey
Ben Howell, Saiem Gilani
Source:vignettes/introduction.Rmd
introduction.RmdfastRhockey
is an R package for accessing hockey data from the PWHL
(Professional Women’s Hockey League) and NHL (National
Hockey League) via public web APIs. It provides structured data frames
of play-by-play, schedule, standings, roster, draft, player stats, and
team data. The package also includes integrated expected goals
(xG) models for NHL data.
Part of the SportsDataverse family of R/Python packages for sports analytics.

Installation
You can install the CRAN version of fastRhockey
with:
install.packages("fastRhockey")You can install the development version from GitHub with:
if (!requireNamespace('pak', quietly = TRUE)){
install.packages('pak')
}
pak::pak("sportsdataverse/fastRhockey")PWHL Data
The PWHL (Professional Women’s Hockey League) launched in January
2024 with six teams: Boston, Minnesota, Montreal, New York, Ottawa, and
Toronto. fastRhockey provides full access to PWHL
schedules, standings, play-by-play, player box scores, team rosters, and
stat leaders.
Schedule
Let’s pull the 2024 PWHL season schedule:
schedule <- pwhl_schedule(season = 2024)
schedule %>%
dplyr::filter(game_status == "Final") %>%
dplyr::select(game_id, game_date, home_team, away_team,
home_score, away_score, winner, venue) %>%
head(10)The schedule returns game IDs, dates, teams, scores, and venue information for every game in the season.
Standings
pwhl_standings(season = 2024) %>%
dplyr::select(team_rank, team, games_played, points,
wins, losses, goals_for, goals_against)Player Box Scores
Pick a game from the schedule and pull individual player stats.
pwhl_player_box() returns a list with two data frames:
skaters and goalies.
box <- pwhl_player_box(game_id = 27)
# Skater stats
box[[1]] %>%
dplyr::select(first_name, last_name, position, team_id,
goals, assists, points, shots, toi) %>%
dplyr::arrange(dplyr::desc(points)) %>%
head(10)
# Goalie stats
box[[2]] %>%
dplyr::select(first_name, last_name, team_id,
saves, goals_against, shots_against, toi)Play-by-Play
The real power of fastRhockey is in the play-by-play
data. pwhl_pbp() returns detailed event-level data
including shot locations, faceoff results, penalties, goals with assist
information, and plus/minus player tracking.
pbp <- pwhl_pbp(game_id = 27)
pbp %>%
dplyr::select(event, team_id, period_of_game, time_of_period,
player_name_first, player_name_last,
x_coord, y_coord) %>%
head(15)The play-by-play data includes 90+ columns with event details, player information, coordinates (raw and transformed), and game context.
Stat Leaders
Pull league-wide goalie or skater stats:
# Goalie stats
pwhl_stats(position = "goalie", season = 2024) %>%
dplyr::select(player_name, team, games_played,
goals_against_avg, save_percentage, shutouts) %>%
head(10)
# Skater stats (all teams)
pwhl_stats(position = "skater", season = 2024) %>%
dplyr::select(player_name, team, games_played,
goals, assists, points) %>%
head(10)NHL Data
fastRhockey also provides extensive access to NHL data
via the api-web.nhle.com and
api.nhle.com/stats APIs.
Schedule
nhl_schedule(season = "20242025") %>%
head(10)Standings
nhl_standings(season = "20242025") %>%
head(10)Game Feed and Play-by-Play
The nhl_game_feed() function returns detailed game data
including play-by-play, rosters, and game information.
nhl_game_pbp() provides play-by-play with shift data
integrated.
feed <- nhl_game_feed(game_id = 2024020001)
dplyr::glimpse(feed)Player Stats
# Skater season stats
nhl_stats_skaters(season = "20242025") %>%
head(10)Draft Data
# Get 2024 draft picks (round 1)
nhl_draft_year(year = 2024, round = 1)Full Season Loaders
For bulk historical data, use the loader functions that pull from the fastRhockey-data repository:
# Full season of play-by-play
pbp <- load_nhl_pbp(seasons = 2024)
# Full season schedule
sched <- load_nhl_schedule(seasons = 2024)
# Full season rosters
rosters <- load_nhl_rosters(seasons = 2024)Deprecated PHF Functions
The Premier Hockey Federation (PHF), formerly the National Women’s
Hockey League (NWHL), ceased operations prior to the formation of the
PWHL. All phf_* functions are deprecated as of v1.0.0 and
will raise errors when called. Use the pwhl_* functions
instead for women’s professional hockey data.
Citations
To cite the fastRhockey
R package in publications, use:
BibTex Citation
@misc{howell_gilani_fastRhockey,
author = {Ben Howell and Saiem Gilani},
title = {fastRhockey: Functions to Access Professional Women's Hockey League and National Hockey League Play by Play Data.},
url = {https://fastRhockey.sportsdataverse.org/},
doi = {10.32614/CRAN.package.fastRhockey},
year = {2025}
}