i want to request data from an API but I’m struggling to get multiple params
within one request.
I have the following line of code:
r = requests.get('https://api.delta.exchange/v2/tickers?contract_types= call_options, put_options')
According to the API documentation the params
for each contract_type can be called by separating with a comma. While using the line above it will only return the first called param
in that case call_options
. I tried separating with an &
with the same effect. For some reason using request.get(url, params={call_options,put_options})
results in the error that call_options
is not defined.
Probably a very trivial problem but I’m thankful for any help or suggestion.
2
Answers
The correct argument for the
params
parameter would be adict
whose key is the parameter name and the value would be the comma-separated string.I cannot reproduce why your line of code should only give you "call options".
The following example and the according output shows that the API is returning the expected types.
Output:
In general, you should avoid using spaces in URLs.