Skip to content

Commit

Permalink
Feature: Goalie Summary Stats (Simple)
Browse files Browse the repository at this point in the history
- Adds client.stats.goalie_stats_suummary_simple method.  Basic endpoint only
  • Loading branch information
coreyjs committed Jul 19, 2024
1 parent 8246814 commit ab8409b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions nhlpy/api/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,39 @@ def skater_stats_with_query_context(
return self.client.get_by_url(
f"https://api.nhle.com/stats/rest/en/skater/{report_type}", query_params=q_params
).json()

def goalie_stats_summary_simple(
self,
start_season: str,
end_season: str,
game_type_id: int = 2,
aggregate: bool = False,
sort_expr: List[dict] = None,
start: int = 0,
limit: int = 70,
fact_cayenne_exp: str = "gamesPlayed>=1",
default_cayenne_exp: str = None,
) -> List[dict]:
q_params = {
"isAggregate": aggregate,
"isGame": False,
"start": start,
"limit": limit,
"factCayenneExp": fact_cayenne_exp,
}

if not sort_expr:
sort_expr = [
{"property": "wins", "direction": "DESC"},
{"property": "gamesPlayed", "direction": "ASC"},
{"property": "playerId", "direction": "ASC"},
]
q_params["sort"] = urllib.parse.quote(json.dumps(sort_expr))

if not default_cayenne_exp:
default_cayenne_exp = f"gameTypeId={game_type_id} and seasonId<={end_season} and seasonId>={start_season}"
q_params["cayenneExp"] = default_cayenne_exp

return self.client.get_by_url("https://api.nhle.com/stats/rest/en/goalie/summary", query_params=q_params).json()[
"data"
]

0 comments on commit ab8409b

Please sign in to comment.