Connecting the Strava API to Google Sheets

Strava is a social network for athletes. We can use the Strava API to import data from Strava into Google Sheets. In this tutorial, we’ll show you how to connect the Strava API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Obtain an Access Token
  3. Choose a Strava endpoint
  4. Enter Your Strava API request into Apipheny
  5. Run the Strava API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on in Google Sheets

To pull data from the Strava API to Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more. 

1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the page: https://apipheny.io/install

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions option in the top menu. In this menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

open apipheny

Step 2.) Obtain an Access Token

Go to https://www.strava.com/settings/api and create an app, so you can obtain credentials. After completing the required fields, click the Create button:

Settings section
Settings section

Choose an icon for your app by clicking the + button:

App Icon section
App Icon section

Click the Save button to save it:

Edit Photo
Edit Photo

Your credentials, including the access token, will then be displayed on the screen:

Credentials Section
Credentials Section

This token expires after 6 hours. The refresh_token may be used to get a new access token when that time period is up.

To refresh your toke, open up a command prompt window for Windows OS or a terminal for Mac OS and compose the following curl command:

curl -X POST https://www.strava.com/api/v3/oauth/token -d client_id=ReplaceWithClientID -d client_secret=ReplaceWithClientSecret -d grant_type=refresh_token -d refresh_token=ReplaceWithRefreshToken
Note: For Mac OS you may need to use single quotes ( ‘ ).
Curl command for access token
Curl command for access token

Request Parameters

  • client_id = the application’s ID, obtained during registration
  • client_secret = the application’s secret, obtained during registration
  • grant_type = the grant type for the request. When refreshing an access token, the grant type must always be “refresh_token”
  • refresh_token = The refresh token for this user, to be used to get the next access token for this user. Please expect that this value can change anytime you retrieve a new access token. Once a new refresh token code has been returned, the older code will no longer work.

Step 3.) Choose a Strava endpoint

In this section, we’ll show you how to browse the Strava API documentation to find an endpoint that retrieves the information you need from your account. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the Strava API documentation page: https://developers.strava.com/docs/reference/

The menu on the left contains a list of the Strava API endpoints:

Strava API documentation page
Strava API documentation page

An example endpoint is Get Activity, which returns an activity owned by the authenticated athlete:

https://www.strava.com/api/v3/activities/{id}?include_all_efforts=TRUEorFALSE

If you use this URL, don’t forget to replace {id} with a real value. Also, choose only one value for the include_all_efforts parameter, TRUE or FALSE.

The endpoint’s documentation contains a short description of the endpoint’s purpose, its HTTP method (GET), the URI, a list of accepted parameters, the curl request and an example response:

Endpoint documentation
Endpoint documentation

All API calls for Strava should be made to the https://www.strava.com/api/v3/ base domain.

Step 4.) Enter Your Strava API Request Into Apipheny

Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the Import tab. With the Import tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your API endpoint. For this example, we are using the GET method.

API URL: In Step 3, we explained how you can find the Strava REST API endpoint that you need. Now copy and paste your complete Strava API URL into the Apipheny add-on, where it says API URL Path, followed by any parameters required for your query (if applicable).

For this example, we are using the Get Authenticated Athlete endpoint, which returns the currently authenticated athlete. The whole URL for this endpoint is:

https://www.strava.com/api/v3/athlete

Headers: In the Headers section of Apipheny, add one row with the following key and value:

Key:
Authorization

Value:
Bearer your_auth_token

your_ auth_token is the value of the token generated previously, in Step 2. There should be a space between “Bearer” and your token in the header value.

Strava API request entered into Apipheny
Strava API request entered into Apipheny

Step 5.) Run the Strava API request in your Google Sheet

Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the Strava API data to be imported into your Google Sheet. Here’s what our request looked like when completed:

Strava data imported into Google Sheets
Strava data imported into Google Sheets

That’s it! You’ve successfully connected your Strava account to Google Sheets using the Strava API, Google Sheets API, and the Apipheny add-on.

After making a successful request to the Strava API, try querying a different Strava API endpoint, or try using one of the more advanced features in the Apipheny add-on.


API Tutorials



Related Posts