schmitty890 / sports-tracker

MIT License
1 stars 0 forks source link

hockey api #14

Open schmitty890 opened 5 years ago

schmitty890 commented 5 years ago

we need a way to get data from the NATIONAL HOCKEY LEAGUE.

Is there a free api we can consume? TBD NEED TO RESEARCH

If no free api to consume, we need to figure out how to get our own data and save to our own database.

If no api available, we could use cheerio to scrape games from the scores page on nhl.com at a specific date such as https://www.nhl.com/scores/2019-11-05

Habernet commented 5 years ago

Apparently, we there are free portions of their official API. I found this Gitlab repo (originally on Github) that documents these portions.

Original link: https://github.com/dword4/nhlapi New link: https://gitlab.com/dword4/nhlapi

Unfortunately, some things are missing. There is no direct endpoint for scores for example. Maybe we will have to do a combination of these methods? Using this API and then scraping with Cheerio.

schmitty890 commented 5 years ago

this has everything we need i believe. good find. 👍

live games: https://statsapi.web.nhl.com/api/v1/game/2019020241/feed/live

todays scheduled games: https://statsapi.web.nhl.com/api/v1/schedule?date=2019-11-07

todays scheduled game for hurricanes: https://statsapi.web.nhl.com/api/v1/schedule?teamId=12&date=2019-11-07

todays scheduled game for hurricanes with linescore: https://statsapi.web.nhl.com/api/v1/schedule?teamId=12&date=2019-11-07&expand=schedule.linescore

hurricanes next game: https://statsapi.web.nhl.com/api/v1/teams?teamId=12&expand=team.schedule.next

hurricanes previous game: https://statsapi.web.nhl.com/api/v1/teams?teamId=12&expand=team.schedule.previous

I could keep documenting more but I am getting tired, but this api has a lot of info in it.

We could have it where the user stores in our database what team(s) they wish to follow, and then when they load our page, we will get their favorite (subscribed) teams from our db, and then use that value to go make an api call to this api to fetch data and when returned, displays it on the page.

I'm not sure if we'd want to store any data directly from the api in our db. like possibly the scores? that way we could tell when there is new data being saved in our api, we trigger the text message alerts or something possibly