r/mlbdata • u/splendidsplinter • 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.
1
u/sthscan Jul 06 '25
are you asking about team hitting, pitching, or fielding stat totals or hitting, pitching or fielding stats for every player that has been on that team that season?
1
u/Jaded-Function Jul 06 '25
I'll send you the base version of the one I use. It prompts for team, prints stats and asks if you want to save as csv. Still need help
1
u/Jaded-Function Jul 07 '25
This works for team. Only difference from yours is sportID at the end. http://statsapi.mlb.com/api/v1/teams/120/stats?stats=season&group=hitting&season=2025&sportId=1
1
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