Closed WRB1021 closed 2 years ago
I don't think WAR is a stat that MLB publishes in the public API. Perhaps it's available in the StatCast endpoints that require authentication (which is only provided to affiliates). Please refer to this reddit post where basically the same question was asked and I provided a more detailed response.
Got it, thanks a ton!
I took another look, and figured it out!
params = {
"personId": 547180, # Bryce Harper
"season": 2021,
"hydrate": "stats(group=[batting],type=[sabermetrics],season=2021)",
}
statsapi.get("person", params)
You should be able to use the same hydration on the people endpoint with multiple personIds.
Oh excellent thanks so much Todd!
That was a single player, single season, but this appears to give all hitters for a given season: https://statsapi.mlb.com/api/v1/stats?stats=sabermetrics&group=hitting&sportId=1&season=2021
statsapi.get("stats", {"stats": "sabermetrics", "group": "hitting", "season": 2021, "sportId": 1})
Hi there. Not an issue, just a question. I'm fairly new to python and to this API but I'm having a bit of trouble pulling in the career WAR / full season WAR for a given player. I know WAR is a field in the meta, but for some reason when I pull career stats for a given player with the 'player_stats' command I'm not seeing WAR in the output. Any help would be appreciated!