Print

Import Strava Data to Google Sheets

paid feature

In this guide, we’ll walk through how to pull Strava data data directly into Google Sheets, using the API Connector add-on for Sheets. Strava is, of course, a well-known fitness tracker website and app.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Connect to the Strava API

The easiest way to get started with the Strava API is through API Connector’s built-in integration.

  1. Select Strava from the drop-down list of applications
    strava-application
  2. Under Authorization, click Connect to Strava
    strava-authorization
  3. You will be directed to strava.com and asked to sign in, if you haven't already. You'll also be asked to authorize the connection.
    strava-img7
  4. You'll then be returned to your Google Sheet, and can verify that your Strava connection is active.

Part 2: Pull Data from Strava to Sheets

Now that we’re connected, let’s pull some data into Sheets.

  1. Under Endpoint, choose /athlete to get data about yourself.
    strava-endpoints
  2. Select a destination sheet, name your request, and click Run.
    strava-response

Part 3: Create a Custom API Request

Alternatively, you can create a custom request instead of using API Connector’s built-in integration, using any of the endpoints and parameters shown in the API documentation.

Here's an example request setup:

  • ApplicationCustom
  • MethodGET
  • Request URLhttps://www.strava.com/api/v3/athlete
  • OAuthStrava

strava-response

Part 4: Handle Pagination

Note Strava's limits on the number of records returned on a response. By default, only 30 records will be returned unless you use pagination handling as described in their documentation.
strava-img8

This means that to get 200 records, you’d use the 'per_page' parameter, and to return more than 200 you’d then make subsequent requests using the 'page' parameter.

With API Connector you can loop through these automatically with pagination handling, like this:

  • Pagination typepage parameter
  • Page parameterpage
  • Run untilchoose when to stop fetching data
    pagination-page-parameter

Part 5: API Documentation

To see more API endpoints and example responses, check out the Strava API playground located at https://developers.strava.com/playground/.

Also, check out this video from Scott for more ideas on using the Strava API: https://www.youtube.com/watch?v=c4kKao0hGO4

30 thoughts on “Import Strava Data to Google Sheets”

  1. Hi, I tried using this with the endpoint https://www.strava.com/api/v3/athlete/activities but it only returned 30 activities. The cutoff point seemed random, it only went back to May 2020.

    Is this a problem with Strava's OAuth? Should this API connection work in 2021 still?

    Thanks

    Reply
    • By default Strava only sends 30 records at a time. To get more, you can add ?per_page=200 to the end of your URL. If you have more than 200 records, you would paginate through using "page parameter" pagination.

      Reply
  2. Hi Anna,
    Do you think it's possible to get activity date from strava. I don't see it in Strava API documentation.

    Or can we get data using API Connector, by filtering "Today Activities" Only (based on date range) ?

    Reply
    • Hey Rudy, when you run the https://www.strava.com/api/v3/athlete/activities request, it returns a "start_date" field, is that what you're looking for?

      Reply
      • Gotcha. Based on what I see in their API docs, they only return the following for the /clubs/{id}/activities endpoint:
        [
        {
        "resource_state": 2,
        "athlete": {
        "resource_state": 2,
        "firstname": "Peter",
        "lastname": "S."
        },
        "name": "World Championship",
        "distance": 2641.7,
        "moving_time": 577,
        "elapsed_time": 635,
        "total_elevation_gain": 8.8,
        "type": "Ride",
        "workout_type": null
        }
        ]

        There's no date in there so it doesn't look like this is available. I checked and found quite a few people complaining about this (e.g. here, here, here). Sorry about that.

    • That is, I can run: https://www.strava.com/api/v3/athlete/activities/{id]/streams, but I can't make it return anytthing but distance.

      Reply
      • I'm trying to make a heart rate based measure of training load. Currently I use the open software Golden Cheetah to do this and copy-paste the values over to Google Sheets.

      • I see. Their docs are pretty unclear on this point, and I don't have my own data to test with, but could you please try this?
        https://www.strava.com/api/v3/activities/{id}/streams?keys=distance,latlng,velocity_smooth,altitude,heartrate&key_by_type=true

        Let me know if that gets you back what you're looking for.

  3. is there a means to use values from the sheet as parameters on the api. For example, the strava gear api requires the gearid which can be gotten from activities. I would like to pass the gearid to the api in a loop to get all the gear records.

    Reply
  4. Hello! Thank you for the article! Could you please advise how or where can I get the Club's id? I would like to export recent activities of club members but for API
    /clubs/{id}/activities

    Thanks in advance.

    Reply
  5. Hi

    I love API connector and have imported all my Strava activities into Google Sheets.

    While analyzing them I initially couldn't find most of the activities I did abroad (outside the Netherlands for me). Looking closer they are there but almost all of them are listed with location_country=Netherlands, although in some cases the time zone indicates Switzerland or France. In the Strava web interface these activities are located in the correct countries.

    When I search the Strava API documentation (https://developers.strava.com/docs/reference/) location_country is not really explained.

    I would like to be able to filter for foreign activities. How can I get the correct data?

    Cheers,
    Marnix

    Reply
    • I'm not really familiar with this but after checking online, this seems to be a bug in the Strava API.
      I see a few people mentioning it, e.g. here and here
      So unfortunately it looks like you will have to use the web interface for this 🙁

      Reply
      • I think you have the following options:
        1) https://www.strava.com/api/v3/athletes/{id}/stats. This will show you your YTD totals, but only for activities set to Everyone.
        2) https://www.strava.com/api/v3/athlete/activities. This will show all your data, split out for each activity date, so you'll need to aggregate it yourself.

  6. When using the URL for getting a new access and refresh token I get a result in Postman. When using this code in the API connector (custom request / POST method) I get an error as result.
    OAuth = strava and it shows connected

    1) : Completed with errors
    - We reveived an error from strava.com (404)

    What am I doing wrong in here?
    Does the API connector needs authorization from the athlete? Did not do that in Postman either. The athlete did authorize because I received an authorization code and I am able to get new acces and refresh tokens with Postman.

    Hope you can help.

    Reply
    • 401 and 403 codes usually relate to authorization, while 404 errors simply mean "not found". In addition, your OAuth = strava says "Connected", so it doesn't sound like there's any issue there. In short, I'd guess that your issue isn't related to authorization, and instead is because your custom request URL doesn't point to an existing resource. If you can share your request URL I can check it out and let you know if I spot any problems.

      Reply
  7. Hi Ana,
    Thanks for the quick reply.
    The URL that is working in Postman is:

    https://www.strava.com/api/v3/oauth/token?client_id=x&client_secret=y&grant_type=refresh_token&refresh_token=z
    where x, y and z are the numbers. I copy this (postman) working URL in the Request URL field in google sheets API connector. Then it does not work.

    When I use a default /athlete/activities I receive my own data. When using /athlete/{id}/stats and I use my ID then I also get error 404. I am trying to get data in from 8 athletes so I can create a dashboard.

    Reply
    • Hi Jeroen, that's a token refresh URL, which is part of the OAuth process. So 1) you can't re-use it, and 2) there's no need to use it in API Connector anyway, since we already have Strava integrated as an OAuth connection, and automatically refresh those the tokens in the background. So I don't think you need that token URL at all, unless I'm missing something here. As for why you're getting error 404, the documentation for that endpoint says "Must match the authenticated athlete.", i.e. you can't fetch data for people other than yourself. It looks like people have asked for access to other people's public data before, but Strava hasn't provided it -- you can see some discussion on this here.

      Reply
      • Thank you Ana, your reply makes things a bit clearer. Good thing that the token is refreshed automatically. I understand now that I can only get my own data and not the data of other athletes. Thank you for the link that describes that issue. Will see what I can retrieve from the club data.

      • In the API connector I can add a new connection in the OAuth section. Currently it is showing Strava. But can I add another Strava connection and let another ahtlete in my club login to Strava? Can then 2 connections run at the same time and can I create the /athlete/activities method on the second connection and receive the data from the other athlete? Then 8 connections will allow me to get the data from 8 athletes. Or am I wrong?

      • That's correct, you could let another athlete log in and store that as a second saved OAuth connection. Then when you run requests for that authenticated athlete, the request will fetch data for their account instead of yours.
        I think the only caveat is it's possible Strava would require re-authentication at some point, and you'd then need that other athelete to log back in again. But I don't know for sure if that would happen since it depends on Strava.

Leave a Comment

Jump To