MLB-StatsAPI icon indicating copy to clipboard operation
MLB-StatsAPI copied to clipboard

Endpoints without parameters throwing Exception

Open waner11 opened this issue 1 year ago • 4 comments

When attempting to call an endpoint without any parameters, such as 'teams' or 'awards', it throws an error. I've noticed in the code that it always expects parameters, even if the endpoint doesn't require any.

waner11 avatar Jul 27 '24 20:07 waner11

Can you provide a code snippet to replicate this? @waner11

BrayanMnz avatar Aug 14 '24 14:08 BrayanMnz

@BrayanMnz I think this is referring to calling statsapi.get() without only the endpoint parameter, e.g. statsapi.get("teams") rather than statsapi.get("teams", {}). The wrapper doesn't default the params to an empty dict, which I guess it could since not all endpoints require user-supplied parameters.

This is pedantic, but all endpoints do require at least one parameter (version)--the wrapper automatically adds it based on defaults in the endpoint definitions. The get function could still default to an empty dict.

toddrob99 avatar Aug 14 '24 20:08 toddrob99

Got it @toddrob99 , I will take a look on how this is built in the wrapper. If you have any input that could be helpful will be great

BrayanMnz avatar Aug 14 '24 21:08 BrayanMnz

is anyone don't understand what this issue means, here is a snippet on how to replicate:

>>> import statsapi
>>> statsapi.get("teams")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: get() missing 1 required positional argument: 'params'

In the case of the teams endpoint, we need to pass an empty dict, in order for it to work.

>>> import statsapi
>>> statsapi.get("teams", {})

BrayanMnz avatar Aug 14 '24 21:08 BrayanMnz

I apologize for late reply, but yes is what @toddrob99 explained, when calling the statsapi.get() without any parameters other than the endpoint name, was throwing an exception. Thanks for taking care of this!

waner11 avatar Oct 29 '24 04:10 waner11