I had a couple of free evenings – hard to believe but it happened – and decided to try and have some fun with Strava’s API. Here’s what I came up with…
The site will give a list of all the segments I’ve attempted, grouped by various classes of segment. In this view, it orders within each segment by my ranking:
I can also filter those segments to show the ones I’ve never had a good crack at, or the ones where I am just slightly behind the leader, for example:
Then I decided to have some fun with the geolocation services built into iPhone and other mobile browsers (and now some desktop browsers as well!) With this, I hacked up a little page that would show me all the segments within 5km of my current location, plus the all important competitive data to help me decide which segment to go for today!
Main site: http://durdin.net/cookbook/strava/query.php
Mobile site: http://durdin.net/cookbook/strava/nearby.php
No guarantees on these pages – they are setup to work only for my data at present, unless you know the secret incantations to populate the database with your data as well.
Why /cookbook/? Well, because I already had a database setup and libraries for it. In other words, I was being lazy 🙂
11 thoughts on “Playing with the Strava API”
This is absolutely fantastic – just what I am after infact!
any chance you can flick me an email with the source 🙂
Cheers [email protected]
Rob, I’m probably not ready to share this code yet — it’s hacked together and has quite a few issues that need sorting out…
It’s all written according to the public Strava API, so anything I’ve got here you should be able to do as well. If I get some time I’ll blog about some of the more interesting snippets.
Very cool, I’m thinking about doing something related and am just getting started re: investigating the Strava API and methods. I’ll echo RandyRob’s earlier sentiment – would you be interested in sharing the source? I’d gladly reciprocate with whatever coolness I eventually come up with. And I’d also be more than willing to make a monetary donation to your post-ride-beverage-of-choice fund… 🙂
Thanks Brian 🙂 I’ve just had 2 requests in the last 2 days for the source to my site. I’ll pull the bits that I can when I get a moment shortly and pop them on the blog, as is. Won’t be very pretty though!
Did you get around to releasing the code at all? It’s nice to reverse engineer sometimes rather than start from scratch, but I’ll start looking at the API docs shortly anyway!
I’ve sanitised the code and popped it into a zip file at http://durdin.net/cookbook/strava/strava.zip
It comes sans comments and with a lot of guff. Haven’t had time to do anything with this for quite some time, so some of it may not even work any more with the updated Strava APIs. Sites like veloviewer and raceshape kinda trump a lot of this!
I do have a scheduled task running on my server to run download/daily.php to collate the data and that much, at least, is working.
That’s about as much as I can offer at this stage, don’t think I’ll be able to assist in spelunking the code but if it is any use to you then great 🙂
Have you had a chance to try out the create/upload API call? I was trying it out and I got a response back with a new ride id, but when I try to show the ride with the new id (i.e. http://www.strava.com/api/v2/rides/41569352), it tells me the ride has been deleted.
I am just wondering if anyone here had any luck with it or are running into the same issues?
Sorry Allen, I’ve never tried the create or upload call.
Does this just show your data or can it show mine too? I noticed the URL said AthleteId=7 – tried replacing that with my AthleteId, but it didn’t work.
Alex, sorry, the back end is populated with only my data at present. Veloviewer.com does a great job of presenting Strava data, more than my page does — you could play with the source linked above or veloviewer for your own data?