nhl-api-py 2.9.2__tar.gz → 2.10.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/PKG-INFO +16 -6
  2. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/README.md +15 -5
  3. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/_version.py +1 -1
  4. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/stats.py +2 -2
  5. nhl_api_py-2.10.2/nhlpy/api/teams.py +70 -0
  6. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/pyproject.toml +1 -1
  7. nhl_api_py-2.9.2/nhlpy/api/teams.py +0 -49
  8. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/__init__.py +0 -0
  9. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/__init__.py +0 -0
  10. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/game_center.py +0 -0
  11. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/misc.py +0 -0
  12. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/playoffs.py +0 -0
  13. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/__init__.py +0 -0
  14. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/builder.py +0 -0
  15. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/__init__.py +0 -0
  16. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/decision.py +0 -0
  17. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/draft.py +0 -0
  18. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/experience.py +0 -0
  19. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/franchise.py +0 -0
  20. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/game_type.py +0 -0
  21. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/home_road.py +0 -0
  22. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/nationality.py +0 -0
  23. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/opponent.py +0 -0
  24. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/position.py +0 -0
  25. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/season.py +0 -0
  26. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/shoot_catch.py +0 -0
  27. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/filters/status.py +0 -0
  28. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/sorting/__init__.py +0 -0
  29. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/query/sorting/sorting_options.py +0 -0
  30. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/schedule.py +0 -0
  31. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/api/standings.py +0 -0
  32. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/config.py +0 -0
  33. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/data/seasonal_information_manifest.json +0 -0
  34. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/data/team_stat_ids.json +0 -0
  35. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/data/teams_20232024.json +0 -0
  36. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/http_client.py +0 -0
  37. {nhl_api_py-2.9.2 → nhl_api_py-2.10.2}/nhlpy/nhl_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nhl-api-py
3
- Version: 2.9.2
3
+ Version: 2.10.2
4
4
  Summary: NHL API (Updated for 2024/2025) and EDGE Stats. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods as well as pythonic query builder for more indepth EDGE stats.
5
5
  Home-page: https://github.com/coreyjs/nhl-api-py
6
6
  License: GPL-3.0-or-later
@@ -29,7 +29,7 @@ Description-Content-Type: text/markdown
29
29
  [![PyPI version](https://badge.fury.io/py/nhl-api-py.svg)](https://badge.fury.io/py/nhl-api-py)
30
30
  ![nhl-api-py workflow](https://github.com/coreyjs/nhl-api-py/actions/workflows/python-app.yml/badge.svg?branch=main)
31
31
 
32
- # NHL-API-PY
32
+ # NHL API & NHL Edge Stats
33
33
 
34
34
 
35
35
  ## About
@@ -43,8 +43,9 @@ projects around the NHL and the NHL data sets. Special thanks to https://github
43
43
 
44
44
  ### Developer Note: This is being updated with the new, also undocumented, NHL API.
45
45
 
46
- More endpoints will be flushed out and completed as they
47
- are discovered. If you find any, open a ticket or post in the discussions tab. I would love to hear more.
46
+ As of 10/5/24 I seem to have a majority of the endpoints added from what I can tell, but every once and awhile I come across one that needs to be added/changed. These will most likely be a minor ver bump.
47
+
48
+ If you find any, open a ticket or post in the discussions tab. I would love to hear more.
48
49
 
49
50
 
50
51
  ---
@@ -261,6 +262,8 @@ client.stats.club_stats_season(team_abbr="BUF") # kinda weird endpoint.
261
262
 
262
263
  client.stats.player_career_stats(player_id="8478402")
263
264
 
265
+ client.stats.player_game_log(player_id="", season_id="20242025", game_type="2")
266
+
264
267
  # Team Summary Stats.
265
268
  # These have lots of available parameters. You can also tap into the apache cayenne expressions to build custom
266
269
  # queries, if you have that knowledge.
@@ -270,8 +273,15 @@ client.stats.team_summary(start_season="20202021", end_season="20212022")
270
273
 
271
274
  # Skater Summary Stats.
272
275
  # Queries for skaters for year ranges, filterable down by franchise.
273
- client.stats.skater_stats_summary(start_season="20232024", end_season="20232024")
274
- client.stats.skater_stats_summary(franchise_id=10, start_season="20232024", end_season="20232024")
276
+ client.stats.skater_stats_summary_simple(start_season="20232024", end_season="20232024")
277
+ client.stats.skater_stats_summary_simple(franchise_id=10, start_season="20232024", end_season="20232024")
278
+
279
+ # For the following query context endpoints, see the above section
280
+ client.stats.skater_stats_with_query_context(...)
281
+
282
+ # Goalies
283
+ client.stats.goalie_stats_summary_simple(start_season="20242025", stats_type="summary")
284
+
275
285
  ```
276
286
  ---
277
287
 
@@ -1,7 +1,7 @@
1
1
  [![PyPI version](https://badge.fury.io/py/nhl-api-py.svg)](https://badge.fury.io/py/nhl-api-py)
2
2
  ![nhl-api-py workflow](https://github.com/coreyjs/nhl-api-py/actions/workflows/python-app.yml/badge.svg?branch=main)
3
3
 
4
- # NHL-API-PY
4
+ # NHL API & NHL Edge Stats
5
5
 
6
6
 
7
7
  ## About
@@ -15,8 +15,9 @@ projects around the NHL and the NHL data sets. Special thanks to https://github
15
15
 
16
16
  ### Developer Note: This is being updated with the new, also undocumented, NHL API.
17
17
 
18
- More endpoints will be flushed out and completed as they
19
- are discovered. If you find any, open a ticket or post in the discussions tab. I would love to hear more.
18
+ As of 10/5/24 I seem to have a majority of the endpoints added from what I can tell, but every once and awhile I come across one that needs to be added/changed. These will most likely be a minor ver bump.
19
+
20
+ If you find any, open a ticket or post in the discussions tab. I would love to hear more.
20
21
 
21
22
 
22
23
  ---
@@ -233,6 +234,8 @@ client.stats.club_stats_season(team_abbr="BUF") # kinda weird endpoint.
233
234
 
234
235
  client.stats.player_career_stats(player_id="8478402")
235
236
 
237
+ client.stats.player_game_log(player_id="", season_id="20242025", game_type="2")
238
+
236
239
  # Team Summary Stats.
237
240
  # These have lots of available parameters. You can also tap into the apache cayenne expressions to build custom
238
241
  # queries, if you have that knowledge.
@@ -242,8 +245,15 @@ client.stats.team_summary(start_season="20202021", end_season="20212022")
242
245
 
243
246
  # Skater Summary Stats.
244
247
  # Queries for skaters for year ranges, filterable down by franchise.
245
- client.stats.skater_stats_summary(start_season="20232024", end_season="20232024")
246
- client.stats.skater_stats_summary(franchise_id=10, start_season="20232024", end_season="20232024")
248
+ client.stats.skater_stats_summary_simple(start_season="20232024", end_season="20232024")
249
+ client.stats.skater_stats_summary_simple(franchise_id=10, start_season="20232024", end_season="20232024")
250
+
251
+ # For the following query context endpoints, see the above section
252
+ client.stats.skater_stats_with_query_context(...)
253
+
254
+ # Goalies
255
+ client.stats.goalie_stats_summary_simple(start_season="20242025", stats_type="summary")
256
+
247
257
  ```
248
258
  ---
249
259
 
@@ -1,3 +1,3 @@
1
1
  # Should this be driven by the main pyproject.toml file? yes, is it super convoluted? yes, can it wait? sure
2
2
 
3
- __version__ = "2.9.2"
3
+ __version__ = "2.10.2"
@@ -173,8 +173,8 @@ class Stats:
173
173
  default_cayenne_exp: str = None,
174
174
  ) -> List[dict]:
175
175
  """
176
- Example: c.stats.skater_stats_summary(start_season="20232024", end_season="20232024")
177
- c.stats.skater_stats_summary(franchise_id=10, start_season="20232024", end_season="20232024")
176
+ Example: c.stats.skater_stats_summary_simple(start_season="20232024", end_season="20232024")
177
+ c.stats.skater_stats_summary_simple(franchise_id=10, start_season="20232024", end_season="20232024")
178
178
  :param start_season: Season id, in format 20202021, 20212022, etc, that will be the start of the range.
179
179
  :param end_season: Season id for the end range.
180
180
  :param franchise_id: String, The ID of the franchise. Not to be confused with team_id found on other endpoints.
@@ -0,0 +1,70 @@
1
+ from typing import List
2
+
3
+ from nhlpy.http_client import HttpClient
4
+
5
+
6
+ class Teams:
7
+ def __init__(self, http_client: HttpClient) -> None:
8
+ self.client = http_client
9
+ self.base_url = "https://api.nhle.com"
10
+ self.api_ver = "/stats/rest/"
11
+
12
+ def teams_info(self, date: str = "now") -> List[dict]:
13
+ """
14
+
15
+ :param date: Optional string, in format YYYY-MM-DD. Defaults to "now". So,
16
+ the NHL API sometimes uses the "now" string to default to the current date, but in some cases
17
+ such as preseaosn this is defaulting to last years season. So, to get accurate teams for
18
+ this season, aka whatever year this is, you can supply the timestamp YYYY-MM-DD which should be the start
19
+ of the upcoming season. For example, 2024-04-18 is for the season 2023-2025 and 2024-10-04 is for the season
20
+ 2024-2025.
21
+
22
+ Returns a list of dicts with all the teams info.
23
+ Updated in 2.10.0, this pulls from current standings API, aggregates a list of teams
24
+ and their conf/div, joins it with franchise ID, and returns it. This isnt pretty but
25
+ the NHL API has limitations to return this data in 1 request.
26
+ :return: dict
27
+ """
28
+ teams_info = self.client.get_by_url(full_resource=f"https://api-web.nhle.com/v1/standings/{date}").json()[
29
+ "standings"
30
+ ]
31
+ teams = []
32
+ for i in teams_info:
33
+ team = {
34
+ "conference": {"abbr": i["conferenceAbbrev"], "name": i["conferenceName"]},
35
+ "division": {"abbr": i["divisionAbbrev"], "name": i["divisionName"]},
36
+ "name": i["teamName"]["default"],
37
+ "common_name": i["teamCommonName"]["default"],
38
+ "abbr": i["teamAbbrev"]["default"],
39
+ "logo": i["teamLogo"],
40
+ }
41
+ teams.append(team)
42
+
43
+ # We also need to get "franchise_id", which is different than team_id. This is used in the stats.
44
+ franchises = self.all_franchises()
45
+ for f in franchises:
46
+ for team in teams:
47
+ if "Canadiens" in f["fullName"] and "Canadiens" in team["name"]:
48
+ team["franchise_id"] = f["id"]
49
+ continue
50
+
51
+ if f["fullName"] == team["name"]:
52
+ team["franchise_id"] = f["id"]
53
+
54
+ return teams
55
+
56
+ def roster(self, team_abbr: str, season: str) -> dict:
57
+ """
58
+ Returns the roster for the given team and season.
59
+ :param team_abbr: Team abbreviation. BUF, TOR, etc
60
+ :param season: Season in format YYYYYYYY. 20202021, 20212022, etc
61
+ :return:
62
+ """
63
+ return self.client.get(resource=f"roster/{team_abbr}/{season}").json()
64
+
65
+ def all_franchises(self) -> List[dict]:
66
+ """
67
+ Returns a list of all past and current NHL franchises. This includes ones long forgotten.
68
+ :return:
69
+ """
70
+ return self.client.get_by_url(full_resource="https://api.nhle.com/stats/rest/en/franchise").json()["data"]
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "nhl-api-py"
7
- version = "2.9.2"
7
+ version = "2.10.2"
8
8
  description = "NHL API (Updated for 2024/2025) and EDGE Stats. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods as well as pythonic query builder for more indepth EDGE stats."
9
9
  authors = ["Corey Schaf <cschaf@gmail.com>"]
10
10
  readme = "README.md"
@@ -1,49 +0,0 @@
1
- import json
2
- import importlib.resources
3
- from typing import List
4
-
5
- from nhlpy.http_client import HttpClient
6
-
7
-
8
- class Teams:
9
- def __init__(self, http_client: HttpClient) -> None:
10
- self.client = http_client
11
- self.base_url = "https://api.nhle.com"
12
- self.api_ver = "/stats/rest/"
13
-
14
- def teams_info(self) -> dict:
15
- """
16
- Returns a list of dicts with all the teams info. This is loaded via a harccoded json file.
17
- :return: dict
18
- """
19
- data_resource = importlib.resources.files("nhlpy") / "data"
20
- teams_info = json.loads((data_resource / "teams_20232024.json").read_text())["teams"]
21
-
22
- # We also need to get "franchise_id", which is different than team_id. This is used in the stats.
23
- franchises = self.all_franchises()
24
- for f in franchises:
25
- for team in teams_info:
26
- if "Canadiens" in f["fullName"] and "Canadiens" in team["name"]:
27
- team["franchise_id"] = f["id"]
28
- continue
29
-
30
- if f["fullName"] == team["name"]:
31
- team["franchise_id"] = f["id"]
32
-
33
- return teams_info
34
-
35
- def roster(self, team_abbr: str, season: str) -> dict:
36
- """
37
- Returns the roster for the given team and season.
38
- :param team_abbr: Team abbreviation. BUF, TOR, etc
39
- :param season: Season in format YYYYYYYY. 20202021, 20212022, etc
40
- :return:
41
- """
42
- return self.client.get(resource=f"roster/{team_abbr}/{season}").json()
43
-
44
- def all_franchises(self) -> List[dict]:
45
- """
46
- Returns a list of all past and current NHL franchises. This includes ones long forgotten.
47
- :return:
48
- """
49
- return self.client.get_by_url(full_resource="https://api.nhle.com/stats/rest/en/franchise").json()["data"]
File without changes