Skip to content
code run strava automation webhook

Strava Webhooks with Stokehook.com

By Published 1 min read

Last verified in 2022. APIs or CLI flags may have changed; browse newer #run posts.

I recently implemented a small application, Stokehook.com, that can send webhooks for your Strava activities to any endpoint. Getting data out of Strava as it is uploaded has never been easy to do and I wanted to fix that in a way that lets other developers integrate the activities into other workflows.

Stokehook dashboard forwarding Strava activity webhook events
Stokehook dashboard forwarding Strava activity webhook events

Tech stack

  • Svelte + SvelteKit
  • TailwindCSS
  • Firestore
  • Firebase Auth
  • Hosted on Netlify (easier than Firebase functions and hosting for now)

How it works

The app does the following:

  1. Handle authentication with Strava
  2. Receives a webhook from Strava for all app users
  3. Looks up the webhook setting for the user
  4. Refreshes the access token for the user
  5. Enriches the webhook with the full object (Strava sends minimal information in their webhook)
  6. Sends it off to the user’s endpoint

The interface for the app is pretty simple.

Stokehook destination webhook URL and secret configuration panel
Stokehook destination webhook URL and secret configuration panel

Payload

The key feature is that Strava sends a “thin” webhook with minimal fields for the activity. The app gets all fields for the object via the Strava API before sending it along.

So instead of:

{
  "aspect_type": "create",
  "event_time": 1654224986,
  "object_id": 7246184314,
  "object_type": "activity",
  "owner_id": 2170160,
  "subscription_id": 217592,
  "updates": {}
}

The payload ends up looking like:

{
  "aspect_type": "create",
  "event_time": 1654224986,
  "object_id": 7246184314,
  "object_type": "activity",
  "owner_id": 2170160,
  "subscription_id": 217592,
  "updates": {},
  "data": {
    "resource_state": 3,
    "athlete": {
      "id": 2170160,
      "resource_state": 1
    },
    "name": "Evening Hike",
    "distance": 2077.3,
    "moving_time": 1700,
    "elapsed_time": 1843,
    "total_elevation_gain": 25,
    "type": "Hike",
    "id": 7246184314,
    "start_date": "2022-06-03T02:22:32Z",
    "start_date_local": "2022-06-02T20:22:32Z",
    "...": "...",
    "pr_count": 0,
    "total_photo_count": 0,
    "has_kudoed": false,
    "suffer_score": 2,
    "description": null,
    "calories": 99,
    "perceived_exertion": null,
    "prefer_perceived_exertion": null,
    "segment_efforts": [],
    "...": "...",
    "available_zones": ["heartrate"]
  },
  "meta": {
    "id": "FDnZJ5smHVVPYQAVOrq3",
    "url": "https://webhook.site/633a324a-eec8-46d1-9bb8-d7b7ca0d90b5"
  }
}

Try it out at Stokehook.com!