nhlapi

A Minimum-Dependency 'R' Interface to the 'NHL' API


License
AGPL-3.0

Documentation

nhlapi

A minimum-dependency R interface to the NHL API.

CRAN Version CRAN Checks Dependencies Remote API Tests Coverage

{nhlapi} is an R package that provides functionality to retrieve and process the data exposed by the open NHL API. This includes information on players, teams, games, tournaments, drafts, standings, schedules and other endpoints. A lower-level interface to access the data via URLs directly is also provided. See below for a full list of endpoints.

Installation

You can install {nhlapi} from CRAN:

install.packages("nhlapi")

You can also install the latest development version from the master branch on GitHub using the {remotes} or {devtools} packages:

# With remotes
remotes::install_github("jozefhajnala/nhlapi")

# Or with devtools
devtools::install_github("jozefhajnala/nhlapi")

Use and develop with Docker

The Docker image jozefhajnala/nhlapi has RStudio and a set of useful packages for both interactive use of the {nhlapi} package and its development.

Running the following command and opening localhost:8787 in a web browser should open RStudio with a setup ready for analysis and development. Login user is rstudio and password is pass:

# Password can be changed by changing the PASSWORD option below:
# If you need root permissions, add `-e ROOT=true`
docker run --rm -p 8787:8787 -e PASSWORD=pass jozefhajnala/nhlapi

Usage

We retrieve the data from the NHL API by calling the functions exported by the {nhlapi} package. They start with nhl_ so you can easily find them with auto-complete in your favorite editor:

nhlapi Preview

In-depth look at use

The package's vignettes provide a more detailed overview of some of the functionality:

Implemented API endpoints

Major endpoints

  • Teams

    • Team Metadata nhl_teams()
    • Team Rosters nhl_teams_rosters()
    • Team Schedules nhl_teams_shedule_next(), nhl_teams_shedule_previous()
    • Team Stats nhl_teams_stats()
  • People (Players)

    • Players metadata nhl_players
    • Players season/playoff stats nhl_players_seasons()
    • Players all season stats nhl_players_allseasons()
  • Games

    • Games content nhl_games_content()
    • Games full live feed nhl_games_feed()
    • Games box score info nhl_games_boxscore()
    • Games line score infonhl_games_linescore()
  • Tournaments

    • Playoffs nhl_tournaments_playoffs()
    • Olympics nhl_tournaments_olympics()
    • World Cups nhl_tournaments_worldcups()
  • Schedule

    • Generic API with all parameters nhl_schedule()
    • Today nhl_schedule_today()
    • Custom seasons nhl_schedule_seasons()
    • Custom date ranges nhl_schedule_date_range()
  • Standings nhl_standings()

Minor endpoints

  • Divisions nhl_divisions()
  • Conferences nhl_conferences()
  • Drafts nhl_drafts()
  • Seasons nhl_seasons()
  • Awards nhl_awards()
  • Venues nhl_venues()
  • Draft prospects nhl_draft_prospects()

Metadata endpoints

  • Game Types nhl_md_game_types()
  • Game Statuses nhl_md_game_statuses()
  • Play Types nhl_md_play_types()
  • Tournament Types nhl_md_tournament_types()
  • Standings Types nhl_md_standings_types()
  • Stats Types nhl_md_stat_types()
  • Event Types nhl_md_event_types()

Acknowledgments

Thanks go to Drew Hynes for documenting this so well on GitLab.

Copyright message

NHL and the NHL Shield are registered trademarks of the National Hockey League. NHL and NHL team marks are the property of the NHL and its teams. © NHL 2021. All Rights Reserved.