Read export.xml with Python
On iPhone, open Health → Summary → your profile → Export All Health Data. Save the ZIP, transfer it to your computer, and unzip it. Put this script in a file named read_health.py beside export.xml. It uses Python 3’s standard library and reads records as they arrive, so a long history can be processed without loading the whole file into memory. Apple’s export instructions.
import csv
import sys
from xml.sax import parse
from xml.sax.handler import ContentHandler
xml_path, record_type = sys.argv[1:]
columns = ("startDate", "endDate", "value", "unit", "sourceName")
writer = csv.writer(sys.stdout, lineterminator="\n")
class Measurements(ContentHandler):
def startElement(self, name, attrs):
if name == "Record" and attrs.get("type") == record_type:
writer.writerow([attrs.get(key, "") for key in columns])
writer.writerow(columns)
parse(xml_path, Measurements())
Run this in that folder. Choose a fresh output filename each time you want to keep an earlier result.
python3 read_health.py export.xml HKQuantityTypeIdentifierHeartRate > heart-rate.csv
Open the CSV and compare a timestamp and value with a reading in Health. The two date columns keep the original time-zone offset, and the source column distinguishes devices and apps. A file containing only the header means no records matched that exact identifier. For resting heart rate, use HKQuantityTypeIdentifierRestingHeartRate. For Apple’s SDNN samples, use HKQuantityTypeIdentifierHeartRateVariabilitySDNN. The same script handles category records, where the value can be text and the unit can be empty.
This example reads measurement records. For runs, distance lives on the workout itself or in its nested statistics. See where to find workout distance in the XML. For the same measurement-to-CSV task without code, use the local browser converter.
When you need HealthKit
If you are building an iPhone app, enable the HealthKit capability and explain why the app needs to read health data. Request access to the specific types you use, then query the device’s HealthKit store. Permission is per type. An empty query can mean there are no visible samples, including when the person has declined read access. Apple’s HealthKit authorization guide.
If you are looking up a recent API change, Apple’s June 2026 notes include workout zones for heart rate and cycling power. Check availability for the specific symbol and OS you support. Apple’s HealthKit updates.
When you need an HTTP endpoint
If a notebook or dashboard needs fresh data, configure HealthSave to sync to your own HealthSave Observatory server. Then query that server from Python using its documented credentials and export endpoint. The readings come from the types you allowed the iPhone app to read and the batches your server has received. Your Apple Account password is never an API credential for the notebook. Set up and query your own REST API.