-
-
Notifications
You must be signed in to change notification settings - Fork 14
Home
Corey Schaf edited this page Oct 21, 2025
·
5 revisions
Examples of Usage
- Load summary statistics for all players for a given season.
from nhlpy.nhl_client import NHLClient
def load_summary_statistics_for_skaters(season_start, season_end, limit: int = 100):
"""
season_start/end in format YYYYYYYY, such as 20252026 for 2025-2026
"""
from nhlpy.api.query.builder import QueryBuilder, QueryContext
from nhlpy.api.query.filters.season import SeasonQuery
from nhlpy.api.query.filters.game_type import GameTypeQuery
filters = [
SeasonQuery(season_start=season_start, season_end=season_end),
GameTypeQuery(game_type="2"),
]
context: QueryContext = QueryBuilder().build(filters=filters)
all_data = []
start = 0
client = NHLClient(debug=False)
while True:
response = client.stats.skater_stats_with_query_context(
report_type='summary',
query_context=context,
aggregate=True,
limit=limit,
start=start
)
total = response['total']
batch_data = response['data']
all_data.extend(batch_data)
if len(all_data) >= total:
break
start += limit
return all_datasummary_stats = summary_stats = load_summary_statistics_for_skaters(season_start="20252026", season_end="20252026") summary_stats[0]
{'assists': 10,
'evGoals': 6,
'evPoints': 8,
'faceoffWinPct': 0.51587,
'gameWinningGoals': 1,
'gamesPlayed': 7,
'goals': 6,
'lastName': 'Eichel',
'otGoals': 0,
'penaltyMinutes': 0,
'playerId': 8478403,
'plusMinus': 7,
'points': 16,
'pointsPerGame': 2.28571,
'positionCode': 'C',
'ppGoals': 0,
'ppPoints': 8,
'shGoals': 0,
'shPoints': 0,
'shootingPct': 0.17647,
'shootsCatches': 'R',
'shots': 34,
'skaterFullName': 'Jack Eichel',
'timeOnIcePerGame': 1248.4285}