coreyjs / nhl-api-py Goto Github PK
View Code? Open in Web Editor NEWNHL API (2024 Updated) - For accessing most of the NHL EDGE statistical API's, scores, schedules and more
License: GNU General Public License v3.0
NHL API (2024 Updated) - For accessing most of the NHL EDGE statistical API's, scores, schedules and more
License: GNU General Public License v3.0
I got someone working on a fix for the nhl-led-scoreboard project and he's using your library to do so. The only issue I got is that some of my requirements breaks using Python 3.10 and up. would it be possible to make Python 3.9 the minimum requirement on your repo?
cheers
Fix typing hints on return types for teams api calls.
New endpoints around stats, misc.
when you go to the endpoint "https://api-web.nhle.com/v1/score/now" it auto puts the date in. The problem being that now will default to the previous day's date until noon. Could I submit a PR that optionally lets that function also take a date to get that day's score before noon.
Add new endpoints to map to available stats endpoints.
GET https://api-web.nhle.com/v1/club-stats-season/TEAM_ABBR
GET https://api-web.nhle.com/v1/player/PLAYER_ID/landing
GET https://api.nhle.com/stats/rest/en/{config/francise/country/season/draft}
The httpx library that you are using is showing a couple of issues when we are using it in our project for our next version(https://github.com/riffnshred/nhl-led-scoreboard)
We are seeing a timeout:
File "/usr/local/lib/python3.9/dist-packages/httpx/_transports/default.py", line 79, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ReadTimeout: The read operation timed out
And an issue with SSL Verification (I believe this is likely because the Cloudflare Load Balancer that the NHL is using was returning a bad cert)
File "/usr/local/lib/python3.9/dist-packages/httpx/_transports/default.py", line 79, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'api-web.nhle.com'. (_ssl.c:1123)
With the httpx API you do have the ability to increase the time out and also disable SSL Verification. Would it be possible to add these as options to the NHLClient like you do with verbose logging?
https://www.python-httpx.org/advanced/#timeout-configuration
https://www.python-httpx.org/advanced/#ssl-certificates
I realize that turning off the SSL Verification is considered a bad idea but it is causing our scoreboard to crash. Having the option to allow a user to bypass the verification is a good option (as long as they understand the potential risk of doing this)
I am thinking about updating this to support async operations. If anyone has any feedback, for or against, I would love to hear it.
Is your feature request related to a problem? Please describe.
When instantiating a client, such as client = NHLClient()
it would be nice to pass in an optional, defaulted to false, flag such as client = NHLClient(verbose=True)
. This can be used to display informative text such as the url that was generated, payload sizes, etc.
So the following in api/__init__.py
:
def _get(self, resource: str) -> httpx.request:
"""
Private method to make a get request to the NHL API. This wraps the lib httpx functionality.
:param resource:
:return:
"""
print(f"{self.base_url}{self.api_ver}{resource}")
r: httpx.request = httpx.get(url=f"{self.base_url}{self.api_ver}{resource}", follow_redirects=True)
return r
would become
def _get(self, resource: str) -> httpx.request:
"""
Private method to make a get request to the NHL API. This wraps the lib httpx functionality.
:param resource:
:return:
"""
if self.verbose:
print(f"{self.base_url}{self.api_ver}{resource}")
r: httpx.request = httpx.get(url=f"{self.base_url}{self.api_ver}{resource}", follow_redirects=True)
return r
And a simple test in tests/test_nhl_client.py
So old api is dead. Long live the new api. I am working thru adding the basic endpoints now. I have been following the helpful guide over at https://gitlab.com/dword4/nhlapi/-/blob/master/new-api.md. This may take a bit as this new API is a mess. I dont think it was meant for public consumption.
I'm working on another project that is trying to pull the schedule for the future week as well as the current week. Would it be possible to slightly change functions calling the schedule api to optionally pass them a date? This would bring it in line with the pulling schedule by month.
Add GH Action.
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2, actions/setup-python@v2, actions/cache@v2. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
Reduce payload down to specific information only. For example, c.teams.all()
should return an array of teams, not an object with NHL meta data which also contains an array of teams.
Initial dev of the helper portion of the NHLClient()
. This will include common functionality like consumes the other endpoints, such as returning an array of league standings that can be easily added to a DataFrame.
https://api.nhle.com/stats/rest/en/shiftcharts?cayenneExp=gameId%3D2023021148%20and%20((duration%20!%3D%20'00%3A00'%20and%20typeCode%20%3D%20517)%20or%20typeCode%20!%3D%20517%20)&exclude=eventDetails
response:
"data": [
{
"id": 14117691,
"detailCode": 0,
"duration": "00:33",
"endTime": "01:06",
"eventDescription": null,
"eventNumber": 105,
"firstName": "Claude",
"gameId": 2023021148,
"hexValue": "#C8102E",
"lastName": "Giroux",
"period": 1,
"playerId": 8473512,
"shiftNumber": 1,
"startTime": "00:33",
"teamAbbrev": "OTT",
"teamId": 9,
"teamName": "Ottawa Senators",
"typeCode": 517
},
...
Ill do this in a few days when my new machine arrives.
When checking API calls on the goalies stats page, another endpoint seems to exist only for goalers.
"https://api.nhle.com/stats/rest/en/goalie/summary"
The endpoint seems to work similarly to that of skaters.
Would be great to add that to the stats functions available, and maybe create one function to merge skaters and goalers stats quickly.
This will allow the nhl api to default back to the current season if nothing is supplied. This makes it a little bit for flexible in a full time use case.
The schedule endpoint allows for optional query param /schedule?teamId=[int, int, int, ...]
. This is to update the Schedule
handler to allow for this optional query param.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.