Go to file
Dan Lenski ec0b8e651d
gracefully handle duplicate and slow activity uploads
upload_activity: handle poll-and-wait for uploads that require long processing time
2020-10-07 06:01:57 +02:00
garminexport gracefully handle duplicate and slow activity uploads 2020-10-07 06:01:57 +02:00
samples Simplify log statements. 2020-04-07 12:49:44 +02:00
tests Make code compatible with Python 2.6+ and Python 3 2018-06-06 22:41:03 +02:00
.gitignore update gitignore 2020-04-07 20:40:00 +02:00
.travis.yml travis: use pipenv 2020-04-08 20:31:26 +02:00
LICENSE initial commit 2014-11-08 13:35:47 +01:00
Makefile switch from requirements.txt to pipenv/Pipfile 2020-04-08 20:25:16 +02:00
Pipfile switch from requirements.txt to pipenv/Pipfile 2020-04-08 20:25:16 +02:00
Pipfile.lock switch from requirements.txt to pipenv/Pipfile 2020-04-08 20:25:16 +02:00
README.md license badge 2020-04-11 15:15:59 +02:00
setup.py setup.py: minor fix 2020-04-08 20:41:36 +02:00

Build Status PyPi release PyPI - Python Version PyPI - License

About

garminexport is both a library and a utility script for downloading/backing up Garmin Connect activities to a 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

It requires Python 3.5+.

Usage

Prerequisites

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

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.

Contribute

To work on the code base you need (besides the basic prerequisites outlined above) to have pipenv installed. Create a virtualenv (an isolated development environment) and install the required dependencies like so:

make venv
# or similarly: pipenv install