Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a147b09
Fix elevation, get additional data like cadence, heart rate, elevatio…
moderation Feb 21, 2016
1493604
Huge refactor after Garmin deprecated old APIs and modified login and…
moderation Aug 31, 2016
ceec54b
Fixed keyError when parsing totalFound results
cmccarty Sep 7, 2016
20d4171
Merge pull request #1 from cmccarty/master
moderation Sep 8, 2016
9d2a62b
GPX broken again.
moderation Oct 19, 2016
c21bbb7
Persist activity JSON.
moderation Nov 30, 2016
f1d3a34
Re-enable export to GPX.
moderation Nov 30, 2016
64c0ff1
Should fix int and str concatenation issue reported at https://github…
moderation Jan 23, 2017
23e2aaa
Clean up old endpoints and improve HTTP error reporting.
moderation Sep 22, 2017
5112258
Check zip file size & skip unzipping 0Kb files.
moderation Sep 22, 2017
33bb855
Use `limit_maximum` instead of magic number
pe-st Mar 6, 2018
5ede66c
Merge pull request #6 from pe-st/feature/limit_maximum
moderation Mar 6, 2018
10afedd
Write empty GPX file when there's no GPS data
pe-st Mar 11, 2018
71dc1dd
Merge pull request #8 from pe-st/feature/gpx-http-204
moderation Mar 21, 2018
dcaffb9
Large refactor based on Garmin Connect API changes and the excellent …
moderation Apr 17, 2018
8fdc827
Merge branch 'master' of github.com:moderation/garmin-connect-export
moderation Apr 17, 2018
bb1bf2d
Bump version on account of Python 3 refactor and small cosmetic changes.
moderation Apr 17, 2018
c3bdff5
Formatting, pylint changes and resolve https://github.com/moderation/…
moderation Apr 20, 2018
9a7c78e
Implement @pe-st method for getting session ticket replacing loop on …
moderation Apr 21, 2018
5be078a
Remove urllib2 warnings as it is not used. Fix debug print statements…
moderation Apr 21, 2018
74f0e34
Fix regression in move to Python 3. Re-implement https://github.com/m…
moderation May 7, 2018
d8e6637
Linting by black. Upgrade to Libre Office 6.1.
moderation Aug 15, 2018
a0ac786
Largish refactor based on deprecation of search URL endpoint (was ret…
moderation Aug 26, 2018
d4a625b
Fix description.
moderation Aug 26, 2018
0dc5042
Handle description being null. Use @pe-st's method for extracting tot…
moderation Aug 27, 2018
925f834
Test and make work downloading all activities.
moderation Aug 27, 2018
ff23760
Update gitignore.
moderation Aug 28, 2018
8a04e53
Adds support for display names containing dots
Aug 29, 2018
b425eb1
Decide whether a response from Garmin Connect
Aug 29, 2018
85f637b
Merge pull request #20 from chmoelders/hotfix/#14-unicode-decode-error
moderation Aug 31, 2018
fd2f353
Merge pull request #19 from chmoelders/hotfix/support-display-names-w…
moderation Aug 31, 2018
5a75cec
Linting by black.
moderation Aug 31, 2018
18cd3b1
Do nothing in decoding_decider for empty GPX data
pe-st Sep 5, 2018
0fb431e
Merge pull request #22 from pe-st/feature/decode-empty-gpx
moderation Sep 5, 2018
63f62dc
Add more error handling
pe-st Sep 5, 2018
9584e9d
Make launching of external application for CSV and opt-in option and …
moderation Sep 9, 2018
8e84874
Merge pull request #23 from pe-st/error-handling
moderation Sep 25, 2018
fb94682
Replace deprecated activity detail endpoint with new API and update J…
moderation Nov 19, 2018
fadae4e
Add new URL to retrieve gear detail and create column for Bike name.
moderation Jan 4, 2019
c381d39
Fix latest login change.
moderation Apr 20, 2019
2ae255d
Latest Black formatting changes.
moderation May 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

.DS_Store
extras/
*_garmin_connect_export/
*.pyc
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Usage
You will need a little experience running things from the command line to use this script. That said, here are the usage details from the `--help` flag:

```
usage: gcexport.py [-h] [--version] [--username [USERNAME]]
usage: gcexport3.py [-h] [--version] [--username [USERNAME]]
[--password [PASSWORD]] [-c [COUNT]]
[-f [{gpx,tcx,original}]] [-d [DIRECTORY]] [-u]

Expand All @@ -43,11 +43,11 @@ optional arguments:
```

Examples:
`python gcexport.py --count all` will download all of your data to a dated directory.
`python gcexport3.py --count all` will download all of your data to a dated directory.

`python gcexport.py -d ~/MyActivities -c 3 -f original -u --username bobbyjoe --password bestpasswordever1` will download your three most recent activities in the FIT file format (or whatever they were uploaded as) into the `~/MyActivities` directory (unless they already exist). 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).
`python gcexport3.py -d ~/MyActivities -c 3 -f original -u --username bobbyjoe --password bestpasswordever1` will download your three most recent activities in the FIT file format (or whatever they were uploaded as) into the `~/MyActivities` directory (unless they already exist). 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).

Alternatively, you may run it with `./gcexport.py` if you set the file as executable (i.e., `chmod u+x gcexport.py`).
Alternatively, you may run it with `./gcexport3.py` if you set the file as executable (i.e., `chmod u+x gcexport3.py`).

Of course, you must have Python installed to run this. Most Mac and Linux users should already have it. Also, as stated above, you should have some basic command line experience.

Expand All @@ -63,9 +63,25 @@ Garmin Connect API
------------------
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.

### REST endpoints

As this script doesn't use the paid API, the endpoints to use are known by reverse engineering browser sessions. And as the Garmin Connect website changes over time, chances are that this script gets broken.

Small history of the endpoint used by `gcexport3.py` to get a list of activities:

- [activity-search-service-1.0](https://connect.garmin.com/proxy/activity-search-service-1.0/json/activities): initial endpoint used since 2015, worked at least until January 2018
- [activity-search-service-1.2](https://connect.garmin.com/proxy/activity-search-service-1.2/json/activities): endpoint introduced in `gcexport.py` in August 2016. In March 2018 this still works, but doesn't allow you to fetch more than 20 activities, even split over multiple calls (when doing three consecutive calls with 1,19,19 as `limit` parameter, the third one fails with HTTP error 500). The JSON returned by this endpoint however is quite rich (see example in the `json` folder).
- [activitylist-service](https://connect.garmin.com/modern/proxy/activitylist-service/activities/search/activities): endpoint introduced in `gcexport.py` in March 2018. The JSON returned by this endpoint is very different from the activity-search-service-1.2 one (also here see the example in the `json` folder), e.g.
- it is concise and offers no redundant information (e.g. only speed, not speed and pace)
- the units are not explicitly given and must be deducted (e.g. the speed unit is m/s)
- there is less information, e.g. there is only one set of elevation values (not both corrected and uncorrected), and other values like minimum heart rate are missing.
- some other information is available only as an ID (e.g. `timeZoneId` or `deviceId`), and complete information might be available by another REST call (I didn't reverse further for the time being)

History
-------
The original project was written in PHP (now in the `old` directory), based on "Garmin Connect export to Dailymile" code at http://www.ciscomonkey.net/gc-to-dm-export/ (link has been down for a while). It no longer works due to the way Garmin handles logins. It could be updated, but I decided to rewrite everything in Python for the latest version.
The original project was written in PHP (formerly in the `old` directory, now deleted), based on "Garmin Connect export to Dailymile" code at http://www.ciscomonkey.net/gc-to-dm-export/ (link has been down for a while). It no longer works due to the way Garmin handles logins. It could be updated, but I decided to rewrite everything in Python for the latest version.

@moderation forked the original from @kjkjava when the various endpoints stopped working and the original repo wasn't been updated. This fork is primarily designed for my use which is cycling. It has not well been tested against other activity types. In the latest updates (April 2018) I've deprecated the Python 2 version (renamed to gcexport2.py) and this script now requires Python 3. The code has been linted using [pylint3](https://packages.debian.org/sid/pylint3).

Contributions
-------------
Expand Down
Loading