2015-02-21 18:10:43 +01:00
|
|
|
Garmin Connect activity backup tool
|
|
|
|
===================================
|
2018-09-01 08:50:54 +02:00
|
|
|
``garminbackup.py`` is a program that downloads activities for a
|
|
|
|
given [Garmin Connect](http://connect.garmin.com/) account and stores
|
|
|
|
them in a backup directory locally on the user's computer. The first time
|
2015-02-21 18:10:43 +01:00
|
|
|
the program 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.
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2018-09-01 08:50:54 +02:00
|
|
|
The library contains a simple utility program, ``get_activity.py`` for
|
2015-02-21 18:10:43 +01:00
|
|
|
downloading a single Garmin Connect activity. Run ``./get_activity.py --help``
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
The library also contains a ``garminclient`` module that could be used by third-party
|
2018-09-01 08:50:54 +02:00
|
|
|
projects that need to communicate over the Garmin Connect API. See the
|
2015-02-21 18:10:43 +01:00
|
|
|
Library Import section below for more details.
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2014-11-08 13:11:01 +01:00
|
|
|
|
2014-11-08 13:35:47 +01:00
|
|
|
Prerequisites
|
|
|
|
=============
|
|
|
|
The instructions below for running the program (or importing the module)
|
2018-09-01 08:50:54 +02:00
|
|
|
assumes that you have Python 2.7 or Python 3+,
|
|
|
|
[pip](http://pip.readthedocs.org/en/latest/installing.html), and
|
|
|
|
[virtualenv](http://virtualenv.readthedocs.org/en/latest/virtualenv.html#installation)
|
|
|
|
(not required with Python 3) installed.
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2018-09-01 08:50:54 +02:00
|
|
|
It also assumes that you have registered an account at
|
2014-11-08 13:41:13 +01:00
|
|
|
[Garmin Connect](http://connect.garmin.com/).
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2014-11-08 13:35:47 +01:00
|
|
|
Getting started
|
|
|
|
===============
|
|
|
|
Create and activate a new virtual environment to create an isolated development
|
|
|
|
environment (that contains the required dependencies and nothing else).
|
|
|
|
|
2018-09-01 08:50:54 +02:00
|
|
|
# using Python 2
|
2014-11-08 13:41:13 +01:00
|
|
|
virtualenv venv.garminexport
|
2018-09-01 08:50:54 +02:00
|
|
|
|
2019-02-05 14:30:06 +01:00
|
|
|
# using Python 3
|
|
|
|
python -m venv venv.garminexport
|
2018-09-01 08:50:54 +02:00
|
|
|
|
|
|
|
Activate the virtual environment
|
|
|
|
|
2014-11-08 13:41:13 +01:00
|
|
|
. venv.garminexport/bin/activate
|
2014-11-08 13:35:47 +01:00
|
|
|
|
|
|
|
Install the required dependencies in this virtual environment:
|
|
|
|
|
2014-11-08 13:41:13 +01:00
|
|
|
pip install -r requirements.txt
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2014-11-11 13:45:11 +01:00
|
|
|
|
2014-11-08 13:35:47 +01:00
|
|
|
|
2015-02-21 18:10:43 +01:00
|
|
|
Running
|
|
|
|
=======
|
2018-09-01 08:50:54 +02:00
|
|
|
The backup program is run as follows (use the ``--help`` flag for a full list
|
2015-02-21 18:10:43 +01:00
|
|
|
of available options):
|
|
|
|
|
|
|
|
./garminbackup.py --backup-dir=activities <username or email>
|
2014-11-08 13:35:47 +01:00
|
|
|
|
|
|
|
Once started, the program will prompt you for your account password and then
|
2015-02-21 18:10:43 +01:00
|
|
|
log in to your Garmin Connect account to download activities to the specified
|
2018-09-01 08:50:54 +02:00
|
|
|
backup directory on your machine. The program will only download activities
|
2015-02-21 18:10:43 +01:00
|
|
|
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.
|
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
|
|
|
|
2019-10-12 08:24:13 +02:00
|
|
|
- ``gpx``: activity GPX file (XML).
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2019-10-12 08:24:13 +02:00
|
|
|
[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.
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2015-03-04 21:00:44 +01:00
|
|
|
- ``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.*
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2019-10-12 08:24:13 +02:00
|
|
|
[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).
|
|
|
|
|
2015-02-21 18:10:43 +01:00
|
|
|
- ``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.*
|
2014-11-09 13:32:20 +01:00
|
|
|
|
2019-10-12 08:24:13 +02:00
|
|
|
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.
|
|
|
|
|
|
|
|
- ``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.
|
|
|
|
|
2014-11-11 12:42:05 +01:00
|
|
|
All files are written to the same directory (``activities/`` by default).
|
2015-02-21 18:10:43 +01:00
|
|
|
Each activity file is prefixed by its upload timestamp and its activity id.
|
2014-11-11 13:45:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-11-08 13:35:47 +01:00
|
|
|
Library import
|
|
|
|
==============
|
2018-09-01 08:50:54 +02:00
|
|
|
To install the development version of this library in your local Python
|
2014-11-08 13:35:47 +01:00
|
|
|
environment, run:
|
|
|
|
|
|
|
|
`pip install -e git://github.com/petergardfjall/garminexport.git#egg=garminexport`
|
|
|
|
|
2015-03-06 10:46:59 +01:00
|
|
|
If you prefer to use a `requirements.txt` file, add the following line
|
2014-11-08 13:35:47 +01:00
|
|
|
to your list of dependencies:
|
|
|
|
|
2015-03-06 10:46:59 +01:00
|
|
|
`-e git://github.com/petergardfjall/garminexport.git#egg=garminexport`
|
2014-11-08 13:35:47 +01:00
|
|
|
|
|
|
|
and run pip with you dependency file as input:
|
|
|
|
|
|
|
|
`pip install -r requirements.txt`
|