Skip to main content

strava

CI codecov PyPI Python PyPI - Downloads License

A fully typed Python SDK for the Strava API v3. Supports Python 3.11–3.14, sync and async HTTPX clients, typed dataclass models, automatic OAuth refresh, and lazy pagination.

Installation

pip install strava

Quick Start

Register an application and obtain an access token with the scopes your app needs. For this example, request read and activity:read (activity:read_all to include Only Me activities). Set STRAVA_ACCESS_TOKEN in your environment; do not put real tokens in source code.

import os

from strava import Strava

with Strava(access_token=os.environ["STRAVA_ACCESS_TOKEN"]) as client:
    athlete = client.athletes.retrieve_authenticated()
    print(f"{athlete.firstname} {athlete.lastname}")

    # Fetch at most 10 activities, not the athlete's entire history.
    activities = client.activities.list(per_page=10).collect(max_items=10)
    for activity in activities:
        print(f"{activity.name} - {activity.distance}m")
        print(activity.device_name)  # Recording device, when supplied by Strava

per_page sets the page size, not a total result limit. Iterating client.activities.list(per_page=10) without a bound continues fetching pages. Use collect(max_items=10) to limit the returned results.

Async

import asyncio
import os

from strava import AsyncStrava


async def main() -> None:
    async with AsyncStrava(access_token=os.environ["STRAVA_ACCESS_TOKEN"]) as client:
        athlete = await client.athletes.retrieve_authenticated()
        activities = await client.activities.list(per_page=10).collect(max_items=10)
        print(athlete.firstname, len(activities))


asyncio.run(main())

Creating an async paginator does not need await; collecting it does. Keep the client open while consuming a paginator.

Next Steps

  • Usage guide: secure OAuth with one-time state validation, token storage and refresh, custom HTTPX clients, pagination, uploads, and webhooks.
  • Practical API reference: all 34 endpoints across 10 resource groups, return types, scopes, units, errors, and rate limits.
  • Migration guide: compatibility changes and Strava's announced 2026–2027 API changes.

The API covers activities, athletes, clubs, gear, routes, segments, segment efforts, streams, uploads, and webhook subscriptions. Both clients expose the same resource methods. Activity creation, updates, and uploads support visibility and activity tags.

OAuth and HTTP configuration

Use build_authorization_url() with unpredictable, server-stored state, then validate and consume that state before exchanging the callback code. Do not log tokens or client secrets. The OAuth example shows the required application-side checks.

The SDK provides exchange_token(), refresh_access_token(), and revoke_token(), plus their async_ counterparts. Helpers accept configurable timeout and caller-owned http_client arguments. For automatic refresh, give Strava or AsyncStrava the refresh credentials, expiration timestamp, and a token persistence callback.

Pass a custom HTTPX client for connection pooling, transports, or event hooks. The SDK controls request authentication, API base_url, and timeout without mutating or closing your HTTPX client. See HTTP client ownership and configuration.

Errors and rate limits

HTTP API errors raise StravaError subclasses; HTTPX transport and timeout exceptions propagate separately. client.rate_limits exposes the most recent rate-limit headers, including an exceeded flag. The SDK does not retry or sleep automatically. See errors and rate limits for handling guidance.

Compatibility Notes

  • Activity and athlete endpoint IDs accept int | str. Models preserve both id and optional id_str without synthesizing either. Python integers retain 64-bit IDs exactly; prefer strings at JavaScript boundaries. See ID migration.
  • The default API URL remains https://www.strava.com/api/v3. Strava's announced https://api-v3.strava.com host becomes available January 4, 2027; the SDK does not switch automatically.
  • Strava retired club activity/member/admin endpoints September 1, 2026. segments.explore() now requires approved Extended Access.
  • deauthorize() is deprecated ahead of its June 1, 2027 retirement. Use revoke_token() or async_revoke_token() for new code.

See the migration guide before upgrading existing code and the changelog for release history.

Development and Contributing

uv sync
make help

Read CONTRIBUTING.md for targeted validation commands, testing guidelines, and the Python 3.11–3.14 CI matrix.

Found a bug? Open an issue. Have an idea? Request a feature.

Metadata

Release files for strava 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strava 0.7.0
File Size Uploaded Provenance Actions
strava-0.7.0.tar.gz 43.8 kB With provenance Details for strava-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for strava 0.7.0
File Interpreter ABI Platform Actions
strava-0.7.0-py3-none-any.whl Python 3 none any Details for strava-0.7.0-py3-none-any.whl

Total release size: 95.1 kB

Release files / strava-0.7.0.tar.gz

Download URL strava-0.7.0.tar.gz
Size 43.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d7c3545f45179000edd6e15824bfb1a4591dad9984014f67c7f29cd4e330c134
BLAKE2b-256 checksum
How to use checksums
6cfb5c4e138ecb50d5920486f6c536efd83232811d2e26d82b8ee49cf47da1ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / strava-0.7.0-py3-none-any.whl

Download URL strava-0.7.0-py3-none-any.whl
Size 51.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31d1b69453629d41a883dfcb3439701177b5d648f63d34258a1c24105c349f52
BLAKE2b-256 checksum
How to use checksums
e4c33e43006f561877b3fd35e5af7c2478f02cffdd8c6684ed1b7312b542aefd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for strava 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for strava-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page