pe-st / garmin-connect-export

Download a copy of your Garmin Connect data, including stats and GPX tracks.
MIT License
364 stars 75 forks source link

Feature request - export body metrics #17

Open Mark10 opened 5 years ago

Mark10 commented 5 years ago

Hi, thanks for the export tool, works perfectly. Would it be possible to add the export of body metrics to the script? Today the export is done manually: https://connect.garmin.com/modern/proxy/userprofile-service/userprofile/personal-information/weightWithOutbound/ with optional filter "filterByDay?from=1483228800&until=1527807599999" than paste it in https://json-csv.com/ to make it readable/editable in Excel. Source: https://www.alunr.com/exporting-weight-data-from-garmin-connect/

Target should be a csv file with the following format, wich can be used with GoldenCheetah for example: https://github.com/GoldenCheetah/GoldenCheetah/blob/master/test/bodymeasures/bodymeasures-format-example-ts.csv

Thanks Mark

pe-st commented 5 years ago

Hello @Mark10

At the heart of the current script are the activities; an export of data linked to an activity can quite easily be added. As far as I can see, the body metrics are not linked to activities, but rather to dates, so it doesn't quite fit with the current script.

A rather ugly workaround would be to query the body metrics for the date of each activity and add the desired values as possible columns to the CSV, then you could write a CSV template for the GoldenCheetah format. The disadvantages would be that there would be no body metrics for days where you didn't register an activity and for days with multiple activities there would be multiple body metrics. And a day with an activity but no body metrics would still be exported, just with empty body metrics...

HTH Peter

Mark10 commented 5 years ago

Hi Peter,

thanks for your feedback. What about a second query if e.g. option "-metrics 27" is set, wich will download the metrics for the last 27 days?

Im not a programmer, but with some copy and paste a managed to export the metrics json file "metrics.json".

Next step would be to convert it to csv. Maybe with a separate python script.

Here are the 9 lines I've added: Added to line 127 URL_GC_METRICS = 'https://connect.garmin.com/modern/proxy/userprofile-service/userprofile/personal-information/weightWithOutbound/'

Added to line 541 def extract_metrics(args, http_caller, file_writer): """ Download json metrics """ metrics_json = http_caller(URL_GC_METRICS) file_writer(args.directory + '/metrics.json', metrics_json, 'w') return None

Added to line 879 extract['metrics'] = extract_metrics(args, http_req, write_to_file)

Mark

datachico commented 4 years ago

To piggyback on this comment thread - how difficult would it be to access sleep and step data using this script? Works great for activities, very useful!!!

gnorman7 commented 1 year ago

Just want to bring this up again and see if any progress has been made on it.

tp2750 commented 1 year ago

There is https://github.com/cyberjunky/python-garminconnect which enables download of health data.