Skip to content

Statistics

Statistical functionality in Edgework.

Statistics Methods

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 instance.players.

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 instance.players.

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 instance.teams.

Skater Statistics Model

edgework.models.stats.SkaterStats(edgework_client, obj_id=None, **kwargs)

Bases: BaseNHLModel

SkaterStats model to store skater statistics.

Initialize a SkaterStats object with dynamic attributes.

fetch_data(report='summary', season=None, aggregate=False, game=True, limit=-1, start=0, sort='points', direction='DESC', game_type=None)

Fetch the data for the skater stats.

Parameters:

Name Type Description Default
report str

The type of report to get (e.g. "summary", "bios", etc.)

'summary'
season int

The season to get stats for (e.g. 20232024)

None
aggregate bool

Whether to aggregate the stats

False
game bool

Whether to get game stats

True
limit int

Number of results to return (-1 for all)

-1
start int

Starting index for results

0
sort str | list[str]

Field to sort by

'points'
direction str | list[str]

Direction to sort (e.g. "DESC", "ASC")

'DESC'
game_type int

Type of game (e.g. 2 for regular season, 3 for playoffs)

None

Goalie Statistics Model

edgework.models.stats.GoalieStats(edgework_client, obj_id=None, **kwargs)

Bases: BaseNHLModel

GoalieStats model to store goalie statistics.

Initialize a GoalieStats object with dynamic attributes.

fetch_data(report='summary', season=None, aggregate=False, game=True, limit=-1, start=0, sort='wins', direction='DESC', game_type=None)

Fetch the data for the goalie stats.

Parameters:

Name Type Description Default
report str

The type of report to get (e.g. "summary", "advanced", etc.)

'summary'
season int

The season to get stats for (e.g. 20232024)

None
aggregate bool

Whether to aggregate the stats

False
game bool

Whether to get game stats

True
limit int

Number of results to return (-1 for all)

-1
start int

Starting index for results

0
sort str | list[str]

Field to sort by

'wins'
direction str | list[str]

Direction to sort (e.g. "DESC", "ASC")

'DESC'
game_type int | None

Type of game (e.g. 2 for regular season, 3 for playoffs)

None

Team Statistics Model

edgework.models.stats.TeamStats(edgework_client, obj_id=None, **kwargs)

Bases: BaseNHLModel

Team Stats model to store team statistics for a season.

Initialize a TeamStats object with dynamic attributes.

fetch_data(report='summary', season=None, aggregate=False, game=True, limit=-1, start=0, sort='wins', direction='DESC', game_type=2)

Fetch the data for the team stats.

Parameters:

Name Type Description Default
report str

The type of report to get (e.g. "summary", "faceoffpercentages", etc.)

'summary'
season int

The season to get stats for (e.g. 20232024)

None
aggregate bool

Whether to aggregate the stats

False
game bool

Whether to get game stats. If False, returns aggregate stats.

True
limit int

Number of results to return (-1 for all). Default is -1.

-1
start int

Starting index for results. Default is 0.

0
sort str

Field to sort by. Can be a string (e.g. "points") or a list of dicts for multiple fields. Default is "wins".

'wins'
direction str

Direction to sort (e.g. "DESC", "ASC"). Default is "DESC".

'DESC'
game_type int

Type of game (e.g. 2 for regular season, 3 for playoffs). Default is 2.

2

Statistics Client

edgework.clients.stats_client.StatsClient(client)

get_skater_stats_leaders(game_type=2)

Fetch current skater statistics leaders.

Parameters:

Name Type Description Default
game_type int

Game type ID (2=Regular Season, 3=Playoffs)

2

Returns:

Type Description
Dict

Dictionary with current skater leaders including:

Dict
  • Points leaders
Dict
  • Goals leaders
Dict
  • Assists leaders

get_goalie_stats_leaders(game_type=2)

Fetch current goalie statistics leaders.

Parameters:

Name Type Description Default
game_type int

Game type ID (2=Regular Season, 3=Playoffs)

2

Returns:

Type Description
Dict

Dictionary with current goalie leaders including:

Dict
  • Wins leaders
Dict
  • GAA leaders
Dict
  • Save percentage leaders

get_skater_stats_leaders_by_season(season, game_type=2)

Fetch skater statistics leaders for a specific season.

Parameters:

Name Type Description Default
season str

Season in format "YYYY-YYYY" (e.g., "2023-2024")

required
game_type int

Game type ID (2=Regular Season, 3=Playoffs)

2

Returns:

Type Description
Dict

Dictionary with skater leaders for the specified season.

get_goalie_stats_leaders_by_season(season, game_type=2)

Fetch goalie statistics leaders for a specific season.

Parameters:

Name Type Description Default
season str

Season in format "YYYY-YYYY" (e.g., "2023-2024")

required
game_type int

Game type ID (2=Regular Season, 3=Playoffs)

2

Returns:

Type Description
Dict

Dictionary with goalie leaders for the specified season.

Skater Statistics

edgework.models.stats.SkaterStats(edgework_client, obj_id=None, **kwargs)

Bases: BaseNHLModel

SkaterStats model to store skater statistics.

Initialize a SkaterStats object with dynamic attributes.

fetch_data(report='summary', season=None, aggregate=False, game=True, limit=-1, start=0, sort='points', direction='DESC', game_type=None)

Fetch the data for the skater stats.

Parameters:

Name Type Description Default
report str

The type of report to get (e.g. "summary", "bios", etc.)

'summary'
season int

The season to get stats for (e.g. 20232024)

None
aggregate bool

Whether to aggregate the stats

False
game bool

Whether to get game stats

True
limit int

Number of results to return (-1 for all)

-1
start int

Starting index for results

0
sort str | list[str]

Field to sort by

'points'
direction str | list[str]

Direction to sort (e.g. "DESC", "ASC")

'DESC'
game_type int

Type of game (e.g. 2 for regular season, 3 for playoffs)

None

Goalie Statistics

edgework.models.stats.GoalieStats(edgework_client, obj_id=None, **kwargs)

Bases: BaseNHLModel

GoalieStats model to store goalie statistics.

Initialize a GoalieStats object with dynamic attributes.

fetch_data(report='summary', season=None, aggregate=False, game=True, limit=-1, start=0, sort='wins', direction='DESC', game_type=None)

Fetch the data for the goalie stats.

Parameters:

Name Type Description Default
report str

The type of report to get (e.g. "summary", "advanced", etc.)

'summary'
season int

The season to get stats for (e.g. 20232024)

None
aggregate bool

Whether to aggregate the stats

False
game bool

Whether to get game stats

True
limit int

Number of results to return (-1 for all)

-1
start int

Starting index for results

0
sort str | list[str]

Field to sort by

'wins'
direction str | list[str]

Direction to sort (e.g. "DESC", "ASC")

'DESC'
game_type int | None

Type of game (e.g. 2 for regular season, 3 for playoffs)

None

Team Statistics

edgework.models.stats.TeamStats(edgework_client, obj_id=None, **kwargs)

Bases: BaseNHLModel

Team Stats model to store team statistics for a season.

Initialize a TeamStats object with dynamic attributes.

fetch_data(report='summary', season=None, aggregate=False, game=True, limit=-1, start=0, sort='wins', direction='DESC', game_type=2)

Fetch the data for the team stats.

Parameters:

Name Type Description Default
report str

The type of report to get (e.g. "summary", "faceoffpercentages", etc.)

'summary'
season int

The season to get stats for (e.g. 20232024)

None
aggregate bool

Whether to aggregate the stats

False
game bool

Whether to get game stats. If False, returns aggregate stats.

True
limit int

Number of results to return (-1 for all). Default is -1.

-1
start int

Starting index for results. Default is 0.

0
sort str

Field to sort by. Can be a string (e.g. "points") or a list of dicts for multiple fields. Default is "wins".

'wins'
direction str

Direction to sort (e.g. "DESC", "ASC"). Default is "DESC".

'DESC'
game_type int

Type of game (e.g. 2 for regular season, 3 for playoffs). Default is 2.

2

Usage Examples

Skater Statistics

from edgework import Edgework

client = Edgework()

# Get top point scorers
top_scorers = client.skater_stats(
    season="2023-2024",
    sort="points",
    direction="DESC",
    limit=10
)

print("Top 10 Point Scorers:")
for i, player in enumerate(top_scorers, 1):
    print(f"{i}. {player.name}: {player.points} points ({player.goals}G, {player.assists}A)")

Advanced Skater Stats

# Get assists leaders
assist_leaders = client.skater_stats(
    season="2023-2024",
    sort="assists",
    limit=10
)

# Get goal scorers
goal_leaders = client.skater_stats(
    season="2023-2024",
    sort="goals",
    limit=10
)

# Get plus/minus leaders
plus_minus_leaders = client.skater_stats(
    season="2023-2024",
    sort="plusMinus",
    limit=10
)

Goalie Statistics

# Get top goalies by wins
top_goalies = client.goalie_stats(
    season="2023-2024",
    sort="wins",
    limit=10
)

print("Top 10 Goalies by Wins:")
for i, goalie in enumerate(top_goalies, 1):
    print(f"{i}. {goalie.name}: {goalie.wins} wins")
    print(f"   GAA: {goalie.goals_against_average:.2f}, SV%: {goalie.save_percentage:.3f}")

Team Statistics

# Get team standings
team_standings = client.team_stats(
    season="2023-2024",
    sort="points",
    limit=32  # All NHL teams
)

print("NHL Standings:")
for i, team in enumerate(team_standings, 1):
    print(f"{i}. {team.team_name}: {team.points} points ({team.wins}-{team.losses}-{team.ot_losses})")

Statistical Categories

Skater Stats

  • Scoring: Goals, Assists, Points
  • Shooting: Shots, Shooting Percentage
  • Time: Games Played, Time on Ice
  • Advanced: Plus/Minus, Penalty Minutes, Power Play Points, Short Handed Points
  • Faceoffs: Faceoff Wins, Faceoff Win Percentage
  • Hits: Hits, Blocked Shots

Goalie Stats

  • Record: Wins, Losses, Overtime Losses
  • Save Stats: Saves, Save Percentage
  • Goals: Goals Against, Goals Against Average
  • Shutouts: Shutout wins
  • Time: Games Played, Time on Ice

Team Stats

  • Record: Wins, Losses, Overtime Losses, Points
  • Scoring: Goals For, Goals Against, Goal Differential
  • Special Teams: Power Play %, Penalty Kill %
  • Shot Stats: Shots For, Shots Against
  • Discipline: Penalty Minutes

Sorting and Filtering

Multiple Sort Criteria

# Sort by multiple criteria (if supported by API)
stats = client.skater_stats(
    season="2023-2024",
    sort=["points", "goals"],
    direction=["DESC", "DESC"],
    limit=20
)

Different Report Types

# Summary report (default)
summary_stats = client.skater_stats(
    season="2023-2024",
    report="summary"
)

# Advanced stats (if available)
advanced_stats = client.skater_stats(
    season="2023-2024",
    report="advanced"
)

Game Type Filtering

# Regular season stats (default)
regular_season = client.skater_stats(
    season="2023-2024",
    game_type=2
)

# Playoff stats
playoff_stats = client.skater_stats(
    season="2023-2024",
    game_type=3
)

Advanced Usage

Statistical Analysis

from edgework import Edgework

client = Edgework()

# Get comprehensive stats
all_skaters = client.skater_stats(
    season="2023-2024",
    limit=100
)

# Calculate team-based statistics
team_scoring = {}
for player in all_skaters:
    team = player.team_abbrev
    if team not in team_scoring:
        team_scoring[team] = {'goals': 0, 'assists': 0, 'points': 0, 'players': 0}

    team_scoring[team]['goals'] += player.goals
    team_scoring[team]['assists'] += player.assists
    team_scoring[team]['points'] += player.points
    team_scoring[team]['players'] += 1

# Display team offensive statistics
for team, stats in sorted(team_scoring.items(), key=lambda x: x[1]['points'], reverse=True):
    avg_points = stats['points'] / stats['players']
    print(f"{team}: {stats['points']} total points, {avg_points:.1f} avg per player")

Comparative Analysis

# Compare current season to previous season
current_season = client.skater_stats(season="2023-2024", limit=50)
previous_season = client.skater_stats(season="2022-2023", limit=50)

# Find players in both seasons
current_players = {p.player_id: p for p in current_season}
previous_players = {p.player_id: p for p in previous_season}

print("Players with improved scoring:")
for player_id in current_players:
    if player_id in previous_players:
        current = current_players[player_id]
        previous = previous_players[player_id]

        if current.points > previous.points:
            improvement = current.points - previous.points
            print(f"{current.name}: +{improvement} points ({previous.points}{current.points})")

Custom Statistics

# Calculate custom metrics
def calculate_efficiency_rating(player):
    """Calculate a custom efficiency rating."""
    if player.games_played == 0:
        return 0

    points_per_game = player.points / player.games_played
    shot_efficiency = player.goals / player.shots if player.shots > 0 else 0

    return (points_per_game * 10) + (shot_efficiency * 100)

# Apply to all players
stats = client.skater_stats(season="2023-2024", limit=100)
efficient_players = []

for player in stats:
    efficiency = calculate_efficiency_rating(player)
    efficient_players.append((player, efficiency))

# Sort by efficiency
efficient_players.sort(key=lambda x: x[1], reverse=True)

print("Most Efficient Players:")
for i, (player, efficiency) in enumerate(efficient_players[:10], 1):
    print(f"{i}. {player.name}: {efficiency:.2f} efficiency rating")