How do I get NHL opening and closing odds by sportsbook in Python?
Every sportsbook's opening and closing moneyline and puck line for a game, so you can measure how far the price moved.
Code verified November 18, 2026. One call to get_odds, 10 credits.
The call
Pass bookmaker to keep one book, or snapshot_type to keep only openings or closings.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.puckapi.com/v1/get_odds",
headers={"x-api-key": API_KEY},
json={
"game_id": "2025020002",
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
odds = pd.DataFrame(data["odds"])
print(data["away_team"], "at", data["home_team"], data["game_date"])
ml = odds.pivot_table(index="bookmaker", columns="snapshotType", values="mlHome")
print(ml)
print(odds[odds["snapshotType"] == "closing"][["bookmaker", "mlHome", "mlAway", "spreadHome", "spreadHomeOdds"]])
Replace YOUR_API_KEY with a key from your dashboard. Python needs requests and pandas (pip install requests pandas). JavaScript runs on Node 18 or newer, or in the browser.
Or use the official client: pip install puckapi
What comes back
The data object of the response, trimmed to the first rows. Every field is real output from the run above.
{
"game_id": "2025020002",
"home_team": "NYR",
"away_team": "PIT",
"game_date": "2025-10-07",
"odds": [
{
"bookmaker": "betmgm",
"snapshotType": "closing",
"mlHome": -235,
"mlAway": 190,
"spreadHome": -1.5,
"spreadHomeOdds": 105,
"spreadAway": 1.5,
"spreadAwayOdds": -125,
"capturedAt": "2025-10-07T22:55:02.000Z"
},
{
"bookmaker": "betmgm",
"snapshotType": "early_opening",
"mlHome": -225,
"mlAway": 185,
"spreadHome": -1.5,
"spreadHomeOdds": 115,
"spreadAway": 1.5,
"spreadAwayOdds": -135,
"capturedAt": "2025-10-06T23:54:46.000Z"
},
"...10 more"
],
"bookmaker_count": 8
}What to do next
- get_line_movement (25 credits). The full time series of a game's line by bookmaker.
- get_game_detail (10 credits). The result and goalie starts, to grade the price.
The data this uses
Every row above comes from NHL historical odds and closing lines and NHL player props by sportsbook, from 2023. Moneyline, puck line and total for every NHL game since 2019-20, by sportsbook: 16 to 18 books a game to 2023-24, 8 since, 60+ on about 300 in 2025-26. REST or MCP.
More guides
The same guide for other sports
- EndzoneAPI: How do I backtest NFL closing lines in Python?
- FighterAPI: How do I compare UFC closing odds with fight results in Python?
- StrikerAPI: How do I get Premier League odds from every sportsbook with the results?
- DunkAPI: How do I backtest NBA closing lines in Python?
- AcesAPI: How do I compare ATP closing odds with the result and Elo in Python?
- BirdieAPI: How do I turn golf major winner odds into probabilities in Python?
- FastballAPI: How do I backtest MLB closing moneylines and run totals in Python?
- YorkerAPI: How do I get historical cricket odds in Python?
The latest lines from every book are on the odds board. Rather ask Claude? 28 free Claude skills call these endpoints for you.
Start with 500 free credits every month
No card. REST or MCP.