Modern Python 3 script to download GPX, TCX, FIT, or JSON files from your Garmin Connect account.
This script uses the modern garminconnect library to authenticate with Garmin Connect and download your activities in multiple formats.
Features:
- Modern OAuth authentication (works with current Garmin Connect API)
- Support for GPX, TCX, FIT, and JSON formats
- Automatic FIT file extraction from ZIP archives
- Date-prefixed filenames for easy organization (YYYY-MM-DD_activityid)
- Secure credential management via
.envfile - Configurable output directory
- Activity summary saved as JSON
File Formats:
- FIT (default): Binary format with full workout data (power, heart rate, cadence, etc.)
- TCX: XML format with detailed trackpoint data
- GPX: GPS track format (may be empty for indoor activities)
- JSON: Complete activity metadata and details
All files are saved with the activity date in the filename (e.g., 2025-11-30_12345678.fit) for easy sorting and identification.
pip3 install garminconnect- Create a
.envfile in the same directory as the script:
[email protected]
GARMIN_PASSWORD=your_password
# Optional: Set default output directory
GARMIN_OUTPUT_DIR=/path/to/your/export/directory- Make sure
.envis in your.gitignoreto keep credentials secure (a.env.examplefile is provided as a template)
python3 garmin_export.py [-h] [--username USERNAME] [--password PASSWORD]
[-c COUNT] [-f {gpx,tcx,fit,json}] [-d DIRECTORY]Options:
-h, --help- Show help message--username USERNAME- Garmin Connect username (or use.envfile)--password PASSWORD- Garmin Connect password (or use.envfile)-c COUNT, --count COUNT- Number of recent activities to download (default: 10)-f {gpx,tcx,fit,json}, --format {gpx,tcx,fit,json}- Export format (default: fit)-d DIRECTORY, --directory DIRECTORY- Output directory (default:GARMIN_OUTPUT_DIRfrom.envor./garmin_exports)
Download last 15 activities as FIT files (uses default directory):
python3 garmin_export.py -c 15Download last 5 activities as TCX to custom directory:
python3 garmin_export.py -c 5 -f tcx -d ~/MyActivitiesDownload last 10 activities as JSON with full details:
python3 garmin_export.py -c 10 -f jsonUse credentials from command line (not recommended):
python3 garmin_export.py -c 3 --username [email protected] --password mypasswordBest practice: Use a .env file for credentials to keep them secure and out of command history.
The script will:
- Authenticate with Garmin Connect
- Download the requested number of activities
- Save each activity with a date-prefixed filename (e.g.,
2025-11-30_12345678.fit) - For FIT format: Automatically extract files from ZIP archives and clean up temporary ZIP files
- Show progress and success count
File naming: Activities are saved as YYYY-MM-DD_activityid.ext making it easy to sort chronologically and identify specific workouts.
- Credentials: Store in
.envfile for security. Never commit credentials to version control. - Output Directory: Configure default output directory via
GARMIN_OUTPUT_DIRin.envfile to avoid hardcoding paths. - Indoor Activities: GPX files may be empty for indoor workouts (no GPS data). Use FIT or TCX for full workout metrics.
- FIT Files: Contain the most complete data including power, heart rate, cadence, and other sensor data.
The original gcexport.py script is still included but uses outdated authentication and may not work with current Garmin Connect. Use garmin_export.py instead.
Contributions are warmly welcome, particularly if this script stops working with Garmin Connect. You may consider opening a GitHub issue first. New features, however simple, are encouraged.
You are a runner, cyclist or triathlete? You love Golden Cheetah? You track your activities with Garmin devices? You want to download all of them from Garmin Connect? Okay, this got answered already within here.
But now, you want to archive, cloud-backup and import automatically into Golden Cheetah? There are tons of alternatives and workarounds. Here is mine.
Download, archive, cloud-backup and auto-import your activities.
Other than that, thx for using this script.
No Guarantee
This script does NOT guarantee to get all your data or even download it correctly. Against my Garmin Connect account it works quite fine and smooth, but different Garmin Connect account settings or different data types could potentially cause problems.
Garmin Connect API
This is NOT an official feature of Garmin Connect, Garmin may very well make changes to their APIs that breaks this script (and they certainly did since this project got created for several times).
THIS SCRIPT IS FOR PERSONAL USE ONLY
It simulates a standard user session (i.e., in the browser), logging in using cookies and an authorization ticket. This makes the script pretty brittle. If you're looking for a more reliable option, particularly if you wish to use this for some production service, Garmin does offer a paid API service.
Security Dislaimer
Using the --username and --password flags are not recommended because your password will be stored in your command line history. Instead, omit them to be prompted (and note that nothing will be displayed when you type your password).
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project follows a Code of Conduct. By participating, you are expected to uphold this code.
MIT © 2015 Kyle Krafka, 2025 AJ Enns