Skip to main content

Strava2GPX

strava2gpx

Small Tutorial

A Python package to convert Strava activities using the Strava API to GPX format. Supports encoding heart rate, cadence, power (watts), and temperature data into GPX file using Garmin GpxExtensions format. Will not convert activity types without GPS data (e.g. Yoga, Weightlifting, etc.) Open a new issue to request additional features and report current problems or open a pull request if you want to contribute your own work.

Installation

pip install strava2gpx

Update

pip install --upgrade strava2gpx

Usage Examples

Write Activity by ID to GPX File

from strava2gpx import strava2gpx
import asyncio

'''
Sends web requests so use in conjunction with asyncio 
or any other async library
'''

async def main():
    '''
    put in your Strava Api client_id, refresh_token, and client_secret
    '''
    client_id = '123456'
    refresh_token = 'adfh750a7s5df8a00dh7asdf98a9s8df6s9asdf8'
    client_secret = 'ahgdyt5672i3y8d345hgd2345c23hjgd1234yd23'

    # create an instance of strava2gpx
    s2g = strava2gpx(client_id, client_secret, refresh_token)

    # connect to Strava API
    await s2g.connect()

    # write activity to output.gpx by activity id
    await s2g.write_to_gpx(11893637629, "output")

if __name__ == '__main__':
    asyncio.run(main())

Get a List of All User Activities

from strava2gpx import strava2gpx
import asyncio
import os

async def main():
    '''
    put in your Strava Api client_id, refresh_token, and client_secret
    example using env variables
    '''
    client_id = os.getenv('STRAVA_CLIENT_ID')
    client_secret = os.getenv('STRAVA_CLIENT_SECRET')
    refresh_token = os.getenv('STRAVA_REFRESH_TOKEN')

    # create an instance of strava2gpx
    s2g = strava2gpx(client_id, client_secret, refresh_token)

    # connect to Strava API
    await s2g.connect()

    # get a list of all user's Strava activities
    activities_list = await s2g.get_activities_list()

    '''
    Each list element is the following format
    [name, id, start_date, type]
    '''

    print(activities_list[0:5])

if __name__ == '__main__':
    asyncio.run(main())

Output

[
    ['Legs may be sore', 11910466229, '2024-07-17T11:57:21Z', 'Ride'],
    ['Tall Grass, Hidden Dirt', 11906994862, '2024-07-17T00:10:57Z', 'Ride'],
    ['A little thunder there, a little MTB here', 11898361818, '2024-07-16T01:16:13Z', 'Ride'],
    ['Morning Run', 11893637629, '2024-07-15T11:50:49Z', 'Run'],
    ['Afternoon Yoga', 11880523323, '2024-07-13T19:09:04Z', 'Yoga']
]

Metadata

Release files for strava2gpx 1.0.1

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

Source distribution (sdist)

Source distribution for strava2gpx 1.0.1
File Size Uploaded
strava2gpx-1.0.1.tar.gz 5.6 kB Details

Built distribution (wheel)

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

Total release size: 11.5 kB

Release files / strava2gpx-1.0.1.tar.gz

Download URL strava2gpx-1.0.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
18303899495c0b3d872c872739ce5d97c52438c2eb823b46dd0cfe74b29c7f92
BLAKE2b-256 checksum
How to use checksums
46d9d8f774e212c8f6e56d7d4a3e4846aefa4be2afd4b6cf16d89828dc759ff9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / strava2gpx-1.0.1-py3-none-any.whl

Download URL strava2gpx-1.0.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7483c6d8616382306c2c2cd3b7811d53fe1682bca69220d2dcb4d4e0bf57c81c
BLAKE2b-256 checksum
How to use checksums
b8c345b4468c86ec4bfb144648624fd23a7d4d575f2d2d4bf0efd8577669229b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.26

2 release files

0.25

2 release files

0.24

2 release files

0.22

2 release files

0.21

2 release files

0.2

2 release files

0.1

2 release files

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