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}]
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
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.
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!
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.
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
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,
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