k0rventen / apple-health-grafana

Visualise your Apple Health export in Grafana
390 stars 28 forks source link

[Feature Request] - Integration with Auto Extractors #25

Open latetedemelon opened 8 months ago

latetedemelon commented 8 months ago

Idea here is to automate the data updates. There are two possible workflows:

1)

https://apps.apple.com/us/app/health-export-csv/id1477944755 https://apps.apple.com/us/app/simple-health-export-csv/id1535380115 https://apps.apple.com/us/app/health-auto-export-json-csv/id1115567069

2) https://apps.apple.com/us/app/health-auto-export-json-csv/id1115567069

More than happy to use my limited my skills to help but I'm not an expert and wanted to see if you were even interested.

latetedemelon commented 8 months ago

Actually it would appear someone has done some of this work here:

https://www.ivaylopavlov.com/charting-apple-healthkit-data-in-grafana/ https://github.com/irvinlim/apple-health-ingester

latetedemelon commented 8 months ago

Apparent here is a way to create an API via Firebase:

https://github.com/emreloper/apple-health-api

k0rventen commented 8 months ago

Hey ! Thx for the suggestion, that's a great idea !

You're right, it should be easier to transfer the health data, rather than manually exporting from the Health App, sending to the computer etc..

I guess having an API endpoint available on our side that the iPhone can hit isn't that difficult to setup. It would be mostly a matter of checking the format sent by the app.

I'll try with the app you mentionned ! When I have a PoC ready I'll bump the issue :)

Regards,

goldjunge91 commented 6 months ago

Hi,

I've been exploring ways to store and utilize iOS Health & ScreenTime data and found this repository incredibly helpful—thank you for your efforts!

While I'm more of a 'copy and paste' coder 😄, I'm keen to contribute some ideas for automated data extraction:

1. Healthflux (MacOS only)

Created by Felix Kohlhas, this project automates the extraction of Health data on MacOS from an Database file.

2. ScreenFlux (MacOS only)

Felix also developed ScreenFlux, which includes a tool, ScreenTime to CSV, for exporting screen time data.

3. Universal Compatibility:

To ensure compatibility across all Apple iOS & MacOS / versions, we could leverage or enhance @mm's Heartbridge shortcut. Consider these examples:

Importantly, in my oppinion is this approach respects user privacy, ensuring that health data is not shared with third-party APIs.

@k0rventen, if you haven't started implementing these function, I'd love to give it a try. I recently developed a web app using Next.js/React, PostgreSQL, and some Python for web scraping. Although my code might not be the cleanest, I'm eager to help and contribute to this project.

Best Regards.

k0rventen commented 6 months ago

Hey @goldjunge91 ! Thx for your interest ! Of course, you're more than welcome to help !

On my side I tried this app: https://apps.apple.com/us/app/health-auto-export-json-csv/id1115567069. But the true 'export' through the network is behind a subscription, which IMO isn't what I want for users to deal with. One workaround would be to use a Shortcut to automate this process. I've played around with it (aka set up a ASGI server on this project and a POST endpoint to publish the export to), but haven't been any further.

This simpler app (https://apps.apple.com/us/app/simple-health-export-csv/id1535380115) looks like a better fit but there is no true export function, and there is no automations available for it in Shortcuts.

Importantly, in my oppinion is this approach respects user privacy, ensuring that health data is not shared with third-party APIs.

I second this. Everything should be local.

If you want i can push what I've already done in a separate branch for you to look at, but it's very much a WIP ;)

Regards,

k0rventen commented 6 months ago

Pushed to this branch.

And here is the shortcut that i've made: https://www.icloud.com/shortcuts/41f3bde06db040c1a08c18218a02dd54.

Install the new dependencies, run python api.py, change the IP in the Shortcut to your server's, then launch it. It should create a 'import.csv' file (which is actually JSON, forgot to change it when testing).

jschulman commented 2 months ago

The shortcut doesn't import correctly for me. What is the full POST url to port 5000? A curl test would be great.

k0rventen commented 2 months ago

As said in a comment above,

I've played around with it (aka set up a ASGI server on this project and a POST endpoint to publish the export to), but haven't been any further.

The server doesn't actually import the data, but merely creates a file locally with the data from the shortcut.

djhn75 commented 2 months ago

Here is a shortcut that can transfer several data points for a specific date to influxdb v2. Maybe someone is interested.

You just have to enter the IP, ORG, and Api token in the dictionary

https://www.icloud.com/shortcuts/3a457dd48dcd42869eb9c02374bed114

latetedemelon commented 1 month ago

This one appears to work for influxdb v1: https://github.com/ivailop7/Healthkit-influxdb-grafana This one for version 2: https://github.com/samanthavbarron/Healthkit-influxdb-grafana And here is my WIP for Victoria Metrics: https://github.com/latetedemelon/Healthkit-influxdb-grafana