Zmalski / NHL-API-Reference

Unofficial reference for the NHL API endpoints.
MIT License
262 stars 19 forks source link

Best way to track live events? #13

Open dvdrplus opened 9 months ago

dvdrplus commented 9 months ago

First off, fantastic job on documentation, what a blessing.

I would like to track live events while they happen in all games occuring that night.

The old API, I used:

https://statsapi.web.nhl.com/api/v1/game/game_Id/feed/live/diffPatch?startTimecode=

which allowed me to periodically check up on a games play by play, only from the last published startTimecode, i.e. not pull the full play-by-play everytime I wanted to update.

Anyone have any recommendations or ideas on the best practice to track live game data with the new API?

For example, if a team scores, or a player gets a shot, I want to know in "real time".

I'll play around more and update if something comes up

dvdrplus commented 9 months ago

Update** - from probing the NHL.com website (play-by-play tab) for a game, it looks like the website itself simply periodically calls the https://api-web.nhle.com/v1/gamecenter/2023020883/play-by-play endpoint.

If it is good enough for them, it is good enough for me. Will leave temporarily open, incase any others have better ideas

minter commented 8 months ago

@dvdrplus That's what I'm doing in my code - polling the full PBP every 30 seconds or so, and keeping track of which events I've seen on my end. No issues as of yet.

Zmalski commented 8 months ago

Thanks for updating with your solution @dvdrplus, very helpful!