-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get League Schedule for the entire Season #92
Comments
This is one of those endpoints where there just isn't a clean implementation from the NHL. They build all these separate endpoints to facilitate their web site and from an API standpoint they are confusing and kinda suck. I think there are two solutions here.
|
This connected PR should add this. It's basically just the following which returns 2835 games ids. Filtered to just regular season is 2624. def get_gameids_by_season(self, season: str, game_types: List[int] = None) -> List[str]:
"""
Get all gameids for a given season.
:param season: The season you want the gameids for. Format is YYYYYYYY. 20202021, 200232024, etc
:param game_types: List of game types you want to include. 2 is regular season, 3 is playoffs, 1 is preseason
"""
from nhlpy.api.teams import Teams
from nhlpy.api.schedule import Schedule
teams = Teams(self.client).teams_info()
gameids = []
for team in teams:
schedule = Schedule(self.client).get_season_schedule(team["abbr"], season)
for game in schedule["games"]:
if not game_types or game["gameType"] in game_types:
gameids.append(game["id"])
return gameids |
released in ver 2.17.0 |
🚀 |
Is your feature request related to a problem? Please describe.
It appears that there are various ways to slice out schedules; for a given day, for a team, a week, but not the entire season across the league. At first blush I expected this using the
.get_season_schedule
method but that requires a team id.Describe the solution you'd like
An approach similar to
.get_season_schedule
but for the entire league. My use case would be to grab the gameids for a season in order to grab the results and PBP datasets for historical analysis and modeling. As such, my need isn't the full object, but simply a list of gameids, but admittedly that might be too narrow. My framing is an endpoint that I previously used from here: http://www.nicetimeonice.com/api, which would yield an array of gameids.Describe alternatives you've considered
I could walk or daily schedules.
Additional context
The text was updated successfully, but these errors were encountered: