NHL API. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods for easy data loading in Pandas or any ML applications.
Project description
NHL-API-PY
This is being updated with the new, also undocumented, NHL API.
More endpoints will be flushed out and completed as they are discovered. If you find any, please submit a PR.
About
NHL-api-py is a Python package that provides a simple wrapper around the NHL API, allowing you to easily access and retrieve NHL data in your Python applications.
Note: This is very early, I created this to help me with some machine learning projects around the NHL and the NHL data sets. Special thanks to https://github.com/erunion/sport-api-specifications/tree/master/nhl and https://gitlab.com/dword4/nhlapi/-/blob/master/stats-api.md.
Usage
from nhlpy import NHLClient
client = NHLClient()
# OR
client = NHLClient(verbose=True) # a tad more logging such as the URL being called
Schedule Endpoints
client.schedule.get_schedule(date="2021-01-13")
client.schedule.get_schedule()
client.schedule.get_schedule_by_team_by_month(team_abbr="BUF")
client.schedule.get_schedule_by_team_by_month(team_abbr="BUF", month="2021-01")
client.schedule.get_schedule_by_team_by_week(team_abbr="BUF")
client.schedule.get_season_schedule(team_abbr="BUF", season="20212022")
client.schedule.schedule_calendar(date="2023-11-23")
Standings Endpoints
client.standings.get_standings()
client.standings.get_standings(date="2021-01-13")
client.standings.get_standings(season="202222023")
# standings manifest. This returns a ton of information for every season ever it seems like
# This calls the API for this info, I also cache this in /data/seasonal_information_manifest.json
# for less API calls since this only changes yearly.
client.standings.season_standing_manifest()
Teams Endpoints
client.teams.teams_info() # returns id + abbrevation + name of all teams
client.teams.team_stats_summary(lang="en") # I honestly dont know. This is missing teams and has teams long abandoned.
Game Center
client.game_center.boxscore(game_id="2023020280")
client.game_center.play_by_play(game_id="2023020280")
client.game_center.landing(game_id="2023020280")
client.game_center.score_now()
Insomnia Rest Client Export
Insomnia Rest Client is a great tool for testing
nhl_api-{ver}.json in the root folder is an export of the endpoints I have been working through using the Insomnia Rest Client. You can import this directly into the client and use it to test the endpoints. I will be updating this as I go
Developers
- Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
or using pipx
pipx install poetry
-
poetry install --with dev
-
poetry shell
$ poetry shell
# You can then run the following
$ pytest
$ ruff .
$ black .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nhl_api_py-2.1.0.tar.gz
.
File metadata
- Download URL: nhl_api_py-2.1.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b7845d9660b1da914bc5afa97085fbff52df002dba2738dd8fa2b959ba23c1b |
|
MD5 | 65b110a0a5bebca3729bdff91e00af5f |
|
BLAKE2b-256 | 5c5f0b42c4bcb575e70ad5d1f3d832d5322600696de774efbf9e8df268268ee2 |
File details
Details for the file nhl_api_py-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: nhl_api_py-2.1.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.0 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b00329bfe22d96521635a9f3bbfaf63e36d3065dbb9a9b12d8692cf7ea9e8d87 |
|
MD5 | 55a1dfa867c2c06295ddc106925df328 |
|
BLAKE2b-256 | 628c6f17336db64a5bb43770dcd9273a1adef6afa437f1bf44883a50ae2d0d63 |