toddrob99 / MLB-StatsAPI

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

Inning-level data for pitchers #73

Closed bennettcolecohen closed 2 years ago

bennettcolecohen commented 2 years ago

Hi there -- is there a way to pull data on an inning level from pitchers? I want to look at recent 30 inning data for a bunch of pitchers, but the best method I can think of is to use the game_playByPlay endpoint and try to manually calculate all the stats. Is there a better method?

toddrob99 commented 2 years ago

There might be a way to get inning-level stats using Situation Codes, but even then you'll have to iterate through players and games to collect the data.

You could potentially use the byDateRange Stat Type as well, if you can determine a date range for 30 the last 30 innings. Again this would have to be done per pitcher, and it's likely you won't get an even 30 innings for any date range.

Unfortunately I'm not aware of a way to get stats for the last number of innings played, other than pulling in all the data and calculating yourself. I do not have much experience using the MLB API for stats though, ironically. If you post on https://reddit.com/r/mlbdata there might be someone with additional insight.