Skip to content

sportsdataverse/fastRhockey

Repository files navigation

fastRhockey

CRAN version CRAN downloads Version-Number R-CMD-check Lifecycle:stable Contributors

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
  • NHL Edge Analytics (33 functions) – Skater, goalie, and team advanced metrics from api-web.nhle.com/v1/edge/... covering shot location, shot speed, skating speed, skating distance, zone time, comparisons, landing pages, and top-10 leaderboards. Each wrapper accepts an optional season argument and falls back to the current season via the /now form
  • NHL Records API (25 functions) – First-time integration with records.nhl.com/site/api/ for franchise totals, player/skater/goalie career and real-time stats, draft lottery, hall of fame, trophies, awards, attendance, venues, officials, and combine data
  • NHL Stats REST (19 dedicated wrappers) – nhl_stats_franchise(), nhl_stats_players(), nhl_stats_glossary(), nhl_stats_country(), nhl_stats_skater_leaders(), nhl_stats_goalie_leaders(), nhl_stats_skater_milestones(), nhl_stats_goalie_milestones(), plus the original nhl_stats_skaters() / nhl_stats_goalies() / nhl_stats_teams() / nhl_stats_draft() / nhl_stats_seasons() / nhl_stats_misc() family
  • PWHL Data – Schedules, standings, play-by-play, player box scores, team rosters, stat leaders, player profiles, game logs, career stats, player search, league leaders, transactions, streaks, playoff brackets, game summaries, and scorebar via the HockeyTech API
  • xG Models – Expected goals predictions for NHL play-by-play data using XGBoost models (5v5, special teams, penalty shots)
  • Helper Aggregators – Convenience functions inspired by nhl-api-py that combine multiple endpoint calls into a single tidy frame: nhl_game_ids_by_season(), nhl_all_players_by_season(), nhl_player_career_stats(), nhl_team_summary_range(), nhl_skater_summary_range(), nhl_goalie_summary_range()
  • Full Season Loaders – Nineteen NHL loaders covering play-by-play (full + lite), schedules, season + per-game rosters, player/skater/goalie/team boxscores, game info, scoring & penalty summaries, three stars, scratches, linescores, shifts, officials, shots-by-period, and shootouts (load_nhl_pbp(), load_nhl_pbp_lite(), load_nhl_schedule(), load_nhl_rosters(), load_nhl_game_rosters(), load_nhl_team_box(), load_nhl_player_box(), load_nhl_skater_box(), load_nhl_goalie_box(), load_nhl_game_info(), load_nhl_scoring(), load_nhl_penalties(), load_nhl_three_stars(), load_nhl_scratches(), load_nhl_linescore(), load_nhl_shifts(), load_nhl_officials(), load_nhl_shots_by_period(), load_nhl_shootout()); for PWHL, fifteen loaders covering play-by-play, schedules, season + per-game rosters, player/skater/goalie/team boxscores, game info, scoring & penalty summaries, three stars, officials, shots-by-period, and shootouts (load_pwhl_pbp(), load_pwhl_schedule(), load_pwhl_rosters(), load_pwhl_game_rosters(), load_pwhl_player_box(), load_pwhl_skater_box(), load_pwhl_goalie_box(), load_pwhl_team_box(), load_pwhl_game_info(), load_pwhl_scoring_summary(), load_pwhl_penalty_summary(), load_pwhl_three_stars(), load_pwhl_officials(), load_pwhl_shots_by_period(), load_pwhl_shootout())

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:

# You can install using the pak package using the following code:
if (!requireNamespace('pak', quietly = TRUE)){
  install.packages('pak')
}
pak::pak("sportsdataverse/fastRhockey")

If you would prefer the remotes installation:

if (!requireNamespace('remotes', quietly = TRUE)){
  install.packages('remotes')
}
remotes::install_github(repo = "sportsdataverse/fastRhockey")

Quick Start

library(fastRhockey)

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

# NHL Edge advanced metrics
nhl_edge_skater_detail(player_id = 8478402)               # Connor McDavid, current season
nhl_edge_goalie_save_percentage_detail(player_id = 8475883)
nhl_edge_team_zone_time_details(team_id = 10)             # Toronto Maple Leafs

# NHL Records API
nhl_records_franchise()
nhl_records_draft_lottery_odds()
nhl_records_skater_real_time_stats_career(limit = 50)

# Helper aggregators
nhl_game_ids_by_season(season = 2025, team_abbr = "TOR")
nhl_player_career_stats(player_id = 8478402)
nhl_team_summary_range(start_season = 2023, end_season = 2024)

# PWHL
pwhl_schedule(season = 2025)
pwhl_standings(season = 2025)
pwhl_pbp(game_id = 27)
pwhl_player_info(player_id = 28)
pwhl_leaders(position = "skaters", season = 2025)
pwhl_game_summary(game_id = 27)

# Full season loaders
load_nhl_pbp(seasons = 2024)
load_nhl_schedule(seasons = 2024)
load_pwhl_pbp(seasons = 2024)
load_pwhl_schedule(seasons = 2024)
load_pwhl_team_box(seasons = 2024)
load_pwhl_skater_box(seasons = 2024)
load_pwhl_scoring_summary(seasons = 2024)
load_pwhl_penalty_summary(seasons = 2024)
load_pwhl_game_info(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.


Changelog

Full News on Releases


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

About

Boxscore and play-by-play stat scraper for the Premier Hockey Federation (PHF, formerly known as the NWHL).

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages