Skip to main content
This connection requires following Strava’s OAuth flow. Please refer to Strava’s OAuth documentation for more information.

Prerequisites

  • Node.js installed on your machine
  • A Strava Developer account
  • A Notion account

Step 1 - Get Your API Keys

Strava API Key
1
Log in to your Strava account.
2
Go to Strava API.
3
Click on Create An App.
4
Fill in the required details and click Create.
5
Copy the Client ID and Client Secret.
Notion API Key
1
Log in to your Notion account.
3
Click on New Connection.
4
Fill in the required details and click Submit.
5
Copy the generated Installation access token.

Step 2 - Set Up Your Notion Database

1
Create a new database in Notion with the following properties:
  • Name (Title)
  • Distance (Number)
  • Pace (Text)
  • Duration (Text)
  • Elevation Gain (Number)
  • Type (Text)
  • Date (Date)
  • Calories (Number)
2
Share the database with your connection:
  • Click on the three dots in the top-right corner of the page.
  • Under Connections, click on Connect to and search for your connection and invite it.

Step 3 - Project Structure

This step is not necessary but we suggest projects to be structured like so:

Step 4 - Create .env file

Create a .env file in your project directory with the following with the following information:
YAML
Please note that you will have to update your .env file with your STRAVA_ACCESS_TOKEN and STRAVA_REFRESH_TOKEN after completing Strava’s OAuth flow.

Step 5 - Packages

Install the required Node.js packages using the following command:
Additionally, create a package.json file and add the following:
JSON

Step 6 - OAuth Flow

Create server.js to handle the OAuth flow:
JavaScript

Step 7 - Set Up Strava API Client

Create strava.js to set up the Strava API client:
JavaScript

Step 8 - Set Up Notion API Client

Create a notion.js file to set up the Notion API client using the @notionhq/client library. Use your Notion installation access token and database ID.
JavaScript

Step 9 - Fetch Activity Data From Strava

Create a stravaIntegration.js file to fetch activity data from your Strava account:
JavaScript

Step 10 - Populate Notion Database with Strava Activity Data

Create a notionIntegration.js file to handle populating the Notion database with all Strava activities.
JavaScript

Step 11 - Main Script

Create a main.js file that uses the modules created above to execute the connection logic.
JavaScript

Step 12 - Run the OAuth Flow

1
Start the OAuth Server:
2
Open your browser and navigate to http://localhost:3000:
  • You should see a page with a link to authorize with Strava.
3
Click the link to authorize with Strava:
  • This will redirect you to Strava’s authorization page.
4
Authorize the application:
  • Strava will redirect you to a page with an authorization code.
5
The server will exchange the authorization code for an access token and refresh token:
  • The tokens will be displayed on the page.
6
Copy the refresh token and update your .env file with it.

Step 13 - Run the Connection

Execute the connection script by running the following command:
Customize the code according to your Notion database structure and the properties you want to include for each Strava activity.