Learn R Programming

⚠️There's a newer version (0.1.4) of this package.Take me there.

nhlapi

A minimum-dependency R interface to the NHL API.

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 package:

remotes::install_github("jozefhajnala/nhlapi")

Usage

You 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 autocomplete in your favourite editor:

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 in https://gitlab.com/dword4/nhlapi/blob/master/stats-api.md

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 2020. All Rights Reserved.

Copy Link

Version

Install

install.packages('nhlapi')

Monthly Downloads

223

Version

0.1.2

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Jozef Hajnala

Last Published

May 25th, 2020

Functions in nhlapi (0.1.2)

nhl_from_json

Get URL using fromJSON
nhl_tournaments

Retrieve data on tournaments from the API
nhl_url_add_suffixes

Add suffixes to URLs
nhl_url_awards

Create an NHL API URL for awards
nhl_url_tournaments

Create an NHL API URL for tournaments
util_convert_minsonice

Convert "mm:ss" character to numeric minutes
nhl_url_teams

Create an NHL API URL for teams
util_attributes_to_cols

Add attributes as data frame columns
nhl_games

Retrieve metadata on NHL games from the API
nhl_make_seasons

Make a vector of seasons consumable by the API
nhl_md_event_types

Get event types metadata
make_log

Create a log message
nhl_teams_shedule_next

Get details for the teams' upcoming game
nhl_teams_shedule_previous

Get details for the teams' previous game
util_generate_sysdata

Generate the sysdata.rda file
nhl_url_players_allseasons

Create an NHL API URL for all players' seasons statistics
util_inherit_attributes

Inherit attributes from another object
nhl_url_players_seasons

Create an NHL API URL for players' seasons statistics
nhl_url_drafts

Create an NHL API URL for drafts
nhl_divisions

Retrieve metadata on NHL divisions from the API
nhl_url_venues

Create an NHL API URL for venues
nhl_url_draft_prospects

Create an NHL API URL for draft prospects
nhl_awards

Retrieve metadata on NHL awards from the API
nhl_players

Retrieve metadata for players based on names or ids
nhl_md_play_types

Get play types metadata
nhl_players_seasons

Retrieve selected seasons statistics for players
nhl_schedule

Retrieve metadata on NHL schedule from the API
nhl_players_allseasons

Retrieve all seasons statistics for players
nhl_md_standings_types

Get standings types metadata
nhl_venues

Retrieve metadata on NHL venues from the API
nhl_drafts

Retrieve metadata on NHL drafts from the API
nhl_md_game_statuses

Get game status metadata
nhl_md_game_types

Get game type metadata
nhl_draft_prospects

Retrieve metadata on NHL draft prospects from the API
util_md5sum_str

Get MD5 hash for a character vector
nhl_url

Create an NHL API URL
nhl_url_add_params

Add parameters to URLs
nhl_teams

Retrieve metadata on NHL teams from the API
nhl_url_games

Create an NHL API URL for games
nhl_standings

Retrieve metadata on NHL standings from the API
nhl_seasons

Retrieve metadata on NHL seasons from the API
util_prepare_player_ids

Prepare player ids based on player names
nhl_url_schedule

Create an NHL API URL for schedules
util_map_player_id

Retrieve a player id from the name
util_map_player_ids

Retrieve a player ids from their names
nhl_url_players_stats

Create an NHL API stats URL for players
nhl_url_players

Create an NHL API URL for players
nhl_teams_rosters

Get rosters for teams
util_process_minsonice

Convert time columns from "mm:ss" to numeric minutes
nhl_url_divisions

Create an NHL API URL for divisions
util_process_copyright

Move copyright information to attribute
nhl_url_conferences

Create an NHL API URL for conferences
util_rbindlist

Safely rbind multiple data.frames
util_report_get_data_errors

Report errors encountered during nhl_get_data
nhl_url_seasons

Create an NHL API URL for seasons
nhl_url_standings

Create an NHL API URL for standings
nhl_conferences

Retrieve metadata on NHL conferences from the API
nhl_get_data

Get data from the API for one or more URLs
nhl_get_data_worker

Get data from the API for 1 URL
nhl_md_stat_types

Get stat types metadata
nhl_md_tournament_types

Get tournament types metadata
nhl_teams_stats

Get team statistics per seasons