The NHL has a poorly documented API that has a lot of information available in it for absolutely free. There are statistics and records available, focusing on teams, players, games, drafts, prospects, and awards. This package aims to provide a basic API wrapper for use in R
. Significant information required for the development of this package comes from https://gitlab.com/dword4/nhlapi.
The package is still under development and may undergo rapid changes, including breaking changes, without warning. Please test any code using this package regularly.
The package may make it to CRAN one day, once stability is achieved. Please watch for that.
This package can be installed by running the following command in an R
session:
devtools::install.github('pbulsink/nhlRapi')
Then, load the package into the R namespace:
library(nhlRapi)
Initially this API will be a dumb wrapper only, calling the API and returning the data as a json object as recieved. Future versions may initiate data cleaning or other manipulations.
The following items are covered by this API:
- Teams
- Divisions
- Conferences
- People
- Game-IDs
- Schedule
- Standings
-
Standings Types -
Stats Types - Team Stats
- Draft
- Prospects
- Awards
- Venues
- Tournaments (new)
- Seasons (new)
Stats Types and Standings Types are modifiers for People Stats and Standings, respectively
- Attendance
- Draft
- Records
- Franchise
- Player
- Playoffs
- Trophy
- Milestones
- Officials
Some functions contain introductory filter options. Further filtering can be done once data is retrieved by the API. For example, the API can get all attendance records getAttendance()
or a specific season getAttendance(season = 20152016)
. While the web API allows for other field filtering (e.g. a call for playoffAttendance>1000000
), the R
api functions do not have all of these built in.
Instead, use R
to perform these filters:
attendance<-getAttendance()
attendance<-attendance$data[attendance$data$playoffAttendance > 1000000, ]
There are no rate limiters built into the API to prevent over-usage of the API. However, significant requests may induce the NHL to throttle or ban your IP address and prevent you from getting data. If using this API, please rate limit yourself.
Rate limiting may be added in future versions.
All data, teams, logos, and information is copyright NHL and its teams, with compliance to the copyright statement recieved from the API call (from getCopyright()
).