Closed joerex1418 closed 2 years ago
I will not be able to look into this in detail for a couple weeks, but I suspect you are right. With a couple of statTypes, season isn't required. With the way the endpoint configuration works, there's no way for the code to know when it should be required or not. Let me think about this some more, but in the meantime you can include statsapi.get()
's force=True
parameter to bypass the required field check.
The following is a valid url for the api: http://statsapi.mlb.com/api/v1/teams/145/stats?stats=yearByYear&group=hitting
But if I try running the python wrapper equivalent -
mlb.get("team_stats",{"teamId":145,"stats":"yearByYear","group":hitting})
I receive the following error -
ValueError: Missing required parameter(s): season.
I reckon that the "season" parameter is only required when retrieving a statType that doesn't need a specific season given. The statTypes - "yearByYear" and "yearByYearAdvanced" are at least two of them that don't require this parameter. There might be more but I have not looked yet.