Skip to main content
Solved

Strava API: keys and Streams


Forum|alt.badge.img

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

Best answer by Elliott11

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! 

View original
Did this topic help you find an answer to your question?

Forum|alt.badge.img+20
  • Community Manager
  • January 13, 2023

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! 


Forum|alt.badge.img+1

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept, you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings