2020-04-07 14:24:55 +02:00
|
|
|
[![Build Status](https://travis-ci.org/petergardfjall/garminexport.svg?branch=master)](https://travis-ci.org/petergardfjall/garminexport)
|
2020-04-11 15:13:23 +02:00
|
|
|
[![PyPi release](https://img.shields.io/pypi/v/garminexport.svg)](https://img.shields.io/pypi/v/garminexport.svg)
|
2020-04-11 15:14:41 +02:00
|
|
|
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/garminexport)
|
2020-04-11 15:15:59 +02:00
|
|
|
![PyPI - License](https://img.shields.io/pypi/l/garminexport)
|
2020-04-07 14:24:55 +02:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
# About
|
|
|
|
`garminexport` is both a library and a utility script for downloading/backing up
|
|
|
|
[Garmin Connect](http://connect.garmin.com/) 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
|
2015-02-21 18:10:43 +01:00
|
|
|
do incremental backups of your account. That is, the script will only download
|
|
|
|
activities that haven't already been downloaded to the backup directory.
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
# Installation
|
|
|
|
`garminexport` is available on [PyPi](https://pypi.org/) and can be installed
|
|
|
|
with [pip](http://pip.readthedocs.org):
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
pip install garminexport
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
It requires Python 3.5+.
|
2018-09-01 08:50:54 +02:00
|
|
|
|
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
# Usage
|
2018-09-01 08:50:54 +02:00
|
|
|
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
## 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.
|
2014-11-08 13:35:47 +01:00
|
|
|
|
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
## As a command-line tool (garmin-backup)
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
The backup program is run as follows (use the `--help` flag for a full list of
|
|
|
|
available options):
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
garmin-backup --backup-dir=activities <username or email>
|
2015-02-21 18:10:43 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
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.
|
2015-02-21 18:10:43 +01:00
|
|
|
|
|
|
|
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
|
2020-04-07 20:41:45 +02:00
|
|
|
`--format` option to narrow the selection.
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2015-02-21 18:10:43 +01:00
|
|
|
Supported export formats:
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2018-09-01 08:50:54 +02:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
- `gpx`: activity GPX file (XML).
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2019-10-12 08:27:24 +02:00
|
|
|
<sub>[GPX](https://en.wikipedia.org/wiki/GPS_Exchange_Format) is an open
|
2019-10-12 08:24:13 +02:00
|
|
|
format, mainly for storing GPS routes/tracks. It does support extensions
|
|
|
|
and Garmin appears to annotate the GPS data with, for example, heart-rate
|
2019-10-12 08:27:24 +02:00
|
|
|
and cadence, when available on your device.</sub>
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
- `tcx`: an activity TCX file (XML).
|
|
|
|
*Note: a `.tcx` file may not always be possible to export, for example
|
2015-03-04 21:00:44 +01:00
|
|
|
if an activity was uploaded in gpx format. In that case, Garmin won't try
|
|
|
|
to synthesize a tcx file.*
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2019-10-12 08:27:24 +02:00
|
|
|
<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>
|
2019-10-12 08:24:13 +02:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
- `fit`: activity FIT file (binary format).
|
|
|
|
*Note: a `.fit` file may not always be possible to export, for example
|
2015-02-21 18:10:43 +01:00
|
|
|
if an activity was entered manually rather than imported from a Garmin device.*
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2019-10-12 08:27:24 +02:00
|
|
|
<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>
|
2019-10-12 08:24:13 +02:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
- `json_summary`: activity summary file (JSON).
|
2019-10-12 08:24:13 +02:00
|
|
|
|
2019-10-12 08:27:24 +02:00
|
|
|
<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
|
2019-10-12 08:24:13 +02:00
|
|
|
time). Only included since it *may* contain additional data that could be
|
2019-10-12 08:27:24 +02:00
|
|
|
useful for developers of analysis tools.</sub>
|
2019-10-12 08:24:13 +02:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
- `json_details`: activity details file (JSON).
|
2019-10-12 08:24:13 +02:00
|
|
|
|
2019-10-12 08:27:24 +02:00
|
|
|
<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>
|
2019-10-12 08:24:13 +02:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
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.
|
2014-11-11 13:45:11 +01:00
|
|
|
|
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
## As a library
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
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).
|
2014-11-08 13:35:47 +01:00
|
|
|
|
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
# Contribute
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
To work on the code base you need (besides the basic prerequisites outlined
|
|
|
|
above) to have [pipenv](https://github.com/pypa/pipenv) installed. Create a
|
|
|
|
`virtualenv` (an isolated development environment) and install the required
|
|
|
|
dependencies like so:
|
2014-11-08 13:35:47 +01:00
|
|
|
|
|
|
|
|
2020-04-07 20:41:45 +02:00
|
|
|
make venv
|
|
|
|
# or similarly: pipenv install
|