The Hub is now in read-only mode as we make improvements to the Hub experience. More information is available here.
02-03-2024 08:17 AM
Hi there!
I'm retrieving my latest run with the following endpoint: /athlete/activities and then the method "getLoggedInAthleteActivities". This works well, but I don't get the same response as the sample response given there. I don't get anything back from my heart rate information. Is this a permissions thing or am I missing something?
Solved! Go to Solution.
02-03-2024 01:55 PM
The separate call for each activity with https://developers.strava.com/docs/reference/#api-Activities-getActivityById cannot be avoided.
02-03-2024 08:36 AM
This is the actual response I get
[{'achievement_count': 0,
'athlete': {'id': xxxxx},
'athlete_count': 1,
'average_speed': 0.0,
'average_watts': None,
'comment_count': 0,
'commute': False,
'device_watts': None,
'distance': 0.0,
'elapsed_time': 7078,
'elev_high': -1.2,
'elev_low': -11.0,
'end_latlng': [],
'external_id': 'xxxxxxxx',
'flagged': False,
'gear_id': None,
'has_kudoed': False,
'hide_from_home': None,
'kilojoules': None,
'kudos_count': 3,
'manual': False,
'map': {'id': 'xxxxxx', 'polyline': None, 'summary_polyline': ''},
'max_speed': 0.0,
'max_watts': None,
'moving_time': 7078,
'name': 'Night Workout',
'photo_count': 0,
'private': False,
'sport_type': 'Workout',
'start_date': datetime.datetime(2024, 2, 1, 20, 0, 35, tzinfo=tzutc()),
'start_date_local': datetime.datetime(2024, 2, 1, 21, 0, 35, tzinfo=tzutc()),
'start_latlng': [],
'timezone': '(GMT+01:00) Africa/Algiers',
'total_elevation_gain': 0.0,
'total_photo_count': 0,
'trainer': True,
'type': 'Workout',
'upload_id': 11419644240,
'upload_id_str': '11419644240',
'weighted_average_watts': None,
'workout_type': None}]
02-03-2024 11:37 AM
The sample response is wrong. You can see the correct output for the activities summary in https://developers.strava.com/docs/reference/#api-models-SummaryActivity
02-03-2024 12:00 PM
is there a call to get something similar to the sample response provided? I would hate to make a separate call for all the heart rates.
02-03-2024 01:55 PM
The separate call for each activity with https://developers.strava.com/docs/reference/#api-Activities-getActivityById cannot be avoided.
02-04-2024 03:16 AM
mhhh oké, but then when i do it through the swagger playground, I do get the correct data tho. I might just contact Strava support to see whats going on. Thanks for your help!
02-05-2024 06:00 AM
When I read that you see the data via Swagger but it's missing when debugging your code, I thought, oh that sounds like a serialization issue. Are you using an outdated library or endpoint version reference? This is typically the reason you could be missing members during runtime but see them as expected via Swagger.
02-05-2024 06:09 AM
uhm I followed the documentation for python, so I assume its the latest version. If I use their swagger playground I do get the full response as showed in the docs. Even tho the docs do say, what @Jan_Mantau mentions, you get an activity summary back, which does not include heart rate data. This API is pretty confusing to work with to be honest haha.
This is what I actually get back
https://developers.strava.com/docs/reference/#api-models-SummaryActivity
02-05-2024 07:20 AM
I see what you mean... the response for "getLoggedInAthleteActivities" doesn't include these members in your sample above. I'm sure I'll run into this issue as well and I'll let you know if I find anything out.
"has_heartrate" : true, "average_heartrate" : 140.3, "max_heartrate" : 178,
02-05-2024 09:03 AM
yea so indeed, thats the data that's missing in the response. I've solved by ditching the python swagger_client.
I've solved it by just making a regular call the endpoint like this:
api_url = "https://www.strava.com/api/v3/athlete/activities"
headers = {
'Authorization': f'Bearer {token.get("token")}'
}
try:
# Get the activities of the logged-in athlete
response = requests.get(api_url, headers=headers)
runs = [run for run in response.json() if run.get('type') == 'Run']
return jsonify(runs), 200
Welcome to the Community - here is your guide to help you get started!