Package: garminexport
Aboutgarminexportis both a library and a tool for downloading/backing upGarmin Connectactivities to a local disk.The main utility script is calledgarmin-backupand performs incremental
backups of your Garmin account to a local directory. The first timegarmin-backupis run, it will downloadallactivities. 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.Installationgarminexportis available onPyPiand can be installed
withpip.Vanilla installationWARNINGGarminConnect employs Cloudflare's bot protection to prevent scripted access
to their services. Therefore a vanilla installation is no longer likely to
work. Instead, try theBrowser-impersonating installationbelow.To only installgarminexportand required dependencies run:pipinstallgarminexportBrowser-impersonating installationTo installgarminexportwith support to circumvent Cloudflare's bot protection
you should install the module with theimpersonate_browserextralike so:pipinstallgarminexport[impersonate_browser]This replaces the defaultrequestslibrary
withcurl_cffifor HTTP session
handling.Whencurl_cffiis used, theGARMINEXPORT_IMPERSONATE_BROWSERenvironment
variable can be used to control which browser is impersonated (default ischrome110, seefull list).UsagePrerequisitesTo be of any use you need to register an account atGarmin Connectand populate it with some
activities.As a command-line tool (garmin-backup)The backup program is run as follows (use the--helpflag for a full list of
available options):garmin-backup--backup-dir=activities<usernameoremail>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--formatoption to narrow the selection.Supported export formats:gpx: activity GPX file (XML).GPXis 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.tcxfile 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.fitfile may not always
be possible to export, for example if an activity was entered manually rather
than imported from a Garmin device.TheFITformat 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 itmaycontain 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 itmaycontain 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.garminexportalso 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 libraryTo build your own tools around the Garmin Connect API you can import thegarminclientmodule. It handles authentication to establish a secure session
with Garmin Connect. For example use, have a look at the command-line tools
undergarminexport/cli.For example, in yoursetup.py,setup.cfg,pyproject.toml(PEP 631) add something like:install_requires=['garminexport',# also installs 'impersonate_browser as a dependency# 'garminexport[impersonate_browser]',...]Note: if you happen to havecloudscraperon yourPACKAGEPATHGarminClientwill make use of it whenever it needs to make an HTTP request.ContributeTo 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