Skip to main content

Build badge PyPi release PyPI - Python Version PyPI - License

About

garminexport is both a library and a tool for downloading/backing up Garmin Connect 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 and can be installed with pip.

pip install garminexport

Usage

Prerequisites

To be of any use you need to register an account at Garmin Connect and populate it with some activities.

Authentication

As a user you only need to supply username and password to garminexport (you will also be prompted for an MFA code if your account has multi-factor authentication enabled). This information is handed over to the garth library which executes the same authentication flow as the Garmin Connect Android app to exchange your user credentials for an OAuth2 token which is used to sign subsequent API requests.

The oauth2 token is stored under ~/.garminexport (or the folder given by --auth-token-dir) and will be reused as long as the token has not expired. Only if the OAuth token has expired will a new login be initiated.

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):

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).

    GPX 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.

  • 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.

    TCX (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).

  • 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.

    The 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.

  • json_summary: activity summary file (JSON).

    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.

  • json_details: activity details file (JSON).

    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.

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 --helpfor more details.
  • garmin-upload-activity: uplad a single Garmin Connect activity file (.fit, .gpx, or .tcx). Run with --helpfor 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.

For example, in your setup.py, setup.cfg, pyproject.toml (PEP 631) add something like:

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

Metadata

Release files for garminexport 0.7.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 garminexport 0.7.1
File Size Uploaded
garminexport-0.7.1.tar.gz 25.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for garminexport 0.7.1
File Interpreter ABI Platform
garminexport-0.7.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 53.2 kB

Release files / garminexport-0.7.1.tar.gz

Download URL garminexport-0.7.1.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f50f4c872a24858dc1695e6e6e9a44be4f64f461efb3a51b3a0719466ea45ee4
BLAKE2b-256 checksum
How to use checksums
2b85ee85afc0c76c18b3728c550184566e5abe5ccb45669822a153afc3be63b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release files / garminexport-0.7.1-py2.py3-none-any.whl

Download URL garminexport-0.7.1-py2.py3-none-any.whl
Size 27.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c882109e23bd539fff38b2fb72a21618e6e6e46c8bc77763e5e522c9867201ba
BLAKE2b-256 checksum
How to use checksums
6e8be606871f61eb7a6b7f6ce89193d838d122fae44b0aebe64409a61f5c3396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

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