01-10-2023 01:45 PM
Hi, I have an issue with Strava API. I want to get activity streams and especially cadence, watts and temp for 1 activity.
Problem: with my requests below, I can only see 'temp' and not cadence and watts.
header = {'Authorization': 'Bearer ' + access_token}
param = {'keys': ['cadence', 'watts', 'temp'], 'key_by_type': True}
time_list = requests.get(url, headers=header, params=param).json()
Does it mean we are able to do only 1 key per request ? Meaning I should have to do 3 requests and not only one ?
Thanks
Solved! Go to Solution.
01-13-2023 07:04 AM
Hey there,
You should be able to make just the one request including all of the keys you're after. If you're running into issues making the request and receiving all of the data you're after, we recommend testing things out in the Swagger Playground. Always good to to ensure that the data is available per key for the specific activity you're querying.
If you find you're still running into issues, do let us know!
04-10-2023 02:35 PM
requests reads your params into the url as:
/?keys=cadence&keys=watts&keys=temp&keys_by_type=True
The Strava api is not flexible enough to take in params this way. It assumes that only one 'keys' query is made and thus only takes the last one in the query. Really they should add 'keys' as a Query method in their GET definition...
To make what you're asking for work:
keys = ['cadence', 'watts', 'temp']
keys = ",".join(keys)
params = {'keys':keys,'key_by_type':True}
if you print keys it will look like this: 'cadence,watts,temp' and the query will be: '?keys=cadence,watts,temp&key_by_type=True
01-13-2023 07:04 AM
Hey there,
You should be able to make just the one request including all of the keys you're after. If you're running into issues making the request and receiving all of the data you're after, we recommend testing things out in the Swagger Playground. Always good to to ensure that the data is available per key for the specific activity you're querying.
If you find you're still running into issues, do let us know!
Welcome to the Community - here is your guide to help you get started!