Skip to main content

A package to convert Strava activities to GPX format

Project description

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']
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strava2gpx-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

strava2gpx-1.0.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file strava2gpx-1.0.0.tar.gz.

File metadata

  • Download URL: strava2gpx-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for strava2gpx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ff5bd606090fe75a4460201f9ef4cb5006cc7eb05602f894c9790237981001b4
MD5 70dea89fc44402c5bf855fb58674d4d2
BLAKE2b-256 5b25e12b6e058f9dbd4bac65b1281304a39775d4a6c82c37eb2051647b46a6d3

See more details on using hashes here.

File details

Details for the file strava2gpx-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: strava2gpx-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for strava2gpx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6ceb7d10935e68239dcc1ef62b162b4827f1198ee6e982cfe34fd2871a1b391
MD5 6c2714ea23850f3b68946438ba96f901
BLAKE2b-256 04de2818abf684f544fbee707304d399322d6e0c640dc17c98c839b481333d7e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page