PuckAPI for Python
Python client for the PuckAPI NHL data API. It has no required dependencies (standard library only) and works on Python 3.9 and newer. Pandas is optional.
Install
pip install puckapi
pip install "puckapi[pandas]" # only if you want DataFrames
Set your key
Get a free key at https://puckapi.com/signup. Free accounts get 500 credits a month.
export PUCKAPI_API_KEY=your_key_here
from puckapi import Client
client = Client() # reads PUCKAPI_API_KEY
client = Client(api_key="your_key") # or pass it in
Examples
1. Closing odds for a game
get_odds returns one row per bookmaker and snapshot. Ask for the closing snapshot and load it into pandas.
from puckapi import Client, to_dataframe
client = Client()
odds = client.get_odds(game_id="2026020080", snapshot_type="closing")
df = to_dataframe(odds, key="odds")
print(df[["bookmaker", "mlHome", "mlAway", "total"]])
print("credits left:", client.last_credits_remaining)
2. Who played the most minutes (shift data)
get_shifts returns every shift for every skater in a game, with start and end times.
from puckapi import Client
client = Client()
shifts = client.get_shifts(game_id="2026020080", team="TOR")
busiest = sorted(shifts["players"], key=lambda p: p["shift_seconds"], reverse=True)[:5]
for p in busiest:
print(p["name"], p["shift_count"], "shifts,", p["shift_seconds"] // 60, "min")
3. A player's recent games
Find a player id with search_players, then pull the game log.
from puckapi import Client
client = Client()
match = client.search_players("Matthews", limit=1)["players"][0]
log = client.get_player_game_log(match["id"], season="20252026", limit=5)
print(match["name"], log)
Credits
Every method returns the data object from the response. After each call, client.last_credits_used and client.last_credits_remaining hold the counters from the X-Credits-Used and X-Credits-Remaining headers. Methods that take estimate_only=True return the price of a call without running or charging it.
Pandas
from puckapi import to_dataframe
df = to_dataframe(data) # finds the main list in the response
df = to_dataframe(data, key="rows") # or name the list yourself
Nested fields become dotted columns. Install pandas separately or with pip install "puckapi[pandas]".
Errors
Every error is an APIError subclass, with the server's message and the HTTP status.
| Exception | Status | Meaning |
|---|---|---|
AuthError |
401 | Missing, invalid or revoked key |
InsufficientCreditsError |
402 | Not enough credits for the call |
NotFoundError |
404 | The id or name does not exist |
RateLimitError |
429 | Too many requests; has .retry_after when the server sends it |
APIError |
400, 5xx | Bad arguments or a server problem |
APIConnectionError |
none | No response (network or timeout) |
from puckapi import Client, APIError, InsufficientCreditsError, RateLimitError
client = Client()
try:
data = client.list_teams()
except InsufficientCreditsError:
print("Out of credits, top up at https://puckapi.com")
except RateLimitError as exc:
print("Slow down, retry after", exc.retry_after)
except APIError as exc:
print(exc.status_code, exc.message)
The client retries 429 and 5xx responses and connection failures up to 3 times with backoff, and honors Retry-After. Set Client(max_retries=0) to turn that off.
If you see CERTIFICATE_VERIFY_FAILED on a python.org install for macOS, run the "Install Certificates.command" script that came with Python, or pip install certifi (the client uses it when present).
Options
Client(
api_key=None, # defaults to $PUCKAPI_API_KEY
base_url="https://mcp.puckapi.com", # point at another host
timeout=60.0, # seconds per request
max_retries=3,
)
client.call("tool_name", {"arg": "value"}) calls any tool by name, which helps when the API adds a tool before this package does.
Tools
Method names match the API tool names. Arguments are keyword arguments; required ones can also be passed positionally. Each method's docstring lists its arguments (help(client.list_teams)).
| Method | Credits | What it does |
|---|---|---|
get_standings |
2 | Standings |
get_team_stats |
5 | Team stats |
list_teams |
1 | List teams |
get_games |
5 | Games |
get_schedule |
2 | Schedule |
get_game_detail |
10 | Game detail |
get_head_to_head |
10 | Head to head |
search_players |
2 | Search players |
get_player_stats |
5 | Player stats |
get_goalie_stats |
5 | Goalie stats |
get_skater_season_stats |
5 | Skater season stats |
get_player_game_log |
5 | Player game log |
get_odds |
10 | Odds |
get_line_movement |
25 | Line movement |
get_player_props |
10 | Player props |
get_prop_history |
10 | Prop history |
get_plays |
10 | Plays |
get_shot_map |
10 | Shot map |
get_shifts |
10 | Shifts |
get_situation_time |
10 | Situation time |
Full API reference: https://puckapi.com/docs
License
MIT
Metadata
Release files for puckapi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| puckapi-0.1.0.tar.gz | 16.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| puckapi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.4 kB
Release files / puckapi-0.1.0.tar.gz
| Download URL | puckapi-0.1.0.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8886b5ca5ddc6ded17a751ef826fb1bc06f69a93457e3b446f3cb17d015a08d0
|
|
BLAKE2b-256 checksum How to use checksums |
23b8d4f685907769f4fe506f5bdbe58dce6ae3a49e85e65002abf4c09b9858c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / puckapi-0.1.0-py3-none-any.whl
| Download URL | puckapi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fa5d9ad868d728ebd031df3cabbfb8c89a2f086fbf401cb8d24df0d854efd72
|
|
BLAKE2b-256 checksum How to use checksums |
be42d6db05a51921245e477a4a982f7fc7dcc55eb87966bec77c13226ab1b613
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency log