cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

The Hub is now in read-only mode as we make improvements to the Hub experience. More information is available here.

How to Get A List of Segments for Athlete within start/end Dates.

goalasso
Shkhara

Good Day,

I can not figure out how to get a list of Segments that an athlete has ridden. I can get the list of Activities in a given time period using the below. But, how do I then see if those Activities contain a certain segment? I can't figure out where/how to link an activity to a segment or link a segment to an activity or just search for a segment across an athlete's activities within a start/end date. 

https://www.strava.com/api/v3/athlete/activities?access_token=xxxxxxx&per_page=1&page=1&before=17040...

The goal is that I want to see if an athlete has ever ridden a segment within a specified start/end date.  So,  " Did Bobby ride Segment A between StartDate and EndDate". 

Any guidance is greatly appreciated,

Goalasso

 

4 REPLIES 4

Jan_Mantau
Superuser
Superuser

Getting the athletes segment efforts for a segment is explained here: https://developers.strava.com/docs/reference/#api-SegmentEfforts-getEffortsBySegmentId

The endpoint that gives you a list of segments for an activity is documented here: https://developers.strava.com/docs/reference/#api-Activities-getActivityById

Those are rather easy to find though. What was the problem?

 

Thank you Jan, 

I have figured these out. My "issue" is that 1) I don't know the segmentID unless I first get the Activity. I can't get the Activity if I don't know the ActivityID UNLESS I first get ALL Activities using "/athlete/activities" first and then iterating across each Activity looking for a specific segment ID. Unless I am missing something.

 

Here is the "question" that I was hoping there was an API call that would answer. Did an athlete complete a segment before and after a start/end date. In other words, provide a segment ID, start date, end date and if there is a segment effort for that athlete between those dates, return  success or failure. Think of a situation where I would like to know all the segments that an athlete has completed. 

Thanks

If you're interested in a specific segment then you can find the segment id at the end of the URL in the segment page like in https://www.strava.com/segments/29836946

After that you can use the mentioned https://developers.strava.com/docs/reference/#api-SegmentEfforts-getEffortsBySegmentId where you can provide exactly the parameters you wanted. But if you want to see all the segment efforts for any segment an athlete ever has made then you need the procedure you've described with activity summary and detail activities.

goalasso
Shkhara

Ok. so maybe I have the approach necessary. I first have to get a list of all activities within the timeframe I am interested. Then, using the returned ActivityIds for each of those, I then have to get the detailed activity usinghttps://www.strava.com/api/v3/activities/ that returns all of the segment efforts. Then I can interrogate those for specifics segementIDs. Is this correct? Is there a more straightforward way? I wish there was an API that just searched for Athlete Completed Segments within a TimeFrame.  Thanks much.

Goalasso