Getting Started With The Strava API: A Tutorial

Tilde Ann Thurium
3 min readSep 16, 2017

--

Here’s a quick and dirty getting started guide for making your first request against the Strava API. This is meant to be beginner-friendly, so I’ve tried to err on the side of over explaining things. This tutorial assumes you have a basic understanding of what a rest API is: GET, POST PUT, all that good stuff.

Step 1: Make an app

In order to use the Strava API, you need to create an app. If you’re reading this, you likely already have a Strava account but if not go ahead and create one now. Sign in to your Strava account and navigate to your settings page.

The interface for creating a Strava app

You can put “localhost” in the Authorization Callback Domain field. The first thing you’re going to do is make a request for your own data, so you don’t need to worry about the authorization callback flow just yet. (Or maybe ever, if you only want to visualize your own data.)

Step 2: Find your access token

A lot of APIs make you go through the oAuth dance and authorize your newly created app before you can fetch any data. Good news: Strava doesn’t do that. Any apps you create with your account are automatically authorized to make requests against your data. This doesn’t work for other users though. Your app can’t fetch their data unless they explicitly authorize it first.

In your settings, there should now be a page with your API application. Navigate there, and copy your access token. It’s important not to commit your access token into source code, to prevent other people from having access to your data. Ditto for your client secret.

Strava settings page

Step 3: Make a request

I personally love using Postman for making API requests. I can never remember the arguments to curl. But you do you.

You’ll want to look at the current API documentation to see what endpoints exist and what arguments they take. Currently, many endpoints require an athlete ID. You can discover your athlete ID by navigating to your Strava profile and looking at the URL.

My Strava profile

To make a request against the Strava API, you need to pass in an access token. You can do so using a query string param, access_token.

Now it’s time to actually make the request. Find the api endpoint you’d like to make your request to, and copy that URL.

If you’re using Postman, click “params” and Postman will automagically fill them in to the URL for you as you type. Neat! Fill in the access token and any other params you need to make your request.

Making an API GET request from the Postman app

If everything has gone as planned, click “send” and you should have some sweet JSON data.

A successful JSON response from the Postman app

If you wanted to do this with curl it would be something like:
curl -X GET “https://www.strava.com/api/v3/athletes/17842500?access_token=YOUR_ACCESS_TOKEN" -H “accept: application/json”

Strava also has a sandbox, which you can use to make example requests. In order to use the sandbox, you need a working oAuth flow for your app, which is out of scope for this tutorial.

That’s it! Go forth and visualize.

--

--

Tilde Ann Thurium

I dress like the illegitimate lovechild of Betsey Johnson and Lisa Frank. ❤️ Vegan. Artist. engiqueer.