Closed Zkatz72 closed 3 years ago
Mostly because it wasn't on my mind when I wrote the function that generates the boxscore. The functions that are built into the wrapper are not really meant to satisfy most use cases. They are meant to show examples of how to use the statsapi.get()
method to retrieve and work with data from the API. If they are useful for some people, I consider that to be a bonus.
Oh all right. Thanks! I am curious though: what exactly is the best way to see the stolen bases recorded in a single game?
The statsapi.boxscore_data()
method that statsapi.boxscore()
uses to retrieve the date from the API actually includes stolen bases, it's just not written to the boxscore. You could make a copy of statsapi.boxscore_data()
and add caughtStealing to the fields
param (currently line 445), then make a copy of statsapi.boxscore()
and add sb/cs to the batter template along with where each batter is written out (away, home. You'll need to account for the extra length in rowLen (not sure after a quick glance if there are other spots).
You could also just take the API call from statsapi.boxscore_data()
, add caughtStealing to the field param, and do whatever you want with the data if you want to do something other than print a full boxscore. The data comes from the game endpoint. You'll find a list of batters in the result under result["liveData"]["boxScore"]["teams"]["away"]["players"]["ID592626"]["stats"]
(replace away
with home
for home team, and replace ID592626
with ID<personId>
where <personId>
is an element in the batters
list at result["liveData"]["boxScore"]["teams"]["away"]["batters"]
(or home
).
I see. Thanks for your help.
I found this wrapper and I've really enjoyed using it so far. However, I was curious as to why there is no base running data (i.e CS and SB) for each game in the game's boxscore. The boxscores look identical to the ones on MLB At Bat, just without the base running data.