Skip to main content

Low-dependency pacakge for pulling NHL data across multiple sources

Project description

NHLData

NHLData is a low dependecy Python package for pulling NHL data from multiple sources. Output is either a list or a list of dictionaries for all calls, allowing the end user to manipulate or store data as thier project requires.

Requirements

  • Python >- 3.8
  • requests

Installation

pip install nhldata

Data Sources

NHL APIs

The first module here is nhl_api which is a module built to connect to the two public facing NHL APIs. The endpoint documentation is based on NHL-API-Reference by Zmalski.

There are two classes (WebConnector and StatsConnector), each with unique calls inside. It is highly recommended that you reference Zmalski's work to understand what each call is doing, but there are docstrings for each function in the classes.

WebConnector Usage

from nhldata import nhl

# Make connectors for the API endpoints
nhl_web = nhl.WebConnector()

# Call the API and return data
nhl_web.roster(team=COL,season=2023)

StatsConnector Usage

from nhldata import nhl

# Make connectors for the API endpoints
nhl_stats = nhl.StatsConnector()

# Call the API and return data
nhl_stats.leaders(pos='skaters', attr='points')

MoneyPuck.com

The second module is designed to access the available data from MoneyPuck.com. This is a series of .csv files that are converted to lists of dictionaries.

Of particular interest here is the shots data that MoneyPuck has going back to 2007/2008. THese are transported as .zip files and unpacked into list/dict structures for consumption. Per MoneyPuck:

All historical shot data is available to download. This includes 1,717,746 shots from the 2007-2008 to 2022-2023 seasons. Data for the 2023-2024 season is also available and updated nightly on this page. Saved shots on goal, missed shots, and goals are included. Blocked shots are not included in these datasets. There are 124 attributes for each shot, including everything from the player and goalie involved in the shot to angles, distances, what happened before the shot, and how long players had been on the ice when the shot was taken. Each shot also has model scores for its probability of being a goal (xGoals) as well as other models such as for the chance there will be a rebound after the shot, the probability the shot will miss the net, and whether the goalie will freeze the puck after the shot. The data has been collected from several sources including the NHL and ESPN. A good amount of data cleaning has also been done on the data. Arena adjusted shot coordinates and distances are also calculated in the dataset using the strategy War-On-Ice used from the method proposed by Schuckers and Curros.

Moneypuck Usage

from nhldata import moneypuck

# Make connectors for the file endpoints
moneypuck = moneypuck.Connector()

# Pull the file(s) and return the raw data
moneypuck.season_stats(file_type='skaters',seasons=[2022,2023],gametype='regular')

Additional Sources

If you know of another strong data soucre for NHL stats date, please let me know/submit a push request and we can get it added here. Happy to talk about expected format and such.

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

nhldata-0.0.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nhldata-0.0.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file nhldata-0.0.2.tar.gz.

File metadata

  • Download URL: nhldata-0.0.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for nhldata-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ea0c3d9d60dee07680aa5ad39c892c8d25117b6596d90685b20f9f784d796751
MD5 f81ece65df4dbebba38dbac8aa93ba22
BLAKE2b-256 2f3edc75424a64157f74d4f4770f0ea1150bdfe37a58eed320616c6e1dab9c4c

See more details on using hashes here.

File details

Details for the file nhldata-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: nhldata-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for nhldata-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 951bc8df117655d036e1fae288717b70fff032bc8679b4478fcbea7251c060d8
MD5 15fbc70cbdd701c51589dfc8bc7b4e52
BLAKE2b-256 e85bfe31ac8ddedff478dfbf701965f7c741c2ae0a85ee43e4c03847551fd538

See more details on using hashes here.

Supported by

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