Directus Strava

Directus is a node based CMS/database I've been using for a while now to store data about myself. Mostly trip logs and reports (I have a terrible memory for things I have done) so that I can look up up where I've been and with who.

I also use Strava to log my activities (cycling and hiking) partly for the social aspect and partly because all of my tracking devices are able to easily upload there.

The extension I've made links the two meaning I can get both a copy of my data somewhere I can control but I also get simple integrations and all important life affirming kudos.

Find the extension on github.


Installation of the extension is simply dropping the index.js file and config.js file into your directus extension folder.

Once authenticated you can both set up a subscription, which will automatically import activities on strava when they are create, or see a list of your recent activities to import.

Extension details

<p>The extension homepage</p>

The extension homepage

This isn't intended as a full explanation of the application as it is a fairly basic OAuth thing so instead this should be read as some random notes about things I found interesting.


The extension authenticates strava users ("athletes") using the strava OAuth api. The OAuth application is easy to create and you just need to point the extension at it. When requests are made to the extension it quickly checks if it needs to refresh the tokens before making any requests to Strava.

Some requests (initial auth, and setting up webhook subscriptions) require access to the OAuth apps client secret. I did experiment with a stateless proxy server for these requests, so that people could use this app without setting up their own OAuth app, but there was a big problem.

Each OAuth app can only have one webhook subscription so I would need to track Athlete IDs and webhook urls for anyone using the proxy server. I decided I did not actually want to deal with anyone else's data and so now you must create your own OAuth app. Luckily this is not hard and it does mean everything can run in the Directus extension.


<p>The extension activities page</p>

The extension activities page

Directus exposes its Express app for extensions to use so the client is simple a set of Express routes.

Each request is checked for a cookie storing the Strava authentication informations, and also is checked for the Directus authentication cookie. This means the app itself stores no data and requires very little configuration.

For the view I tried out the nunjucks templating engine and found it to be quite adequate.

Full Data Option

By default the Strava activities API is missing (I think quite deliberately) data for each activity. The ones that concerned me were the original GPX file and the private notes for each activity.

These are not exposed in any way via the API so the extension also allows you to provide your normal login details to acquire these extras via scraping.