Skip to main content

NHL API Wrapper. For standings, team stats and outcomes.

Project description

PyPI version

NHL-API-PY

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.

Example Notebook:

An example Collab notebook can be found here at coreyjs/nhl-api-py-examples.

Installation

You can install NHL-py-api using pip:

pip install nhl-api-py

Usage

from nhlpy import NHLClient

client = NHLClient()

Available methods:

client.teams.all()
client.teams.get_by_id(id=1, roster=False)
client.teams.get_team_next_game(id=1)
client.teams.get_team_previous_game(id=1)
client.teams.get_team_stats(id=1)

# Standings
client.standings.get_standings(season="20222023", detailed_record=False)
client.standings.get_standing_types()

# Player Stats
client.players.get_player_stats(person_id=8477949, season="20222023", stat_type="statsSingleSeason")
client.players.get_player_stats(person_id=8477949, season="20222023", stat_type="goalsByGameSituation")
client.players.get_player_stats(person_id=8477949, season="20222023", stat_type="yearByYear")

As mentioned at the top, I created a notebook to go over some of the available methods in more detail. Below is an export md of that notebook, with out cell executions.

pip install nhl-api-py
from nhlpy import NHLClient

Getting Started - Create the NHLClient

client = NHLClient()

Team APIs

teams = client.teams.all()
teams
buffalo = client.teams.get_by_id(id=7)
buffalo
next_buffalo_game = client.teams.get_team_next_game(id=7)
next_buffalo_game
prev_buffalo_game = client.teams.get_team_previous_game(id=7)
prev_buffalo_game
buffalo_with_stats = client.teams.get_team_with_stats(id=7)
buffalo_with_stats
buffalo_roster = client.teams.get_team_roster(id=7)
buffalo_roster
buffalo_full_team_stats = client.teams.get_team_stats(id=7)
buffalo_full_team_stats

Standing APIs

# These can be used in conjunction with get_standings_by_standing_type
all_standing_types = client.standings.get_standing_types()
all_standing_types
# standings by season
all_standings = client.standings.get_standings(season="20222023", detailed_record=False)
all_standings
# same as above but with more detailed information
# standings by season
all_standings = client.standings.get_standings(season="20222023", detailed_record=True)
all_standings
# Get standings by type, types can be found via get_standings_by_type, or in the docstring
post_season = client.standings.get_standings_by_standing_type(standing_type="regularSeason")
post_season

Players

# APIs to access player information.  Requires person_id, found from `teams.get_team_roster()`
jj = client.players.get_player(person_id=8482175)
jj
jj_stats = client.players.get_player_stats(person_id=8482175, season="20222023", stat_type="statsSingleSeason")
jj_stats
# Differnt stat types you can access
types = client.players.get_player_stat_types()
types


Developers

poetry install --with dev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nhl_api_py-0.2.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

nhl_api_py-0.2.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file nhl_api_py-0.2.0.tar.gz.

File metadata

  • Download URL: nhl_api_py-0.2.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for nhl_api_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 87854bfca68b06b4e4c472fa619217c1b6e31b07098a1af40fd0852ff375838c
MD5 3b901c7627ac91b0ba94df15dcd4418b
BLAKE2b-256 2b80d546562188f3cf479c6520dd3520ba345e55b7aeef3527413d7a61143ce8

See more details on using hashes here.

File details

Details for the file nhl_api_py-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nhl_api_py-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for nhl_api_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c57934a144f74838ad74c4b8d886b772f4b5ada4f8bb6395f8664ab364da597
MD5 a69781e049eb1005ecc6ba1ee8f1ecb2
BLAKE2b-256 8f897d5d7da7441ec59053b7e6a8f411d4d214f33ff0b5395f74ece428845646

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page