toddrob99 / MLB-StatsAPI

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

Today's game date #77

Closed roe-men closed 2 years ago

roe-men commented 2 years ago

How would you pull today's scheduled game date?

I'm working on a Twitter bot to tweet live updates from Mets games but having issues with the currently defined functions and creating variables off of them. For example get_next_game function would only work as a reference point until the first pitch is thrown. So essentially I need to create a variable with today's gamePk and not the next_game.

I've tried using the get function to pull the startTimecode with no success.

Sorry if this is a simple fix, very new to the coding game.

toddrob99 commented 2 years ago

Use the schedule function:

today_schedule = statsapi.schedule()

Or get raw data from the schedule endpoint.

today_schedule = statsapi.get("schedule", {"sportId": 1})