Skip to contents

fastRhockey

fastRhockey is an R package for accessing hockey data from the NHL (National Hockey League) and PWHL (Professional Women’s 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 trained via XGBoost.

Part of the SportsDataverse family of R/Python packages for sports analytics.

Key Features

  • NHL Data – Game feeds, boxscores, play-by-play with shifts, schedules, standings, rosters, draft picks, player/team stats, playoffs, and broadcast information via api-web.nhle.com and api.nhle.com/stats
  • PWHL Data – Schedules, standings, play-by-play, player box scores, team rosters, and stat leaders via the HockeyTech API
  • xG Models – Expected goals predictions for NHL play-by-play data using XGBoost models (5v5, special teams, penalty shots)
  • Full Season Loadersload_nhl_pbp(), load_nhl_schedule(), load_nhl_team_box(), load_nhl_player_box(), load_nhl_rosters() for bulk historical data

Note: PHF (Premier Hockey Federation) functions are deprecated as of v1.0.0. The league ceased operations; use PWHL functions instead.


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")

Quick Start

library(fastRhockey)

# NHL
nhl_schedule(season = "20242025")
nhl_standings(season = "20242025")
nhl_game_feed(game_id = 2024020001)

# PWHL
pwhl_schedule(season = 2024)
pwhl_standings(season = 2024)
pwhl_pbp(game_id = 27)

# Full season loaders
load_nhl_pbp(seasons = 2024)
load_nhl_schedule(seasons = 2024)

Documentation

You can find the documentation for fastRhockey on GitHub pages.

You can view CSVs of historical boxscore and play-by-play on the fastRhockey data repo, as well as the process for scraping that historical data.


Follow the SportsDataverse on Twitter and star this repo

Twitter Follow

GitHub stars

Our Authors

Our Contributors (they’re awesome)

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}
}