toddrob99 / MLB-StatsAPI

Python wrapper for MLB Stats API
GNU General Public License v3.0
533 stars 100 forks source link

404 Client Error - team_stats Endpoint #92

Closed Laneville closed 2 years ago

Laneville commented 2 years ago

Getting an HTTPError: 404 Client Error: Not found for url: https://statsapi.mlb.com/api/v1/teams/159/stats?season=2022&group=hitting

Can someone confirm if they are experiencing the same issue with this 'team_stats' endpoint?

Screen Shot 2022-08-14 at 2 59 36 PM
Laneville commented 2 years ago

I have submitted an application to statsapi MLB for their documentation so hopefully I can troubleshoot this error and help out, instead of just posting :)

toddrob99 commented 2 years ago

I have submitted an application to statsapi MLB for their documentation so hopefully I can troubleshoot this error and help out, instead of just posting :)

You won't get access to the MLB documentation unless you're an affiliate.

toddrob99 commented 2 years ago

I think there are two issues here...

  1. The stats parameters was not indicated as required in the documentation when I generated this package's endpoint structure, but it does in fact appear to be required. If you include stats=season the endpoint works. Try https://statsapi.mlb.com/api/v1/teams/143/stats?season=2022&group=hitting&stats=season or statsapi.get("team_stats", {"teamId": 143, "season" : 2022, "group": "hitting", "stats": "season"})
  2. You are using teamId 159 which is AL All-Stars. It appears this team is not valid for team_stats. https://statsapi.mlb.com/api/v1/teams/159/stats?season=2022&group=hitting&stats=season still returns the 404 error message.
Laneville commented 2 years ago

yes, looks like I got that response from MLB :(

And yes looks like that fixed the issue. Thank you!