Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base running data in the boxscore #59

Closed
Zkatz72 opened this issue Jul 22, 2021 · 4 comments
Closed

Base running data in the boxscore #59

Zkatz72 opened this issue Jul 22, 2021 · 4 comments
Labels
question Question about usage/support

Comments

@Zkatz72
Copy link

Zkatz72 commented Jul 22, 2021

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.

@toddrob99
Copy link
Owner

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.

@toddrob99 toddrob99 added the question Question about usage/support label Jul 23, 2021
@Zkatz72
Copy link
Author

Zkatz72 commented Jul 23, 2021

Oh all right. Thanks! I am curious though: what exactly is the best way to see the stolen bases recorded in a single game?

@toddrob99
Copy link
Owner

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).

@Zkatz72
Copy link
Author

Zkatz72 commented Jul 23, 2021

I see. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about usage/support
Projects
None yet
Development

No branches or pull requests

2 participants