toddrob99 / MLB-StatsAPI

Python wrapper for MLB Stats API
GNU General Public License v3.0
513 stars 98 forks source link

Way to obtain gamePk for current game? #112

Closed unnes closed 1 year ago

unnes commented 1 year ago

Super cool library. It's been getting me back into playing with Python and I'm very grateful for that.

statsapi.last_game works great to pull the most completed game, but is there a way to pull a currently-active game? One of the help pages implied that last_game should but it seems like its not. Is there a function that I'm missing?

toddrob99 commented 1 year ago

Use the schedule function and pass in the current date and team id. That will return today's games for the given team, and you can check the status to see if it's currently active. Note there could be more than one game listed, in case of a doubleheader.

unnes commented 1 year ago

Fantastic! Thanks for the direction and I appreciate the caveat about doubleheaders.