Skip to main content

Garmin Connect activity exporter and backup tool

Project description

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

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

garminexport-0.7.1.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

garminexport-0.7.1-py2.py3-none-any.whl (27.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file garminexport-0.7.1.tar.gz.

File metadata

  • Download URL: garminexport-0.7.1.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for garminexport-0.7.1.tar.gz
Algorithm Hash digest
SHA256 f50f4c872a24858dc1695e6e6e9a44be4f64f461efb3a51b3a0719466ea45ee4
MD5 44502107292ffc98cce76287aaa87c3c
BLAKE2b-256 2b85ee85afc0c76c18b3728c550184566e5abe5ccb45669822a153afc3be63b8

See more details on using hashes here.

File details

Details for the file garminexport-0.7.1-py2.py3-none-any.whl.

File metadata

  • Download URL: garminexport-0.7.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for garminexport-0.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c882109e23bd539fff38b2fb72a21618e6e6e46c8bc77763e5e522c9867201ba
MD5 cb92e08c72bf16e4b0ae59dd25be7684
BLAKE2b-256 6e8be606871f61eb7a6b7f6ce89193d838d122fae44b0aebe64409a61f5c3396

See more details on using hashes here.

Supported by

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