
[](https://img.shields.io/pypi/v/garminexport.svg)


# About
`garminexport` is both a library and a tool for downloading/backing up
[Garmin Connect](http://connect.garmin.com/) activities to local disk.
The main utility script is called `garmin-backup` and performs incremental
backups of your Garmin account to a local directory. The first time
`garmin-backup` is run, it will download _all_ activities. After that, it will
do incremental backups of your account. That is, the script will only download
activities that haven't already been downloaded to the backup directory.
# Installation
`garminexport` is available on [PyPi](https://pypi.org/) and can be installed
with [pip](http://pip.readthedocs.org).
```bash
pip install garminexport
```
# Usage
## Prerequisites
To be of any use you need to register an account at
[Garmin Connect](http://connect.garmin.com/) and populate it with some
activities.
## Authentication
Logging in with the user-supplied username and password gives `garminexport` two
important pieces of data needed to authenticate further client requests:
- An OAuth bearer token.
- A `JWT_FGP` cookie.
These are both stored under `~/.garmexport` (or the folder given by
`--auth-token-dir`) and will be reused as long as the OAuth token has not
expired. Only if the OAuth token has expired (normally after two hours) will a
new login be initiated. Doing too many logins in a short period of time risks
seeing your IP address being temporarily blocked by CloudFlare (normally
indicated by a `429 (Too Many Requests)` response). The reuse of authentication
tokens should make this a non-issue though.
## As a command-line tool (garmin-backup)
The backup program is run as follows (use the `--help` flag for a full list of
available options):
```bash
garmin-backup --backup-dir=activities <username or email>
```
Once started, the program will prompt you for your account password and then log
in to your Garmin Connect account to download activities to the specified backup
directory on your machine. The program will only download activities that aren't
already in the backup directory.
Activities can be exported in any of the formats outlined below. Note that by
default, the program downloads all formats for every activity. Use the
`--format` option to narrow the selection.
Supported export formats:
- `gpx`: activity GPX file (XML).
<sub>[GPX](https://en.wikipedia.org/wiki/GPS_Exchange_Format) is an open
format, mainly for storing GPS routes/tracks. It does support extensions and
Garmin appears to annotate the GPS data with, for example, heart-rate and
cadence, when available on your device.</sub>
- `tcx`: an activity TCX file (XML). _Note: a `.tcx` file may not always be
possible to export, for example if an activity was uploaded in gpx format. In
that case, Garmin won't try to synthesize a tcx file._
<sub>[TCX](https://en.wikipedia.org/wiki/Training_Center_XML) (Training Center
XML) is Garmin's own XML format. It is, essentially, an extension of GPX which
includes more metrics and divides the GPS track into "laps" as recorded by
your device (with "lap summaries" for each metric).</sub>
- `fit`: activity FIT file (binary format). _Note: a `.fit` file may not always
be possible to export, for example if an activity was entered manually rather
than imported from a Garmin device._
<sub>The [FIT](https://www.thisisant.com/resources/fit/) format is the "raw
data type" stored in your Garmin device and should contain all metrics your
device is capable of tracking (GPS, heart rate, cadence, etc). It's a binary
format, so tools are needed to read its content.</sub>
- `json_summary`: activity summary file (JSON).
<sub>Provides summary data for an activity. Seems to lack a formal schema and
should not be counted on as a stable data format (it may change at any time).
Only included since it _may_ contain additional data that could be useful for
developers of analysis tools.</sub>
- `json_details`: activity details file (JSON).
<sub>Provides detailed activity data in a JSON format. Seems to lack a formal
schema and should not be counted on as a stable data format (it may change at
any time). Only included since it _may_ contain additional data that could be
useful for developers of analysis tools.</sub>
All files are written to the same directory (`activities/` by default). Each
activity file is prefixed by its upload timestamp and its activity id.
`garminexport` also contains a few smaller utility programs:
- `garmin-get-activity`: download a single Garmin Connect activity. Run with
`--help`for more details.
- `garmin-upload-activity`: uplad a single Garmin Connect activity file (`.fit`,
`.gpx`, or `.tcx`). Run with `--help`for more details.
## As a library
To build your own tools around the Garmin Connect API you can import the
`garminclient` module. It handles authentication to establish a secure session
with Garmin Connect. For example use, have a look at the command-line tools
under [garminexport/cli](garminexport/cli).
For example, in your `setup.py`, `setup.cfg`, `pyproject.toml`
([PEP 631](https://peps.python.org/pep-0631/)) add something like:
```python
install_requires=[
'garminexport',
...
]
```
# Contribute
To start working on the code, create a virtual environment (an isolated
development environment) and install the required dependencies like so:
# create virtualenv and populate it with library dependencies
make dev-init
# activate virtualenv
source .venv/bin/activate
# test
make test
Raw data
{
"_id": null,
"home_page": "https://github.com/petergardfjall/garminexport",
"name": "garminexport",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "garmin, export, backup",
"author": "Peter Gardfj\u00e4ll",
"author_email": "peter.gardfjall.work@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/99/b7/a9e12c9d2905d8ccefb7bd0452cb447ae7dcd0e3bd80e4eaf16c6b101306/garminexport-0.6.0.tar.gz",
"platform": null,
"description": "\n[](https://img.shields.io/pypi/v/garminexport.svg)\n\n\n\n# About\n\n`garminexport` is both a library and a tool for downloading/backing up\n[Garmin Connect](http://connect.garmin.com/) activities to local disk.\n\nThe main utility script is called `garmin-backup` and performs incremental\nbackups of your Garmin account to a local directory. The first time\n`garmin-backup` is run, it will download _all_ activities. After that, it will\ndo incremental backups of your account. That is, the script will only download\nactivities that haven't already been downloaded to the backup directory.\n\n# Installation\n\n`garminexport` is available on [PyPi](https://pypi.org/) and can be installed\nwith [pip](http://pip.readthedocs.org).\n\n```bash\npip install garminexport\n```\n\n# Usage\n\n## Prerequisites\n\nTo be of any use you need to register an account at\n[Garmin Connect](http://connect.garmin.com/) and populate it with some\nactivities.\n\n## Authentication\n\nLogging in with the user-supplied username and password gives `garminexport` two\nimportant pieces of data needed to authenticate further client requests:\n\n- An OAuth bearer token.\n- A `JWT_FGP` cookie.\n\nThese are both stored under `~/.garmexport` (or the folder given by\n`--auth-token-dir`) and will be reused as long as the OAuth token has not\nexpired. Only if the OAuth token has expired (normally after two hours) will a\nnew login be initiated. Doing too many logins in a short period of time risks\nseeing your IP address being temporarily blocked by CloudFlare (normally\nindicated by a `429 (Too Many Requests)` response). The reuse of authentication\ntokens should make this a non-issue though.\n\n## As a command-line tool (garmin-backup)\n\nThe backup program is run as follows (use the `--help` flag for a full list of\navailable options):\n\n```bash\ngarmin-backup --backup-dir=activities <username or email>\n```\n\nOnce started, the program will prompt you for your account password and then log\nin to your Garmin Connect account to download activities to the specified backup\ndirectory on your machine. The program will only download activities that aren't\nalready in the backup directory.\n\nActivities can be exported in any of the formats outlined below. Note that by\ndefault, the program downloads all formats for every activity. Use the\n`--format` option to narrow the selection.\n\nSupported export formats:\n\n- `gpx`: activity GPX file (XML).\n\n <sub>[GPX](https://en.wikipedia.org/wiki/GPS_Exchange_Format) is an open\n format, mainly for storing GPS routes/tracks. It does support extensions and\n Garmin appears to annotate the GPS data with, for example, heart-rate and\n cadence, when available on your device.</sub>\n\n- `tcx`: an activity TCX file (XML). _Note: a `.tcx` file may not always be\n possible to export, for example if an activity was uploaded in gpx format. In\n that case, Garmin won't try to synthesize a tcx file._\n\n <sub>[TCX](https://en.wikipedia.org/wiki/Training_Center_XML) (Training Center\n XML) is Garmin's own XML format. It is, essentially, an extension of GPX which\n includes more metrics and divides the GPS track into \"laps\" as recorded by\n your device (with \"lap summaries\" for each metric).</sub>\n\n- `fit`: activity FIT file (binary format). _Note: a `.fit` file may not always\n be possible to export, for example if an activity was entered manually rather\n than imported from a Garmin device._\n\n <sub>The [FIT](https://www.thisisant.com/resources/fit/) format is the \"raw\n data type\" stored in your Garmin device and should contain all metrics your\n device is capable of tracking (GPS, heart rate, cadence, etc). It's a binary\n format, so tools are needed to read its content.</sub>\n\n- `json_summary`: activity summary file (JSON).\n\n <sub>Provides summary data for an activity. Seems to lack a formal schema and\n should not be counted on as a stable data format (it may change at any time).\n Only included since it _may_ contain additional data that could be useful for\n developers of analysis tools.</sub>\n\n- `json_details`: activity details file (JSON).\n\n <sub>Provides detailed activity data in a JSON format. Seems to lack a formal\n schema and should not be counted on as a stable data format (it may change at\n any time). Only included since it _may_ contain additional data that could be\n useful for developers of analysis tools.</sub>\n\nAll files are written to the same directory (`activities/` by default). Each\nactivity file is prefixed by its upload timestamp and its activity id.\n\n`garminexport` also contains a few smaller utility programs:\n\n- `garmin-get-activity`: download a single Garmin Connect activity. Run with\n `--help`for more details.\n- `garmin-upload-activity`: uplad a single Garmin Connect activity file (`.fit`,\n `.gpx`, or `.tcx`). Run with `--help`for more details.\n\n## As a library\n\nTo build your own tools around the Garmin Connect API you can import the\n`garminclient` module. It handles authentication to establish a secure session\nwith Garmin Connect. For example use, have a look at the command-line tools\nunder [garminexport/cli](garminexport/cli).\n\nFor example, in your `setup.py`, `setup.cfg`, `pyproject.toml`\n([PEP 631](https://peps.python.org/pep-0631/)) add something like:\n\n```python\ninstall_requires=[\n 'garminexport',\n ...\n]\n```\n\n# Contribute\n\nTo start working on the code, create a virtual environment (an isolated\ndevelopment environment) and install the required dependencies like so:\n\n # create virtualenv and populate it with library dependencies\n make dev-init\n\n # activate virtualenv\n source .venv/bin/activate\n\n # test\n make test\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Garmin Connect activity exporter and backup tool",
"version": "0.6.0",
"project_urls": {
"Homepage": "https://github.com/petergardfjall/garminexport",
"Source": "https://github.com/petergardfjall/garminexport.git",
"Tracker": "https://github.com/petergardfjall/garminexport/issues"
},
"split_keywords": [
"garmin",
" export",
" backup"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6235a6b3c13d92ca7f4c6037ecd5c3943facefea76329490880f82b34fc8361e",
"md5": "6795bef27bbf20d18c1f8dc9f365265e",
"sha256": "4651896ed0beb74a75ce35c4aaed30c0f6a98fcd8fdf92db997a2a3e4c4dc0e4"
},
"downloads": -1,
"filename": "garminexport-0.6.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "6795bef27bbf20d18c1f8dc9f365265e",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.9",
"size": 30671,
"upload_time": "2025-08-17T08:47:08",
"upload_time_iso_8601": "2025-08-17T08:47:08.678153Z",
"url": "https://files.pythonhosted.org/packages/62/35/a6b3c13d92ca7f4c6037ecd5c3943facefea76329490880f82b34fc8361e/garminexport-0.6.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "99b7a9e12c9d2905d8ccefb7bd0452cb447ae7dcd0e3bd80e4eaf16c6b101306",
"md5": "0ac7b0ac428c4067534bdd5d82935401",
"sha256": "b74f388243cc9d6a8055fbe1e857d815762059eeb400c3879ab83b63a3353bb1"
},
"downloads": -1,
"filename": "garminexport-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "0ac7b0ac428c4067534bdd5d82935401",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 29348,
"upload_time": "2025-08-17T08:47:10",
"upload_time_iso_8601": "2025-08-17T08:47:10.292373Z",
"url": "https://files.pythonhosted.org/packages/99/b7/a9e12c9d2905d8ccefb7bd0452cb447ae7dcd0e3bd80e4eaf16c6b101306/garminexport-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-17 08:47:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "petergardfjall",
"github_project": "garminexport",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "certifi",
"specs": [
[
"==",
"2025.8.3"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.4.3"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.10"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.9.0.post0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.32.4"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.17.0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.5.0"
]
]
}
],
"lcname": "garminexport"
}