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

Is there a way to get a game log for a given player? #111

Closed
essentiapip opened this issue Apr 16, 2023 · 1 comment
Closed

Is there a way to get a game log for a given player? #111

essentiapip opened this issue Apr 16, 2023 · 1 comment

Comments

@essentiapip
Copy link

Hi,

I have been enjoying the wrapper and have been making extensive use of it in my current project.

My question was; if I have the player ID of a batter/pitcher and I want to get his game-by-game performance over a given date range, can I do that with your wrapper? Is there a function for it? Do you know how I can do this alternatively?

My end goal is that for a given pitcher or batter id, i get back the game records of the respective players and the appropriate statistics (e.g. atBats).

My current way of getting this is very recursive and slow and makes it very difficult to track the flow of the code to extract meaningful features.

Really looking forward to hearing back on this,

Thanks!

@toddrob99
Copy link
Owner

I think the person_stats endpoint gets you close. You need the gamePks, which you can get from the player's team's schedule, and then you would loop over the person_stats endpoint for each gamePk. Here is an example of the response for the person_stats endpoint: http://statsapi.mlb.com/api/v1/people/605151/stats/game/531368. You could use statsapi.get() to query the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants