strava2gpx


Namestrava2gpx JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryA package to convert Strava activities to GPX format
upload_time2024-07-18 23:25:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords strava gpx convert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Strava2GPX
![strava2gpx](https://github.com/user-attachments/assets/12a5735d-cb4d-4a2f-900f-47e6fb3b191d)

[Small Tutorial](https://jamesephelps.com/2024/07/18/how-to-get-gpx-files-from-the-strava-api-strava2gpx-python/)

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

```sh
pip install strava2gpx
```
## Update

```sh
pip install --upgrade strava2gpx
```

## Usage Examples

### Write Activity by ID to GPX File
```python
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
```python
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']
]
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "strava2gpx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "strava, gpx, convert",
    "author": null,
    "author_email": "James Phelps <jamesphelpsmail@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/5b/25/e12b6e058f9dbd4bac65b1281304a39775d4a6c82c37eb2051647b46a6d3/strava2gpx-1.0.0.tar.gz",
    "platform": null,
    "description": "# Strava2GPX\n![strava2gpx](https://github.com/user-attachments/assets/12a5735d-cb4d-4a2f-900f-47e6fb3b191d)\n\n[Small Tutorial](https://jamesephelps.com/2024/07/18/how-to-get-gpx-files-from-the-strava-api-strava2gpx-python/)\n\nA 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.\n\n\n## Installation\n\n```sh\npip install strava2gpx\n```\n## Update\n\n```sh\npip install --upgrade strava2gpx\n```\n\n## Usage Examples\n\n### Write Activity by ID to GPX File\n```python\nfrom strava2gpx import strava2gpx\nimport asyncio\n\n'''\nSends web requests so use in conjunction with asyncio \nor any other async library\n'''\n\nasync def main():\n    '''\n    put in your Strava Api client_id, refresh_token, and client_secret\n    '''\n    client_id = '123456'\n    refresh_token = 'adfh750a7s5df8a00dh7asdf98a9s8df6s9asdf8'\n    client_secret = 'ahgdyt5672i3y8d345hgd2345c23hjgd1234yd23'\n\n    # create an instance of strava2gpx\n    s2g = strava2gpx(client_id, client_secret, refresh_token)\n\n    # connect to Strava API\n    await s2g.connect()\n\n    # write activity to output.gpx by activity id\n    await s2g.write_to_gpx(11893637629, \"output\")\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n### Get a List of All User Activities\n```python\nfrom strava2gpx import strava2gpx\nimport asyncio\nimport os\n\nasync def main():\n    '''\n    put in your Strava Api client_id, refresh_token, and client_secret\n    example using env variables\n    '''\n    client_id = os.getenv('STRAVA_CLIENT_ID')\n    client_secret = os.getenv('STRAVA_CLIENT_SECRET')\n    refresh_token = os.getenv('STRAVA_REFRESH_TOKEN')\n\n    # create an instance of strava2gpx\n    s2g = strava2gpx(client_id, client_secret, refresh_token)\n\n    # connect to Strava API\n    await s2g.connect()\n\n    # get a list of all user's Strava activities\n    activities_list = await s2g.get_activities_list()\n\n    '''\n    Each list element is the following format\n    [name, id, start_date, type]\n    '''\n\n    print(activities_list[0:5])\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n#### Output\n```\n[\n    ['Legs may be sore', 11910466229, '2024-07-17T11:57:21Z', 'Ride'],\n    ['Tall Grass, Hidden Dirt', 11906994862, '2024-07-17T00:10:57Z', 'Ride'],\n    ['A little thunder there, a little MTB here', 11898361818, '2024-07-16T01:16:13Z', 'Ride'],\n    ['Morning Run', 11893637629, '2024-07-15T11:50:49Z', 'Run'],\n    ['Afternoon Yoga', 11880523323, '2024-07-13T19:09:04Z', 'Yoga']\n]\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A package to convert Strava activities to GPX format",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/jime567/strava2gpx"
    },
    "split_keywords": [
        "strava",
        " gpx",
        " convert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "04de2818abf684f544fbee707304d399322d6e0c640dc17c98c839b481333d7e",
                "md5": "6c2714ea23850f3b68946438ba96f901",
                "sha256": "d6ceb7d10935e68239dcc1ef62b162b4827f1198ee6e982cfe34fd2871a1b391"
            },
            "downloads": -1,
            "filename": "strava2gpx-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6c2714ea23850f3b68946438ba96f901",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5865,
            "upload_time": "2024-07-18T23:25:21",
            "upload_time_iso_8601": "2024-07-18T23:25:21.155427Z",
            "url": "https://files.pythonhosted.org/packages/04/de/2818abf684f544fbee707304d399322d6e0c640dc17c98c839b481333d7e/strava2gpx-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b25e12b6e058f9dbd4bac65b1281304a39775d4a6c82c37eb2051647b46a6d3",
                "md5": "70dea89fc44402c5bf855fb58674d4d2",
                "sha256": "ff5bd606090fe75a4460201f9ef4cb5006cc7eb05602f894c9790237981001b4"
            },
            "downloads": -1,
            "filename": "strava2gpx-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "70dea89fc44402c5bf855fb58674d4d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5576,
            "upload_time": "2024-07-18T23:25:22",
            "upload_time_iso_8601": "2024-07-18T23:25:22.451622Z",
            "url": "https://files.pythonhosted.org/packages/5b/25/e12b6e058f9dbd4bac65b1281304a39775d4a6c82c37eb2051647b46a6d3/strava2gpx-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-18 23:25:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jime567",
    "github_project": "strava2gpx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "strava2gpx"
}
        
Elapsed time: 0.26383s