Back

Strava API Essential Guide

Aug 11, 20246 minute read

What type of API does Strava provide?

Strava uses a REST API. Here are the key points about Strava's API:

API Type

Strava provides a RESTful API (Representational State Transfer).

Key Characteristics

  1. REST Architecture: The API follows REST principles, making data available as resources.

  2. Authentication: It uses OAuth 2.0 for authentication, requiring access tokens for all requests.

  3. Rate Limiting: The API has rate limits, allowing 200 requests every 15 minutes, with up to 2,000 requests per day by default.

  4. Single Endpoint: The API is accessed through a single base URL: https://www.strava.com/api/v3/.

  5. HTTP Methods: It uses standard HTTP methods like GET, POST, PUT, and DELETE for different operations.

API Features

  • The API provides access to data on athletes, segments, routes, clubs, and gear.
  • It supports webhooks for real-time notifications of new activities.
  • The API uses JSON for data formatting and exchange.

Documentation and Tools

  • Strava provides comprehensive API documentation, including a Swagger Playground for testing API calls.
  • The Swagger Playground allows developers to familiarize themselves with the API by submitting HTTP requests and observing responses.

Best Practices

  • Developers should create an application and request athlete authorization using OAuth 2.0 to access data.
  • It's recommended to use the Swagger Playground to test and understand the API before writing client code.

In summary, Strava's REST API provides a robust and well-documented interface for developers to interact with Strava's data, following modern API design principles and best practices.

Does the Strava API have webhooks?

Yes, the official Strava API does have webhooks. Here are the key points about Strava's webhook functionality:

Webhook Support

Strava offers a Webhook Events API that allows applications to subscribe to real-time events.

Event Types

You can subscribe to the following types of events:

  1. Athlete events:

    • When an athlete revokes access to your application
  2. Activity events:

    • When an activity is created
    • When an activity is deleted
    • When certain activity fields are updated, including:
      • Title
      • Type
      • Privacy (requires activity:read_all scope)

Key Considerations

  • Each application can only have one subscription, but that subscription will receive events for all supported changes to data owned by athletes who have authorized the application.
  • When an event occurs, Strava sends a POST request to the callback URL you specify, containing details like:
    • object_type (activity or athlete)
    • object_id
    • aspect_type (create, update, or delete)
    • updates (for activity updates)
    • owner_id
    • subscription_id
    • event_time
  • Your callback endpoint must acknowledge the POST request with a 200 OK status within two seconds.
  • To set up a webhook subscription, you need to:
    1. Create a subscription by making a POST request to Strava's API
    2. Validate the callback address by responding to a GET request from Strava

Best Practices

  • Implement webhooks to know when an athlete has deauthorized your application (required by API terms).
  • Use webhooks to avoid hitting rate limits.
  • Subscribe to activity updates instead of polling for new activities.
  • Use webhooks to know if activities have changed from public to private.

By using webhooks, you can receive real-time updates and eliminate the need for polling, which is more efficient and helps you stay within API rate limits.

Rate Limits and other limitations

Here are the key points about the API rate limits for the Strava API:

Overall Rate Limits

  • The default overall rate limit allows 200 requests every 15 minutes, with up to 2,000 requests per day.

  • There is a separate "non-upload" rate limit that allows 100 requests every 15 minutes, with up to 1,000 requests per day.

Rate Limit Details

  • The 15-minute limit resets at natural 15-minute intervals (0, 15, 30, 45 minutes past the hour).

  • The daily limit resets at midnight UTC.

  • Exceeding the limit returns a 429 Too Many Requests error.

  • Requests exceeding the short-term limit still count toward the long-term limit.

Monitoring Usage

  • An application's limits and usage are reported on the API application settings page.

  • Rate limit information is returned in HTTP headers with every API request:

    • X-RateLimit-Limit: 15-minute limit, daily limit
    • X-RateLimit-Usage: 15-minute usage, daily usage
    • X-ReadRateLimit-Limit: 15-minute limit, daily limit for read operations
    • X-ReadRateLimit-Usage: 15-minute usage, daily usage for read operations

Increasing Rate Limits

  • Rate limits may be adjusted as an application grows.

  • To request a rate limit increase:

    1. Create demand and have a popular app approaching capacity
    2. Review and comply with API terms and brand guidelines
    3. Submit for review using the Developer Program form
    4. Include screenshots showing Strava data usage and "Connect with Strava" button

Best Practices

  • Implement webhooks to avoid hitting daily limits from activity polling.
  • Use API response headers to throttle requests when approaching 15-minute limits.

The rate limits are designed to manage API usage across applications while allowing for growth. Developers can request increases as their applications gain popularity and demonstrate compliance with Strava's guidelines.

Latest API Version

The most recent version of the Strava API is V3. Here are the key points about the Strava API version:

Current Version

  • The current version of the Strava API is V3 [2][3].

Key Points

  • The V3 API is a stable interface used by Strava mobile apps and 3rd party applications to communicate with Strava [1].

  • It is referred to as the "Strava API v3" in the official documentation [2].

  • The V3 API was introduced several years ago and has been continuously updated and maintained since then.

Recent Updates

  • While the core API version remains V3, Strava regularly makes updates and changes to the API functionality. Some recent updates include:

    • July 3, 2024: Changes to how activities with hidden start times are returned [1].

    • December 9, 2019: Updates to the URL for managing push subscriptions (webhooks) [1].

  • Strava maintains a changelog to document functional changes to the V3 API over time [1].

Best Practices

  • Developers should refer to the latest API documentation and changelog when working with the Strava API to stay up-to-date on any changes or new features within the V3 version.

  • The Swagger Playground (https://developers.strava.com/playground) is recommended for testing and familiarizing yourself with the current API functionality [2][4].

In summary, while Strava continues to update and improve the API, the core version remains V3. Developers should stay informed about changes within this version by monitoring the official documentation and changelog.

How to get a Strava developer account and API Keys?

To get a developer account for Strava and create an API integration, you need to follow these steps:

1. Create a Strava Account

First, you need to sign up for a regular Strava account if you don't already have one:

  • Go to https://www.strava.com/register and create a Strava account.

2. Create an API Application

Once you have a Strava account and are logged in:

  • Go to https://www.strava.com/settings/api
  • Click on "Create Application" to set up your API integration.

3. Configure Your API Application

On the "My API Application" page, you'll need to provide some information:

  • Application Name
  • Category
  • Website URL
  • Authorization Callback Domain
  • Description

After creating your application, you'll see important details like:

  • Client ID
  • Client Secret
  • Authorization token
  • Refresh token
  • Rate limits

Key Points to Consider

  • Keep your Client Secret, Authorization token, and Refresh token confidential.
  • The Authorization token changes every six hours.
  • The default rate limit is 200 requests every 15 minutes, with up to 2,000 requests per day.
  • You'll need to use OAuth 2.0 for authentication to access athlete data.

Best Practices

  • When developing, set the "Authorization Callback Domain" to localhost. When going live, change it to your actual domain.
  • Never share access tokens, refresh tokens, authorization codes, or your client secret in public forums.
  • Familiarize yourself with the Strava API documentation at https://developers.strava.com.

By following these steps, you'll be able to set up a developer account and create an API integration with Strava. Remember to comply with Strava's API Agreement and Brand Guidelines when using their API.

What can you do with the Strava API?

Based on the search results provided, here is a list of data models you can interact with using the Strava API, along with key points about what is possible for each:

Activities

  • Get detailed information about individual activities [1]
  • Upload new activities [2]
  • Get activity streams (detailed time-series data) [3]
  • Update activity details [1]
  • Delete activities [1]

Key points:

  • Activities include data like distance, time, speed, elevation, heart rate, etc. [2]
  • Activity streams provide second-by-second data for metrics like speed, power, heart rate [3]
  • You can get data for the authenticated athlete's activities [2]

Athletes

  • Get profile information for the authenticated athlete [1][2]
  • Get an athlete's stats (totals and recent activity counts) [1]
  • Update an athlete's profile [1]

Key points:

  • You can only access data for athletes who have authorized your app [2]
  • Basic profile info like name, profile picture, location is available [2]

Routes

  • Get details of specific routes [1]
  • Create new routes [1]
  • Update existing routes [1]

Segments

  • Get details about segments [1]
  • Get leaderboards for segments [1]
  • Star/unstar segments for the authenticated athlete [1]

Clubs

  • Get details about clubs [1]
  • Get club members [1]
  • Get club activities [1]

Gear

  • Get details about an athlete's gear (bikes, shoes, etc.) [1][5]

Key points:

  • Basic gear info like distance, brand, model is available [5]
  • Detailed component info is not available via the API [5]

General API Usage

  • Authentication is required using OAuth 2.0 [2]
  • Rate limits apply (200 requests per 15 minutes, 2000 per day by default) [2]
  • Data is returned in JSON format [1]
  • Pagination is used for large data sets [2]

In summary, the Strava API provides access to a wide range of athlete and activity data, allowing developers to build applications that can analyze and visualize athletic performance, manage routes and segments, and interact with clubs and gear information. The API requires authentication and adherence to rate limits and terms of service.