nhl-api-py 2.3.4__tar.gz → 2.5.0__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.
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/PKG-INFO +5 -3
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/README.md +4 -2
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/_version.py +1 -1
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/game_center.py +16 -1
- nhl_api_py-2.5.0/nhlpy/config.py +12 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/http_client.py +8 -4
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/nhl_client.py +12 -3
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/pyproject.toml +1 -1
- nhl_api_py-2.3.4/nhlpy/config.py +0 -6
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/__init__.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/__init__.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/helpers.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/misc.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/__init__.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/builder.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/__init__.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/decision.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/draft.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/experience.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/franchise.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/game_type.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/home_road.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/nationality.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/opponent.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/position.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/season.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/shoot_catch.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/filters/status.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/sorting/__init__.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/query/sorting/sorting_options.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/schedule.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/standings.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/stats.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/api/teams.py +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/data/seasonal_information_manifest.json +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/data/team_stat_ids.json +0 -0
- {nhl_api_py-2.3.4 → nhl_api_py-2.5.0}/nhlpy/data/teams_20232024.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nhl-api-py
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: NHL API. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods for easy data loading in Pandas or any ML applications.
|
|
5
5
|
Home-page: https://github.com/coreyjs/nhl-api-py
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -59,8 +59,10 @@ Im available on [Bluesky](https://bsky.app/profile/coreyjs.dev) for any question
|
|
|
59
59
|
from nhlpy import NHLClient
|
|
60
60
|
|
|
61
61
|
client = NHLClient()
|
|
62
|
-
#
|
|
63
|
-
client = NHLClient(verbose=True)
|
|
62
|
+
# Fore more verbose logging
|
|
63
|
+
client = NHLClient(verbose=True)
|
|
64
|
+
# OR Other available configurations:
|
|
65
|
+
client = NHLClient(verbose={bool}, timeout={int}, ssl_verify={bool}, follow_redirects={bool})
|
|
64
66
|
```
|
|
65
67
|
---
|
|
66
68
|
## Stats with QueryBuilder
|
|
@@ -32,8 +32,10 @@ Im available on [Bluesky](https://bsky.app/profile/coreyjs.dev) for any question
|
|
|
32
32
|
from nhlpy import NHLClient
|
|
33
33
|
|
|
34
34
|
client = NHLClient()
|
|
35
|
-
#
|
|
36
|
-
client = NHLClient(verbose=True)
|
|
35
|
+
# Fore more verbose logging
|
|
36
|
+
client = NHLClient(verbose=True)
|
|
37
|
+
# OR Other available configurations:
|
|
38
|
+
client = NHLClient(verbose={bool}, timeout={int}, ssl_verify={bool}, follow_redirects={bool})
|
|
37
39
|
```
|
|
38
40
|
---
|
|
39
41
|
## Stats with QueryBuilder
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional
|
|
1
|
+
from typing import Optional, List
|
|
2
2
|
from nhlpy.http_client import HttpClient
|
|
3
3
|
|
|
4
4
|
|
|
@@ -43,3 +43,18 @@ class GameCenter:
|
|
|
43
43
|
:return: dict
|
|
44
44
|
"""
|
|
45
45
|
return self.client.get(resource=f"score/{date if date else 'now'}").json()
|
|
46
|
+
|
|
47
|
+
def shift_chart_data(self, game_id: str, excludes: List[str] = None) -> dict:
|
|
48
|
+
"""
|
|
49
|
+
Get shift chart data for the game_id. GameIds can be retrieved from the schedule endpoint.
|
|
50
|
+
:param excludes: List of strings of items to exclude from the response.
|
|
51
|
+
:param game_id: The game_id for the game you want the shift chart data for.
|
|
52
|
+
:return: dict
|
|
53
|
+
"""
|
|
54
|
+
if not excludes:
|
|
55
|
+
excludes = ["eventDetails"]
|
|
56
|
+
|
|
57
|
+
base_url: str = "https://api.nhle.com/stats/rest/en/shiftcharts"
|
|
58
|
+
exclude_p: str = ",".join(excludes)
|
|
59
|
+
expr_p: str = f"gameId={game_id} and ((duration != '00:00' and typeCode = 517) or typeCode != 517 )"
|
|
60
|
+
return self.client.get_by_url(full_resource=f"{base_url}?cayenneExp={expr_p}&exclude={exclude_p}").json()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class ClientConfig:
|
|
2
|
+
def __init__(
|
|
3
|
+
self, verbose: bool = False, timeout: int = 10, ssl_verify: bool = True, follow_redirects: bool = True
|
|
4
|
+
) -> None:
|
|
5
|
+
self.verbose = verbose
|
|
6
|
+
self.timeout = timeout
|
|
7
|
+
self.ssl_verify = ssl_verify
|
|
8
|
+
self.follow_redirects = follow_redirects
|
|
9
|
+
|
|
10
|
+
self.api_web_base_url = "https://api-web.nhle.com"
|
|
11
|
+
self.api_base_url = "https://api.nhle.com"
|
|
12
|
+
self.api_web_api_ver = "/v1/"
|
|
@@ -14,9 +14,10 @@ class HttpClient:
|
|
|
14
14
|
:param resource:
|
|
15
15
|
:return:
|
|
16
16
|
"""
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
17
|
+
with httpx.Client(
|
|
18
|
+
verify=self._config.ssl_verify, timeout=self._config.timeout, follow_redirects=self._config.follow_redirects
|
|
19
|
+
) as client:
|
|
20
|
+
r: httpx.request = client.get(url=f"{self._config.api_web_base_url}{self._config.api_web_api_ver}{resource}")
|
|
20
21
|
|
|
21
22
|
if self._config.verbose:
|
|
22
23
|
logging.info(f"API URL: {r.url}")
|
|
@@ -30,7 +31,10 @@ class HttpClient:
|
|
|
30
31
|
:param full_resource: The full resource to get.
|
|
31
32
|
:return:
|
|
32
33
|
"""
|
|
33
|
-
|
|
34
|
+
with httpx.Client(
|
|
35
|
+
verify=self._config.ssl_verify, timeout=self._config.timeout, follow_redirects=self._config.follow_redirects
|
|
36
|
+
) as client:
|
|
37
|
+
r: httpx.request = client.get(url=full_resource, params=query_params)
|
|
34
38
|
|
|
35
39
|
if self._config.verbose:
|
|
36
40
|
logging.info(f"API URL: {r.url}")
|
|
@@ -13,11 +13,20 @@ class NHLClient:
|
|
|
13
13
|
client = NHLClient(verbose=True) # for a lil extra logging
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
def __init__(
|
|
16
|
+
def __init__(
|
|
17
|
+
self, verbose: bool = False, timeout: int = 10, ssl_verify: bool = True, follow_redirects: bool = True
|
|
18
|
+
) -> None:
|
|
17
19
|
"""
|
|
18
|
-
param:
|
|
20
|
+
:param follow_redirects: bool. Some of these endpoints use redirects (ew). This is the case when using
|
|
21
|
+
endpoints that use "/now" in them, which will redirect to todays data.
|
|
22
|
+
:param verbose: bool, Defaults to False. Set to True for extra logging.
|
|
23
|
+
:param timeout: int, Defaults to 10 seconds.
|
|
24
|
+
:param ssl_verify: bool, Defaults to True. Set to false if you want to ignore SSL verification.
|
|
19
25
|
"""
|
|
20
|
-
|
|
26
|
+
# This config type setup isnt doing what I thought it would. This will be reworked later on.
|
|
27
|
+
self._config = ClientConfig(
|
|
28
|
+
verbose=verbose, timeout=timeout, ssl_verify=ssl_verify, follow_redirects=follow_redirects
|
|
29
|
+
)
|
|
21
30
|
self._http_client = HttpClient(self._config)
|
|
22
31
|
|
|
23
32
|
self.teams = teams.Teams(http_client=self._http_client)
|
|
@@ -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.
|
|
7
|
+
version = "2.5.0"
|
|
8
8
|
description = "NHL API. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods for easy data loading in Pandas or any ML applications."
|
|
9
9
|
authors = ["Corey Schaf <cschaf@gmail.com>"]
|
|
10
10
|
readme = "README.md"
|
nhl_api_py-2.3.4/nhlpy/config.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|