kjkjava / garmin-connect-export Goto Github PK
View Code? Open in Web Editor NEWDownload a copy of your Garmin Connect data, including stats and GPX tracks.
License: MIT License
Download a copy of your Garmin Connect data, including stats and GPX tracks.
License: MIT License
Hi there,
when trying to download Garmin data using the script I got an "unexpected HTTP error (410)".
The download url seemed to be changed. I simply changed it (here just for gpx) and it worked fine:
#url_gc_gpx_activity = 'http://connect.garmin.com/proxy/activity-service-1.1/gpx/activity/'
url_gc_gpx_activity = 'https://connect.garmin.com/modern/proxy/download-service/export/gpx/activity/'
Best regards,
Till
Hello, I am using this code for a while now and it's been working great, thanks a lot !
But from today I get this error message when running it : "HTTP error 402: payment required"
It is happening when trying to access the activity list at url :
https://connect.garmin.com/modern/proxy/activitylist-service/activities/search/activities?start=0&limit=1
Can you help ?
Thank you,
Magali
Garmin has re done there authentication to use a SSO instead. This breaks the script.
I've used parts of your code in my own project https://github.com/wederbrand/workout-exchange so that is also broken.
We should collaborate on a solution if we both try to fix it.
Hi,
i have a lot of activities that contain the character "ö".
When running gcexport.py in a cron job i get the followin error:
Garmin Connect activity: [1127628337] Traceback (most recent call last):
File "./gcexport.py", line 174, in
print a['activity']['activityName']['value']
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 1: ordinal not in range(128)
Is there anything i can do?
Regards,
Jörg
Can only get through a couple workout files without seeing the following error. Restarting script will get me past the one file, but it crashed again a couple files later
(using https://github.com/moderation/garmin-connect-export/blob/master/gcexport.py)
Garmin Connect activity: [1953986132] Schenectady Running
Thu, Aug 31, 2017 7:57 AM, 00:17:43, 1.95 Miles
verboseprint
https://connect.garmin.com/modern/proxy/download-service/export/gpx/activity/1953986132?full=true
Downloading file... http exception
404
Traceback (most recent call last):
File "gcexport.py", line 394, in
raise Exception('Failed. Got an unexpected HTTP error (' + str(e.code) + ').')
Exception: Failed. Got an unexpected HTTP error (404).
Hey,
first of all thanks for the nice tool! I've been using it for some months now. Unfortunately, since yesterday(?) I get the following error regardless of the parameters I use. The password and username are correct. I verified it via Garmin Connect web interface:
Welcome to Garmin Connect Exporter!
Warning: Output directory already exists. Will skip already-downloaded files and append to the CSV file.
Traceback (most recent call last):
File "gcexport.py", line 155, in
result = http_req(url_gc_search + urlencode(search_params))
File "gcexport.py", line 70, in http_req
response = opener.open(request, data=post) # This line may throw a urllib2.HTTPError.
File "/usr/lib/python2.7/urllib2.py", line 410, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 442, in error
result = self._call_chain(_args)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(_args)
File "/usr/lib/python2.7/urllib2.py", line 629, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python2.7/urllib2.py", line 410, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 448, in error
return self._call_chain(_args)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(_args)
File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
Any changes on Garmin side? Can you reproduce the problem or do I have canged something here that I am not aware of atm?
I'm wondering if Garmin has updated their privacy settings. I used your code back in February 2021 with no errors but when I tried running today, I get the following error:
Traceback (most recent call last):
File "gcexport.py", line 114, in
raise Exception('Did not get a ticket cookie. Cannot log in. Did you enter the correct username and password?')
Exception: Did not get a ticket cookie. Cannot log in. Did you enter the correct username and password?
Any thoughts on this? Thanks!
Would it be possible for this script to correct the timestamp on the saved files to match the original dataset's timestamp? (ie. event start time)
hello, it's not an issue per say
But after I failed for hours to implements login to garmin connect through python requests for a little upload .fit files cli I'm currently writing (https://github.com/euri10/gols), I found your code.
And I still can't explain why that url_gc_post_auth = 'https://connect.garmin.com/post-auth/login?' works wonderfully.
Now it bugs me, because when browsing with chrome dev tools, or looking at the way it connects in Burp, or even trying to debug the redirects in requests, I never ever saw that url...never ever!!
So it works, it's cool, but out of curiosity, how did you manage to find it ? is it from the old site ?
well sorry for the non-issue here, but that bugs me, I'd like to understand
Works using the -f original flag but GPX or TCX files throw error:
Welcome to Garmin Connect Exporter!
Garmin Connect activity: [2495363004] Treadmill Running
Tue, Feb 13, 2018 4:59 AM, 00:30:02, 3.40 Miles
Downloading file...
Traceback (most recent call last):
File "gcexport.py", line 231, in <module>
raise Exception('Failed. Got an unexpected HTTP error (' + str(e.code) + ').')
Exception: Failed. Got an unexpected HTTP error (410).
Posting in case helpful. For a recent activity of mine, which I added to Connect manually, no GPX is available (see screenshot). Therefore with command-line defaults,
Traceback (most recent call last):
File "./gcexport.py", line 231, in <module>
raise Exception('Failed. Got an unexpected HTTP error (' + str(e.code) + ').')
Exception: Failed. Got an unexpected HTTP error (410).
When adding --format 'original'
, however, the export is successful.
Screenshot:
Thank you for making this. As Garmin Connect has been updated, can you update the HTTP path's to extract data?
I've used this occasionally, but it seems to be broken now. Here's the traceback:
Traceback (most recent call last):
File "./gcexport1.py", line 120, in
http_req(url_gc_post_auth + 'ticket=' + login_ticket)
File "./gcexport1.py", line 71, in http_req
response = opener.open(request, data=post) # This line may throw a urllib2.HTTPError.
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 435, in open
response = meth(req, response)
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 473, in error
return self._call_chain(*args)
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found
The URL containing all activities (statistics) returns 0 results.
File "/usr/src/app/garmin_connect_export/gcexport.py", line 1218, in main
total_to_download = int(userstats_json['userMetrics'][0]['totalActivities'])
KeyError: 'userMetrics'
login to garmin successds though. Does anyone experience the same issue
I see that the script only pulls GPX data up to the 100th most recent activity. I also understand that Garmin only allows up to 100 downloads at one time. How do I edit the script, or can you post an edited script that allows me to enter a range of indices (e.g. 300 - 400 [for the 300th to 400th most recent activities]) so that I can download all of my activities. Thanks
I get an an error when extracting the downloaded zip file of a manually created event, where I (for example) forgot to add the event type. The downloaded zip file is then empty and unzipping it will not work. A simple workaround that does the trick for me (i.e. it ignores these cases) would be to add
if os.stat(data_filename).st_size > 0:
in line 300, before unzipping the file. Of course, it then completely ignores the file, but it will continue the bulk export.
Garmin makes sleep data (part of the "daily summary") available for export as a zipped fit file.
Would it be possible to make this script also backup that data?
The url garmin connect fetches from is
https://connect.garmin.com/modern/proxy/download-service/files/wellness/2016-08-28
I guess I could make a second copy of the script, edit the variable url_gc_original_activity
and change /activity/
to /wellness/
and it might work
When I try to download my Garmin Workouts, the last activity ist listed, then the Download of the file is tried and the I receive the following exception:
Traceback (most recent call last):
File "./gcexport.py", line 231, in <module>
raise Exception('Failed. Got an unexpected HTTP error (' + str(e.code) + ').')
Exception: Failed. Got an unexpected HTTP error (410).
New to Python I installed python 3.7.0, thought it should be easy to get output by the gcexport.py-script.
Unfortunately Python demands a lot of parantheses that seem to be missing after the print-commands of gcexport.py.
After introducing "( )" I got the next error (just trying the "-h"):
"ImportError: cannot import name 'urlencode' from 'urllib' (C:\Users\Gerald\AppData\Local\Programs\Python\Python37\lib\urllib_init_.py)"
This init-file is empty.
Is there something else necessary that the py-script runs?
Best regards
beta-L-user
Hi, I'm a little new to your program and I received this error message when trying to import .fit files from my Garmin account.
I'm not sure how to fix it unfortunately. Any help would be greatly appreciated. Thanks a lot!
Matt
Traceback (most recent call last):
File "./gcexport.py", line 155, in
result = http_req(url_gc_search + urlencode(search_params))
File "./gcexport.py", line 70, in http_req
response = opener.open(request, data=post) # This line may throw a urllib2.HTTPError.
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 469, in error
result = self._call_chain(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 656, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
return self._call_chain(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
Garmin Connect activity: [1892029351] Other
Wed, 2 Aug 2017 18:12, 00:33:18, 0.00 Miles
https://connect.garmin.com/modern/proxy/download-service/export/gpx/activity/1892029351?full=true
Downloading file...
Traceback (most recent call last):
File "gcexport.py", line 357, in
data = http_req(download_url)
File "gcexport.py", line 86, in http_req
raise Exception('Bad return code (' + str(response.getcode()) + ') for: ' + url)
Exception: Bad return code (204) for: https://connect.garmin.com/modern/proxy/download-service/export/gpx/activity/1892029351?full=true
Ever since February 23, I'm getting a message from the Garmin api while using this that a payment is required and it doesn't complete.
Requesting Login ticket... Done. Ticket=ST-0234665-GucJ5WoJWl7eA30ye9Fr-cas
Authenticating... Done.
[ERROR] Failed to reach url https://connect.garmin.com/modern/proxy/activitylist-service/activities/search/activities?start=0&limit=20, error: HTTP Error 402: Payment Required
Querying list of activities 1..20...Traceback (most recent call last):
File "C:\admintools\garmin-connect-export-3.0.2\gcexport.py", line 1061, in
main(sys.argv)
File "C:\admintools\garmin-connect-export-3.0.2\gcexport.py", line 941, in main
result = http_req_as_string(URL_GC_LIST + urlencode(search_params))
File "C:\admintools\garmin-connect-export-3.0.2\gcexport.py", line 271, in http_req_as_string
return http_req(url, post, headers).decode()
File "C:\admintools\garmin-connect-export-3.0.2\gcexport.py", line 247, in http_req
response = OPENER.open(request, data=post)
File "C:\Users\mediaserver\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
response = meth(req, response)
File "C:\Users\mediaserver\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
response = self.parent.error(
File "C:\Users\mediaserver\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 561, in error
return self._call_chain(*args)
File "C:\Users\mediaserver\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(*args)
File "C:\Users\mediaserver\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 402: Payment Required
Last commit here is from 2015 ...
https://github.com/kjkjava/garmin-connect-export/network lists some active repositories... Seems that https://github.com/pe-st/garmin-connect-export/tree/develop is the acive ones.
@kjkjava What's about to archive this repro and add links to @pe-st repository ?!?
Max. Elevation values are being written to the Min. Elevation columns in the CSV. The two lines at https://github.com/kjkjava/garmin-connect-export/blob/master/gcexport.py#L277-L278 need to replace maxElevation with minElevation. I've made this change on my local copy and successfully tested.
Would you like to make the change or shall I fork, modify and create a pull request (assuming of course that this is a bug).
The script fails for me with the following error message:
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
I'm using Debian Squeeze with an up-to-date ca-certificates package and have no trouble accessing connect.garmin.com via my browser with working SSL.
Any thoughts? I'm thinking I'd need to add the certificate for the Garmin API... Thanks for creating and sharing the script - it's a neat idea!
Hi,
I tried downloading a tcx file using this script.
When doing so, I get a very different TCX file than the one I get when downloading the tcx file manually (from the activity itself).
Has anyone tried this and knows how to get the same file as the one you download in the activity?
Thanks.
When downloading activities, the script crashes on activities with "ø" in the name.
Error message:
File`"gcexport.py", line 186, in
print a['activity']['activityName']['value']
File "C:\Anaconda2\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\xf8' in position 1: character maps
to <undefined>
Tracked it to the
json_results = json.loads(result)
on line 169 (or in that area if I have changed the script slightly). Basically writing or printing the result
variable shows the ø properly in files or on screen, but the "json_results"-dict shows a unicode stringfor the acitivityName as this
{u'value': u'H\xf8vik Cycling'}
Tested with
print a['activity']['activityName']['value'].encode('utf-8')
(also other encodings without luck) but it produces a weird character.
Anyone know how to fix it?
When downloading Workouts, the program reports an Exception:
Downloading file...
Traceback (most recent call last):
File "garmin-connect-export_moderation/gcexport.py", line 357, in <module>
data = http_req(download_url)
File "garmin-connect-export_moderation/gcexport.py", line 86, in http_req
raise Exception('Bad return code (' + response.getcode() + ') for: ' + url)
TypeError: cannot concatenate 'str' and 'int' objects
Hi,
I'm using latest version of script.
I get
raise Exception('Failed. Got an unexpected HTTP error (' + str(e.code) + ').') Exception: Failed. Got an unexpected HTTP error (503).
when trying to run script. Last week everything was working.
I tried putting url (url_gc_gpx_activity + a['activity']['activityId'] + '?full=true) and I get
The requested endpoint is retired
URL for downloading through browser is https://connect.garmin.com/modern/proxy/download-service/export/gpx/activity/12691xxxxxx
The app stop in authorization request.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.