Skip to main content
Solved

Don't receive heart rate data from activities API

  • 3 February 2024
  • 9 replies
  • 31 views

Forum|alt.badge.img+3

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?

Best answer by Jan_Mantau

The separate call for each activity with https://developers.strava.com/docs/reference/#api-Activities-getActivityById cannot be avoided.

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

Forum|alt.badge.img+3

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}]

Jan_Mantau
Superuser
Forum|alt.badge.img+26
  • Superuser
  • February 3, 2024

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


Forum|alt.badge.img+3

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. 


Jan_Mantau
Superuser
Forum|alt.badge.img+26
  • Superuser
  • February 3, 2024

The separate call for each activity with https://developers.strava.com/docs/reference/#api-Activities-getActivityById cannot be avoided.


Forum|alt.badge.img+3

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!


Forum|alt.badge.img+2
  • Hub Starter
  • February 5, 2024

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.


Forum|alt.badge.img+3

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

 


Forum|alt.badge.img+2
  • Hub Starter
  • February 5, 2024

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,

Forum|alt.badge.img+3

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

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