Reading Sensor Id and type from Activity

44 views
Skip to first unread message

Chaitanya G

unread,
Jan 22, 2022, 3:53:09 AM1/22/22
to Strava API
Hello Strava Developers,

I am trying to read the sensor Id and type from the Strava Activity details.
For example, if a Run activity was recorded with Garmin's ANT+ Footpod sensor, the FIT file exported from Strava contains device_type=124 and an ant_device_number.
Is there a way to extract these from the Activity using the Strava API?

Thanks!
-CG

ActivityFix Brandon

unread,
Feb 1, 2022, 4:14:11 PM2/1/22
to Strava API

Strava does not provide that information in any of the available data feeds. You have two options, depending on your goal:
  1. Use the "Export Original" option from the activity page in Strava. This can't be automated, so it's the same as downloading the FIT file from your Garmin device or Garmin Connect. I'm guessing this isn't what you want.
  2. If you are trying to automate something you will need to sign up for the Garmin Connect Developer Program, implement their oauth protocol to link your account, subscribe to their webhooks (specifically their ping service), and retrieve the FIT file from newly uploaded activities. Since the Strava and Garmin webhook calls won't have a guaranteed order or timing, you will need to save the data from both and correlate them once you've got both pieces of data. Most of the time you can use the field 'external_upload_id' from the Strava activity information (I forget the exact field name but it's something like that, I am not in front of my development machine at the moment) to get the Garmin activity ID. Sometimes it's a random UUID instead of garmin_push_XXXXXX in which case you need to base it on the activity start time (add some margin, Strava seems to mess with the start time by +/- 10 seconds). You'll also need something to parse and process the FIT file to extract the information you need, you can find example code in several languages in the FIT SDK available from Garmin. The minimal development option (but slowest) is to use their FitCSV JAR to extract the file to a CSV, then parse the CSV for the information you need.

C G

unread,
Feb 1, 2022, 4:28:24 PM2/1/22
to ActivityFix Brandon, Strava API
Thanks for the response!
I decided to go with option #2 you mentioned. It is a long route which requires getting approval from Garmin for access to the Activity API, but I am working through it.
In the meantime I went with a Chrome Extension where the injected script makes a xhr request to the export_original url. I then upload the data to my server, parse the FIT file with the fit-file-parser npm library and do the rest of my business logic.
This works as a hack, but I will be going with the Garmin Activity API as the proper long term solution.

--
You received this message because you are subscribed to a topic in the Google Groups "Strava API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/strava-api/OGgNrIcMbcA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to strava-api+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/strava-api/db99f37f-7322-4a42-ae5f-3700b61ade98n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages