Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - export body metrics #17

Open
Mark10 opened this issue Dec 5, 2018 · 5 comments
Open

Feature request - export body metrics #17

Mark10 opened this issue Dec 5, 2018 · 5 comments

Comments

@Mark10
Copy link

Mark10 commented Dec 5, 2018

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
Copy link
Owner

pe-st commented Dec 16, 2018

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
Copy link
Author

Mark10 commented Dec 19, 2018

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
Copy link

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
Copy link

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

@tp2750
Copy link

tp2750 commented Aug 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants