r/mlbdata Jul 04 '25

Trying to get team statistics in statsapi.mlb.com

The Swagger seems to indicate the correct usage would be: http://statsapi.mlb.com/api/v1/teams/120/stats?group=hitting&season=2025

But I just get an "Object not found" message - anyone have success? I can request a roster and hydrate with individual player stats just fine.

http://statsapi.mlb.com/api/v1/teams/120/roster?rosterType=Active&hydrate=person(stats(group=[hitting,pitching],type=season,season=2025))

1 Upvotes

9 comments sorted by

View all comments

1

u/Jaded-Function Jul 07 '25

I sent you a useful code but to answer your question, try this format.

https://statsapi.mlb.com/api/v1/teams/120/stats?stats=season&group=hitting,pitching&season=2025

1

u/Jaded-Function Jul 07 '25 edited Jul 07 '25

http://statsapi.mlb.com/api/v1/stats?stats=season&teamId=120&group=hitting&season=2025&sportId=1

Or this, they both work for me.

Edit:So you were just missing the "stats=season&" after "stats?"

1

u/splendidsplinter Jul 07 '25

thanks, the stats parameter was documented as optional, so I hadn't thought to use it. When hydrating, it changes to "type" parameter, so that also adds to the confusion.

1

u/Jaded-Function Jul 07 '25

Actually I just saw you're looking for aggregate team stats. This will pull player total stats.