Created
May 22, 2026 21:03
-
-
Save coreyjs/16688951cbc39e9e6687c06eef46cace to your computer and use it in GitHub Desktop.
player stats for season
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The NHL API is a little wonky with how they structure data. But here are some examples: | |
| # 1. Getting a players career stats, so across all seasons. But its all summarized and not broken down | |
| # by year so its kinda confusing | |
| p = client.stats.player_career_stats(player_id="8481528”) | |
| # To get a single players season data its not as easy as you would think, | |
| # you were correct on the game log. That being said maybe the NHL released some new APIs to dig into, but for now. | |
| # For this you can swap the season_id to any previous season, and it works mid season. | |
| games = client.stats.player_game_log(player_id="8478402", season_id="20252026", game_type=2) | |
| totals = { | |
| "goals": sum(g["goals"] for g in games), | |
| "assists": sum(g["assists"] for g in games), | |
| "points": sum(g["points"] for g in games), | |
| "shots": sum(g["shots"] for g in games), | |
| } | |
| # { | |
| # "goals": 48, | |
| # "assists": 90, | |
| # "points": 138, | |
| # "shots": 306 | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment