Posts

Showing posts from May, 2023

NHL API: Get NHL Career Stats

  Introduction The NHL has a publicly accessible Application Programming Interface (or  API ) that allows users to obtain a lot of useful data (including detailed play-by-play data). There are a couple of obstacles though: 1) the NHL API does not come with a user manual; and 2) the NHL API is most easily accessed using a programming language such as R or Python. To help you overcome those obstacles I’m writing articles that provide the code (in the R programming language) for functions that pull data from the NHL API. In this article I provide a function that pulls a skater’s NHL career stats. The Data Before I provide the code, here’s a sample of the data. player_id:  8478402 player:  Connor McDavid gp:  569 toi_as:  742323 toi_es:  600275 toi_pp:  119736 toi_sh:  22312 goals:  303 assists:  547 points:  850 shots:  1948 hits:  375 blocks:  223 pim:  219 goals_es:  225 goals_pp:  71 goals_sh:  7 goals_ot:  15 assists_es:  320 assists_pp:  218 assists_sh:  9 points_pp:  289 points_sh: 

NHL API: Get Year-By-Year Stats

  Introduction The NHL has a publicly accessible Application Programming Interface (or  API ) that allows users to obtain a lot of useful data (including detailed play-by-play data). There are a couple of obstacles though: 1) the NHL API does not come with a user manual; and 2) the NHL API is most easily accessed using a programming language such as R or Python. To help you overcome those obstacles I’m writing articles that provide the code (in the R programming language) for functions that pull data from the NHL API. In this article I provide a function that pulls a skater’s yearly stats for the NHL. The function also pulls stats for other leagues (such as the AHL) to the extent those stats are available. The Data Before I provide the code, here’s a sample of the data. Note: I included the stats for only one season in this sample. The function pulls these same stats for every year that they’re available. player_id:  8478402 player:  Connor McDavid season:  20222023 league_id:  133 lea

NHL API: Get Single Season Stats

  Introduction The NHL has a publicly accessible Application Programming Interface (or  API ) that allows users to obtain a lot of useful data (including detailed play-by-play data). There are a couple of obstacles though: 1) the NHL API does not come with a user manual; and 2) the NHL API is most easily accessed using a programming language such as R or Python. To help you overcome those obstacles I’m writing articles that provide the code (in the R programming language) for functions that pull data from the NHL API. In this article I provide a function that pulls a skater’s single season stats. The Data Before I provide the code, here’s a sample of the data. player_id:  8478402 player:  Connor McDavid season:  20222023 gp:  82 toi_as:  110137 toi_es:  84569 toi_pp:  19313 toi_sh:  6255 goals:  64 assists:  89 points:  153 shots:  352 hits:  89 blocks:  40 pim:  36 goals_es:  39 goals_pp:  21 goals_sh:  4 goals_ot:  2 assists_es:  36 assists_pp:  50 assists_sh:  3 points_pp:  71 point

NHL API: Get Game Logs

  Introduction The NHL has a publicly accessible Application Programming Interface (or  API ) that allows users to obtain a lot of useful data (including detailed play-by-play data). There are a couple of obstacles though: 1) the NHL API does not come with a user manual; and 2) the NHL API is most easily accessed using a programming language such as R or Python. To help you overcome those obstacles I’m writing articles that provide the code (in the R programming language) for functions that pull data from the NHL API. In this article I provide a function that pulls a skater’s regular season game logs. The Data Before I provide the code, here’s a sample of the data. player_id:  8478402 player:  Connor McDavid season:  20222023 game_id:  2022021308 date:  2023-04-13 toi_as:  916 toi_es:  673 toi_pp:  232 toi_sh:  11 goals:  0 assists:  1 points:  1 shots:  5 hits:  0 blocks:  1 pim:  0 goals_es:  0 goals_pp:  0 goals_sh:  0 goals_ot:  0 assists_es:  0 assists_pp:  1 assists_sh:  0 points

NHL API: Get Schedule

  Introduction The NHL has a publicly accessible Application Programming Interface (or  API ) that allows users to obtain a lot of useful data (including detailed play-by-play data). There are a couple of obstacles though: 1) the NHL API does not come with a user manual; and 2) the NHL API is most easily accessed using a programming language such as R or Python. To help you overcome those obstacles I’m writing articles that provide the code (in the R programming language) for functions that pull data from the NHL API. In this article I provide a function that pulls schedule data. The Data Before I provide the code, here’s a sample of the data. game_id:  2022030245 season:  20222023 game_type:  P date:  2023-05-12 home_team_id:  54 home_team:  Vegas Golden Knights away_team_id:  22 away_team:  Edmonton Oilers The Code Here’s the code for the function that pulls the above data. # This function pulls the NHL schedule for a specified time period # The date format is "YYYY-MM-DD"

NHL API: Get Team Rosters

  Introduction The NHL has a publicly accessible Application Programming Interface (or  API ) that allows users to obtain a lot of useful data (including detailed play-by-play data). There are a couple of obstacles though: 1) the NHL API does not come with a user manual; and 2) the NHL API is most easily accessed using a programming language such as R or Python. To help you overcome those obstacles I’m writing articles that provide the code (in the R programming language) for functions that pull data from the NHL API. In this article I provide a function that pulls detailed roster data for each NHL team. The Data Before I provide the code, here’s the data it pulls: player_id:  8478402 player:  Connor McDavid team_id:  22 team:  Edmonton Oilers position:  C age:  26 dob:  1997-01-13 nationality:  CAN height:  6’ 1” weight:  193 shoots_catches:  L number:  97 The Code Here’s the code for the function that pulls the above data. get_team_rosters <- function () { # Creat