Skip to main content

A package to pull NHL historical data, and create the objects to hold the data.

Project description

NHL Core

Build GitHub latest commit

The National Hockey League (NHL) was kind enough to provide all of the historical data on a free web interface. This library was created to parse the data that is retrieved from the api. After json data is retrieved it can be parsed by passing it to an NHLData python object. The documentation can be found here.

Example

In the following example, the data for a single team is retrieved.

from nhl import NHLData, API_TEAM_ENDPOINT
from requests import get

json_data = get(API_TEAM_ENDPOINT).json()
if 'teams' in json_data:
    print(NHLData(json_data['teams'][0]))

The result is the following:

{
    "id": 1,
    "name": "New Jersey Devils",
    "link": "/api/v1/teams/1",
    "venue": {
        "name": "Prudential Center",
        "link": "/api/v1/venues/null",
        "city": "Newark",
        "timeZone": {
            "id": "America/New_York",
            "offset": -4,
            "tz": "EDT"
        }
    },
    "abbreviation": "NJD",
    "teamName": "Devils",
    "locationName": "New Jersey",
    "firstYearOfPlay": "1982",
    "division": {
        "id": 18,
        "name": "Metropolitan",
        "nameShort": "Metro",
        "link": "/api/v1/divisions/18",
        "abbreviation": "M"
    },
    "conference": {
        "id": 6,
        "name": "Eastern",
        "link": "/api/v1/conferences/6"
    },
    "franchise": {
        "franchiseId": 23,
        "teamName": "Devils",
        "link": "/api/v1/franchises/23"
    },
    "shortName": "New Jersey",
    "officialSiteUrl": "http://www.newjerseydevils.com/",
    "franchiseId": 23,
    "active": true
}

The user could also access the values directly. For instance getting the teamName would require:

print(NHLData(json_data['teams'][0].teamName))

The user can also access nested values:

print(NHLData(json_data['teams'][0].franchise.franchiseId))

Copyright

All data is owned by the NHL. The result of each query will contain a copyright that should be included in all work. An example is shown below:

NHL and the NHL Shield are registered trademarks of the National Hockey League. NHL and NHL team marks are the property of the NHL and its teams. © NHL 2023. All Rights Reserved.

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_core-0.0.0.tar.gz (58.1 kB view hashes)

Uploaded Source

Built Distribution

nhl_core-0.0.0-py3-none-any.whl (20.8 kB view hashes)

Uploaded Python 3

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