Skip to main content

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.

Metadata

Release files for nhldata 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nhldata 0.0.2
File Size Uploaded
nhldata-0.0.2.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nhldata 0.0.2
File Interpreter ABI Platform
nhldata-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / nhldata-0.0.2.tar.gz

Download URL nhldata-0.0.2.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ea0c3d9d60dee07680aa5ad39c892c8d25117b6596d90685b20f9f784d796751
BLAKE2b-256 checksum
How to use checksums
2f3edc75424a64157f74d4f4770f0ea1150bdfe37a58eed320616c6e1dab9c4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / nhldata-0.0.2-py3-none-any.whl

Download URL nhldata-0.0.2-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
951bc8df117655d036e1fae288717b70fff032bc8679b4478fcbea7251c060d8
BLAKE2b-256 checksum
How to use checksums
e85bfe31ac8ddedff478dfbf701965f7c741c2ae0a85ee43e4c03847551fd538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page