toddrob99 / MLB-StatsAPI

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

Missing documentation? #114

Closed rpoynter1342 closed 1 year ago

rpoynter1342 commented 1 year ago

statsapi.get('team_stats', {'teamId': 117, 'season': '2023', 'group': 'game'}) returns with a 404 error:

Traceback (most recent call last): File "/home/reid/baseball-stats-app/flask-server/server.py", line 55, in print(statsapi.get('team_stats', {'teamId': 117, 'season': '2023', 'group': 'game'})) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/reid/.local/lib/python3.11/site-packages/statsapi/init.py", line 1736, in get r.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://statsapi.mlb.com/api/v1/teams/117/stats?season=2023&group=game

In the documentation, it specifically says that for the endpoint 'team_stats' the only required value is teamID. However when i run this line: statsapi.get('team_stats', {'teamId': 117} I get this stack trace:

Traceback (most recent call last): File "/home/reid/baseball-stats-app/flask-server/server.py", line 55, in print(statsapi.get('team_stats', {'teamId': 117})) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/reid/.local/lib/python3.11/site-packages/statsapi/init.py", line 1722, in get raise ValueError( ValueError: Missing required parameter(s): season, group. --Required parameters for the team_stats endpoint: [['season', 'group']]. --Note: If there are multiple sets in the required parameter list, you can choose any of the sets. --Endpoint note: Use meta('statGroups') to look up valid values for group, meta('statTypes') for valid values for stats, and meta('situationCodes') for valid values for sitCodes. Use sitCodes with stats=statSplits.****

rpoynter1342 commented 1 year ago

i see that this works https://statsapi.mlb.com/api/v1/teams/117/stats?season=2023&group=hitting&stats=season

but i want the teams stats for win/loss, run diff etc

rpoynter1342 commented 1 year ago

I guess i was looking at the wrong endpoint