Edgework Client¶
The main client class for interacting with NHL APIs.
Main Client Class¶
edgework.Edgework(user_agent='EdgeworkClient/2.0')
¶
Initializes the Edgework API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_agent
|
str
|
The User-Agent string to use for requests. Defaults to "EdgeworkClient/2.0". |
'EdgeworkClient/2.0'
|
players(active_only=True)
¶
Fetch a list of players.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
active_only
|
bool
|
If True, fetch only active players. If False, fetch all players (active and inactive). Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
list[Player]
|
list[Player]: A list of Player objects. |
skater_stats(season, report='summary', sort='points', direction='DESC', aggregate=False, limit=10, game_type=2)
¶
Fetch skater stats for a given season. Args: season (str): The season to fetch stats for (e.g., "2024-2025"). report (str): The type of report to fetch (e.g., "summary", "detailed"). sort (str | list[str]): The field to sort the results by (e.g., "points", "goals"). direction (str | list[str]): The direction to sort the results (e.g., "DESC", "ASC"). aggregate (bool): Whether to aggregate the stats. Defaults to False. limit (int): The maximum number of results to return.
Returns:
| Name | Type | Description |
|---|---|---|
SkaterStats |
SkaterStats
|
An instance of the SkaterStats model, populated with the fetched data.
The actual player statistics can be accessed via |
goalie_stats(season, report='summary', sort='wins', direction='DESC', is_aggregate=False, limit=10)
¶
Fetch goalie stats for a given season. Args: season (str): The season to fetch stats for (e.g., "2024-2025"). report (str): The type of report to fetch (e.g., "summary", "detailed"). sort (str): The field to sort the results by (e.g., "wins", "goalsAgainst"). is_aggregate (bool): Whether to aggregate the stats. Defaults to False. limit (int): The maximum number of results to return.
Returns:
| Name | Type | Description |
|---|---|---|
GoalieStats |
GoalieStats
|
An instance of the GoalieStats model, populated with the fetched data.
The actual goalie statistics can be accessed via |
team_stats(season, report='summary', sort='points', direction='DESC', limit=10, aggregate=False, game=True)
¶
Fetch team stats for a given season. Args: season (str): The season to fetch stats for (e.g., "2024-2025"). report (str): The type of report to fetch (e.g., "summary", "detailed"). sort (dict): The field to sort the results by (e.g., "points", "wins"). limit (int): The maximum number of results to return. Defaults to 10. aggregate (bool): Whether to aggregate the stats. Defaults to False.
Returns:
| Name | Type | Description |
|---|---|---|
TeamStats |
TeamStats
|
An instance of the TeamStats model, populated with the fetched data.
The actual team statistics can be accessed via |
get_teams()
¶
Fetch a list of all NHL teams.
Returns:
| Type | Description |
|---|---|
list[Team]
|
list[Team]: A list of Team objects. |
get_roster(team_code, season=None)
¶
Fetch a roster for a specific team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_code
|
str
|
The team code (e.g., 'TOR', 'NYR'). |
required |
season
|
str
|
The season in format "YYYY-YYYY" (e.g., "2023-2024"). If None, gets current roster. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Roster |
Roster
|
A Roster object containing the team's players. |
get_team_stats(team_code, season=None, game_type=2)
¶
Get team statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_code
|
str
|
The team code (e.g., 'TOR', 'NYR'). |
required |
season
|
str
|
The season in format "YYYY-YYYY" (e.g., "2023-2024"). If None, gets current season stats. |
None
|
game_type
|
int
|
Game type (2 for regular season, 3 for playoffs). Default is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Team statistics data. |
get_team_schedule(team_code, season=None)
¶
Get team schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_code
|
str
|
The team code (e.g., 'TOR', 'NYR'). |
required |
season
|
str
|
The season in format "YYYY-YYYY" (e.g., "2023-2024"). If None, gets current season schedule. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Team schedule data. |
get_team_prospects(team_code)
¶
Get team prospects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_code
|
str
|
The team code (e.g., 'TOR', 'NYR'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Team prospects data. |
get_team_scoreboard(team_code)
¶
Get team scoreboard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_code
|
str
|
The team code (e.g., 'TOR', 'NYR'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Team scoreboard data. |
get_schedule()
¶
Get the current NHL schedule.
Returns:
| Name | Type | Description |
|---|---|---|
Schedule |
Schedule
|
Current NHL schedule with games and season information. |
get_schedule_for_date(date)
¶
Get the NHL schedule for a specific date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
str
|
The date in format 'YYYY-MM-DD'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Schedule |
Schedule
|
NHL schedule for the specified date. |
get_schedule_for_date_range(start_date, end_date)
¶
Get the NHL schedule for a date range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_date
|
str
|
The start date in format 'YYYY-MM-DD'. |
required |
end_date
|
str
|
The end date in format 'YYYY-MM-DD'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Schedule |
Schedule
|
NHL schedule for the specified date range. |
get_team_schedule_full(team_abbr)
¶
Get the full season schedule for a specific team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_abbr
|
str
|
The team abbreviation (e.g., 'TOR', 'NYR'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Schedule |
Schedule
|
Full season schedule for the specified team. |
get_team_schedule_week(team_abbr)
¶
Get the weekly schedule for a specific team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_abbr
|
str
|
The team abbreviation (e.g., 'TOR', 'NYR'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Schedule |
Schedule
|
Weekly schedule for the specified team. |
get_team_schedule_month(team_abbr)
¶
Get the monthly schedule for a specific team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_abbr
|
str
|
The team abbreviation (e.g., 'TOR', 'NYR'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Schedule |
Schedule
|
Monthly schedule for the specified team. |
get_schedule_calendar()
¶
Get the current NHL schedule calendar.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Schedule calendar showing available dates with games. |
get_schedule_calendar_for_date(date)
¶
Get the NHL schedule calendar for a specific date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
str
|
The date in format 'YYYY-MM-DD'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Schedule calendar for the specified date. |
close()
¶
Closes the underlying HTTP client session.
HTTP Client¶
edgework.http_client.HttpClient(user_agent=f'EdgeworkClient/{__version__}')
¶
Base HTTP client for NHL API requests.
Initialize the HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_agent
|
str
|
User agent string for requests |
f'EdgeworkClient/{__version__}'
|
get(endpoint, path=None, params=None, web=False)
¶
Make a GET request to an NHL API endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
API endpoint (without base URL) |
required |
path
|
Optional[str]
|
Optional full path to override endpoint |
None
|
params
|
Optional[Dict[str, Any]]
|
Optional query parameters |
None
|
web
|
bool
|
If True, use the web API base URL |
False
|
Returns:
| Type | Description |
|---|---|
Response
|
httpx.Response object |
get_raw(url, params=None)
¶
Make a GET request to a raw URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Full URL to request |
required |
params
|
Optional[Dict[str, Any]]
|
Optional query parameters |
None
|
Returns:
| Type | Description |
|---|---|
Response
|
httpx.Response object |
get_with_path(path, params=None, web=False)
¶
Make a GET request using a full path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Full path including query parameters |
required |
params
|
Optional[Dict[str, Any]]
|
Optional query parameters |
None
|
web
|
bool
|
If True, use the web API base URL |
False
|
Returns:
| Type | Description |
|---|---|
Response
|
httpx.Response object |
close()
¶
Close the HTTP client.
Season Validation¶
edgework.edgework._validate_season_format(season)
¶
Validates season string format and converts to integer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
season
|
str
|
Season string in format "YYYY-YYYY" (e.g., "2023-2024") |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Season as integer in format YYYYYYYY (e.g., 20232024) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If season format is invalid |
Usage Examples¶
Basic Initialization¶
from edgework import Edgework
# Default initialization
client = Edgework()
# Custom user agent
client = Edgework(user_agent="MyApp/1.0")
Season Format Validation¶
The client includes built-in season format validation:
from edgework import Edgework
client = Edgework()
# Valid season format
stats = client.skater_stats(season="2023-2024")
# Invalid format - will raise ValueError
try:
stats = client.skater_stats(season="2024")
except ValueError as e:
print(f"Error: {e}")
Available Methods¶
Player Methods¶
players(active_only=True)- Get list of playersskater_stats(season, ...)- Get skater statisticsgoalie_stats(season, ...)- Get goalie statistics
Team Methods¶
team_stats(season, ...)- Get team statistics
Schedule Methods¶
schedule(...)- Get game schedules
Draft Methods¶
draft_rankings(...)- Get draft rankings
Standings Methods¶
standings(...)- Get team standings
Error Handling¶
The client raises various exceptions for different error conditions:
ValueError- Invalid input parameters (e.g., wrong season format)HTTPError- API request failuresException- Other unexpected errors