Library to extract information from Apple Health exports.
To use this library, is required to provide an export file from the iOS Apple Health app.
- Open the Apple Health app on your iOS device.
- Tap on your profile picture on the top-right corner.
- Scroll down until you see a button that reads "Export All Health Data".
- After pressing the button, a dialog will appear while the export process is ongoing (it might take a while).
- Once the process is finished, a file called
apple_health_export.zip
will be generated. - Finally, from that zip file you'll need only the file named
export.xml
.
from health import HealthData
FILE = "./export/export.xml"
data = HealthData.read(
FILE,
include_me=True,
include_activity_summaries=True,
include_correlations=False,
include_records=False,
include_workouts=True,
)
print(data.me.biological_sex)
print(f"{len(data.activity_summaries)} activity records")
print(f"{len(data.correlations)} correlations")
print(f"{len(data.records)} records")
print(f"{len(data.workouts)} workouts")
>> HKBiologicalSexMale
>> 322 activity records
>> 0 correlations
>> 0 records
>> 129 workouts
note: use the flags on the
HealthData.read
to include only what you need to speed up the reading process.