Viser innlegg med etiketten REST. Vis alle innlegg
Viser innlegg med etiketten REST. Vis alle innlegg

lørdag 12. mai 2012

Strava API for efforts per segment: Limitations and workarounds

The Strava API for downloading efforts per segment never returns more that 50 efforts. By including the option best=true, you get the 50 all time best efforts, i.e. the overall leaderboard from 1 to 50. However, this option does not work in combination with the startDate/endDate options. Thus, if you're interested in compiling leaderboards including athletes who are not among the top fifty, or if you want to show the best efforts from within a given timespan, you have to start doing a bit more work. Marc Durdin sums it up pretty good in this posting.

In essence what Marc is saying is that you have to call the API repeatedly, and whenever you get 50 efforts back, you split the time span in two halves and do two new calls. The lowest resolution available is per day, so what happens if you at the end are down to a day and you still get fifty efforts back? You're stuck. By combining this approach with a single call to the best=true, you're sure that you have the 50 all time best efforts + a substantial number of all efforts ever made. But for days when more than 50 efforts have been made, you are most certainly missing efforts.

Initially, I though this probably might not pose a problem, but I was wrong. A popular segment around here is Grefsenkollen, and on four occasions this spring 50 or more efforts have been made on this segment during a single day. The dates are:
  • 17th of April (Tuesday)
  • 19th of April (Thursday)
  • 24th of April (Tuesday)
  • 3rd of May (Thursday)

I thought these official numbers fra Strava HQ (posted December 2011) were interesting. One particulary interesting piece of information was that the fourth most active country in the world was Norway (Norway is of course not a very big country). So, this was 2011 - the numbers I'm seeing now indicate the usage has really risen for 2012, at least here in the Oslo area. I'll write a blog post about this sometime.