Strava Sensors – Using RESTful API

I have been having a play around to see what kind of information can be gathered from the strava api for us that cycle.

This is far from what i want to be able to do with the API, but i see this as a start.

If anyone else is interested in helping me please drop me a pm. I would love to make a component that we can easily integrate into HAS.

Get yourself to

The access token retrieved via settings ->

My API Application this has the default permission, which means we can only read public activities.

I am working on writing some simple scripts to delete and upload new activities, which requires an access token with write permission.

This guide details how to quickly get a Strava access token with write access.

Log into the strava website

Create an application “My Api Application”

Make sure that you set the callback URL a localhost.

We will need to to obtain an authorization token.

Take note of your client ID, these will be needed later

Leave strava tab open

Create a request URL for Strava authorization, where the base URL is and parameters are:

client_id: your application’s ID, obtained during registration
redirect_uri: URL to which the user will be redirected with the authorization code.
response_type: must be ‘code’
scope: ‘public’, ‘write’, ‘view_private’, ‘view_private,write’



Copy the above URL with your “Client_id” into a browser.
Browser will 404 as


Does not exist.

Authorize the app on Strava.

Copy the authorization URL from previous step and take note of the code.




Use a rest client. Perform a POST to as documented in the API.

client_id: your application’s ID, obtained during registration
client_secret: your application’s secret, obtained during registration
code: authorization code from last step


$ curl -X POST


Retrieving Data from API Endpoints

Strava offers many endpoints, i have only played around with a couple at the moment.


Example using v3/activities

Using a rest client perform a GET with the following“YOUR_API_KEY

Information returned from the API

Any of the fields can be used and brought into the front end in HomeAssistant using the rest platform.

It is worth referring to the documentation when picking up fields in Home assistant.

As an example elevation_gain is reported in meters, but on my mobile app it is reported in ft. It bugged me the wrong measurement being reported in Home Assistant on the front end.

total_elevation_gain: float

Using a value template you can convert metres to feet and vice versa.

value_template: '{{ value_json[0].elev_high | multiply(3.280839895) | round(1) }}'
1 Meter = 3.28084 feet

Home Assistant Configuration

Sensor.yaml sample

Picking up the elev_high parameter from the api which is reported in metres, but converted to FT

– platform: rest
name: strava_elev_high
method: GET
value_template: ‘{{ value_json[0].elev_high | multiply(3.280839895) | round(1) }}’
unit_of_measurement: ft
scan_interval: 300

Group Created on Information from API

Automation based on sensor

– alias: Notify Last Ride Mileage
– platform: state
entity_id: sensor.strava_last_ride_milage
condition: template
value_template: “{{ states(‘sensor.strava_last_ride_mileage) != ‘unknown’ }}”
– service: notify.notifier_telegram
message: Ride uploaded to strava

i hope to add more sensors so that when a message is sent to a notifier we can have a summary of information such as heart rate, average, speed etc. These sensors can then be used with tts script.

Very quick write up so apologies for any mistakes