Apple Watch + Apple Health:
a complete guide for the researcher
From native export to Python pipelines - how to work with physiological data at any level of training.
What is Apple Health and how does it work?
Before working with data, it is important to understand the system architecture. Without this understanding, many things will seem strange - for example, why the data is sometimes duplicated, why the heart rate is not recorded every second, or why the export file weighs half a gigabyte.
Apple Health is more than just an app. It is a centralized database of physiological information deployed locally on your iPhone. Technical name - HealthKit. The Health application that you see on the screen is just a user interface to this database.
Key principle: Data is stored on the device, not on Apple servers. This means Apple doesn't have a cloud API through which a researcher can connect remotely and download someone's data.. All access occurs only through the iPhone of a specific user, with his explicit permission. With two-factor authentication enabled, even Apple itself does not have the keys to decrypt the data - it is protected by end-to-end encryption.
How the data gets into the database: Any device or app that has user permission can write data to HealthKit. Apple Watch does this automatically and continuously. Garmin, Oura, Polar and other devices - through their applications. The user can also enter data manually. Each record contains four required fields: data type, numeric value, unit of measure, and source—the device or application that created the record.
Data storage model important for understanding what happens when you have multiple devices. Apple Health doesn't average or mix data from different sources—it stores all records in isolation. When you request a daily total (for example, the number of steps per day), the system applies a hierarchy of priorities and selects the value from the source with the highest priority. By default, Apple Watch is ranked higher than iPhone, iPhone is higher than third-party apps. The user can change this order manually in the settings of the “Data Sources” section.
This has a practical consequence for the researcher: if a participant wears both an Apple Watch and a Garmin, steps will be recorded twice, but only those from the priority source will be included in the summary statistics. In the raw export, however, both records will be visible - and this must be taken into account when cleaning the data.
What is actually stored inside - the nature of the data
This is one of the most important sections for a researcher. The difference between what you expect to get and what's actually stored in Apple Health can completely change the design of your study.
Apple Watch reads photoplethysmogram (PPG)—the optical signal of green light reflecting off blood vessels—and processes it using built-in machine learning algorithms. The result is already included in the database: the pulse value in beats per minute, and not the wave signal itself. The same thing happens with the accelerometer: instead of the original stream of acceleration values along three axes, the number of steps or the fact of training is recorded in HealthKit.
For a researcher, this means the following: you are working with processed indicators, and not with primary physiological signals. This doesn't make the data useless - it's great for trend analysis, correlations, observational studies and working with large samples. But if your task is to analyze the quality of the signal itself or obtain R-R intervals with millisecond accuracy, the standard capabilities of HealthKit will not be enough.
Each entry in the database is accompanied by metadata: source (name of device or application), device identifier, time stamps of the beginning and end of measurement. Field sourceName allows you to subsequently filter data for a specific device - this is an important cleaning tool.
Compatible devices - who writes what to the database
Here lies one of the key values of Apple Health for the researcher: it is an open aggregator ecosystem. If the device is able to write data to HealthKit, all the methods described in this manual work for it in full.
Open the application Health → select any metric (for example, Heart Rate) → scroll down to the section "Data Sources and Access". It lists all devices and applications that write data of this type. For the purity of the experiment, determine the priority source and make sure it is first on the list.
Native export (XML)
Free · Full archive · Suitable for one-time deep extraction of entire history
The easiest way to get all the data is native export directly from the Health app. No third party tools, no permissions, just a few clicks.
-
1Open the application Health on iPhone.
-
2Click on yours avatar or initials in the upper right corner.
-
3Scroll down to "Export all health data".
-
4Confirm action. Creating an archive will take from a few minutes to half an hour.
-
5Save the file
export.zipvia AirDrop, iCloud Drive or send by mail.
What's inside the archive: main file - export.xml. Each entry looks like this:
<Record type="HKQuantityTypeIdentifierHeartRate" sourceName="Apple Watch" unit="count/min" startDate="2025-03-15 08:14:22 +0300" value="72"/>
If the data came from Coros or Garmin - field sourceName will contain its name. The structure is identical.
⚠️ File size: from 100 MB to 1–2 GB over several years. Excel will not open such a file.. Need a converter or code.
Besides export.xml in the archive: GPX files with GPS training tracks and a folder electrocardiograms with ECG data.
Online service applehealthdata.com — the file is processed locally in the browser, the data is not transferred anywhere. The output is a set of CSV files, divided by data type: a separate file for heart rate, steps, sleep, and so on.
Exporter applications
The practical way for most tasks. Works the same for data from any source synced with Apple Health.
Supports 150+ metrics. Saves each individual sample (Individual Samples) - critical for time series. Automatic sending to Dropbox, Google Drive, REST API. There is a version for macOS.
Selecting specific metrics and aggregation interval. Data with detail down to the minute. Convenient for selective export without unnecessary noise.
Free minimalistic tool. Select indicators → click “Create Table” → get CSV. Zero entry threshold.
Supports Walking Asymmetry, Six-Minute Walk Test and other new metrics. Can create PDF reports for the doctor.
Structure of the final table - the same for all applications above:
| Column | What it contains |
|---|---|
| StartDate | Exact time stamp of start of measurement |
| EndDate | Measurement end time |
| Value | Numerical value of the indicator |
| Unit | Unit of measurement - count/min, ms, %, kcal |
| Source | Data source: Apple Watch, COROS PACE 3, Garmin Connect… |
| Device | Specific device ID |
Column Source allows you to instantly filter data by device if there are several sources in the database.
Python and software processing
Full control over every step. For those who want to parse, clean, build correlations, and apply statistical models.
-
1Get
export.xmlvia native export (Level 1). Unpack the archive.
-
2Install the libraries:
pip install pandas lxml matplotlib seaborn
-
3Parsing XML into DataFrame:
import xml.etree.ElementTree as ET import pandas as pd tree = ET.parse('export.xml') root = tree.getroot() records = [] for record in root.findall('.//Record'): records.append({ 'type': record.get('type'), 'value': record.get('value'), 'unit': record.get('unit'), 'startDate': record.get('startDate'), 'endDate': record.get('endDate'), 'sourceName': record.get('sourceName'), 'device': record.get('device'), }) df = pd.DataFrame(records)
-
4Extract a specific metric and filter by device:
hr_df = df[df['type'] == 'HKQuantityTypeIdentifierHeartRate'].copy() hr_df['value'] = pd.to_numeric(hr_df['value']) hr_df['startDate'] = pd.to_datetime(hr_df['startDate']) hr_df = hr_df.sort_values('startDate') # Filter by specific device: hr_df = hr_df[hr_df['sourceName'] == 'Apple Watch'] # or: hr_df = hr_df[hr_df['sourceName'] == 'COROS PACE 3']
-
5Time series visualization:
import matplotlib.pyplot as plt plt.figure(figsize=(14, 4)) plt.plot(hr_df['startDate'], hr_df['value'], alpha=0.4, linewidth=0.5) plt.title('Heart Rate Time Series — Apple Watch') plt.xlabel('Date') plt.ylabel('BPM') plt.tight_layout() plt.show()
HKQuantityTypeIdentifierHeartRate # pulse (count/min) HKQuantityTypeIdentifierHeartRateVariabilitySDNN # HRV (ms) HKQuantityTypeIdentifierStepCount # steps HKQuantityTypeIdentifierVO2Max #VO2 max (ml/kg/min) HKQuantityTypeIdentifierOxygenSaturation # SpO2 (%) HKQuantityTypeIdentifierRespiratoryRate # breathing rate HKCategoryTypeIdentifierSleepAnalysis # sleep (categorical) HKQuantityTypeIdentifierRestingHeartRate # resting heart rate
import heartpy as hp working_data, measures = hp.process(data, sample_rate=1.0) print('SDNN:', measures['sdnn']) print('RMSSD:', measures['rmssd'])
combined = pd.merge(hr_daily, hrv_daily, on='date') combined = pd.merge(combined, sleep_daily, on='date') print(combined.corr())
Ready-made libraries
Raw sensor data in real time
If the task is an accelerometer, gyroscope, magnetometer with a frequency of 50–100 Hz. HealthKit won't help here.
Apple Watch does not store high-frequency sensor data in a long-term database - for power and memory reasons. There are special applications for such tasks.
- Runs simultaneously on iPhone and Apple Watch
- Accelerometer, gyroscope, barometer, magnetometer, GPS, heart rate from HealthKit
- Streaming via HTTP and MQTT in real time over a local network
- Export: ZIP CSV, JSON, Excel, KML
- Suitable for biomechanics and kinematics
- Alternative tool
- Broadcasts accelerometer data from Apple Watch to computer via HTTP/TCP
- AccelerometerX/Y/Z columns with time stamps
- Suitable for movement pattern analysis
Background recording of high frequency data on Apple Watch is limited by iOS/watchOS. Long sessions (more than 1-2 hours) require the screen to remain active or the application to run in a special Workout mode. Consider this when planning your protocol.
Data formats and what to do with them
The same health file can come in different formats - each requires a different approach.
Data processing using AI models
Apple Health CSV files lend themselves well to language model analysis. It works, and it works well.
-
1Analyze correlations — the relationship between HRV and sleep quality, between activity and resting heart rate.
-
2Find patterns and anomalies — pulse jumps, sleep changes after exercise, weekly rhythms.
-
3Generate statistics — averages, medians, standard deviations, trends for the period.
-
4Help with interpretation — explain indicators in the context of physiology.
-
5Write and debug code — create Python scripts if you are not a programmer.
-
1Don't load XML directly - convert to CSV at first.
-
2Limit the period — 30–90 days are enough for chat analysis.
-
3Choose specific metrics - not the entire archive, only the necessary types of data.
-
4Check your privacy - Remove personal identifiers before downloading third party data.
Tools: Health2AI and AI Health Export convert exports into formats optimized for loading into ChatGPT, Claude, or other language models.
Repository apple-health on GitHub supports integration with local models via Ollama. Important for studies where participant data should not leave a secure loop.
-
1Export via Health Auto Export in CSV for the last 3 months: HeartRate, HRV, SleepAnalysis, StepCount.
-
2Load the CSV into the dialog with Claude or GPT-4.
-
3Ask a specific question: “Show the correlation between overnight HRV and steps from the previous day” or “Find days when your resting heart rate was significantly higher than average.”
-
4Get analysis and interpretation.
⚠️ AI analysis is exploratory analysis, not the final conclusions of the study. The results require statistical confirmation.
Data cleaning and preparation
Typical problems and specific solutions for each of them.
df = df[df['sourceName'] == 'Apple Watch']pd.to_datetime(df['startDate'], utc=True).dt.tz_convert('Europe/Moscow')hr_df = hr_df[(hr_df['value'] >= 30) & (hr_df['value'] <= 220)]Be honest about limitations
What Apple doesn't give away and why it's important to know before starting your research.
- No access to raw PPG signal. Apple Watch measures the photoplethysmogram, but only gives the final result - the pulse value in bpm.
- There are no continuous R-R intervals in the background. Partially solved via ECG (30 sec manually) or HRV Logger and Heart Plot apps. For full HRV in the frequency domain - Polar H10.
- No server API. Data must be pushed from the participant's device manually or through an auto-exporter application.
- "Black box" of algorithms. Apple does not disclose details of calculation of HRV, sleep phases, VO2 max. Algorithms change with watchOS updates - document the version.
Accuracy of indicators: Resting pulse ±5 bpm in 89% of measurements AF: specificity 0.91 Walking steps: error 2–3% Calories: error up to 30–50% Sleep phases: 60–70% vs polysomnography SpO2: ±3–4%
- Observational studies
- Trend analysis
- Population studies
- Longitudinal monitoring
- Pilot projects
- Cardiovascular risk screening
- Clinical diagnosis
- Pharmacological tests
- High precision HRV in frequency domain
- Neurophysiology
- Sports Science at the Elite Level
About Garmin - for those who value openness. Garmin provides more open access through Garmin Health API and Connect IQ. For research where access to primary data is critical, Garmin is often more convenient. Apple wins in user friendliness, but the data remains in a “closed garden” - this is a conscious position of the platform.
Tool comparison table
| Task | Tool | Format | Level | AI analysis |
|---|---|---|---|---|
| Quickly get CSV without code | Health Auto Export / QS Access | CSV | Elementary | ✓ Yes |
| Complete historical archive | Native export + online converter | XML → CSV | Elementary | ⏱ After conversion |
| Automatic daily flow | Health Auto Export Premium | CSV / JSON | Average | ✓ Yes |
| Software processing, correlations | Native export + Python (pandas) | XML → DataFrame | Advanced | ✓ Full control |
| HRV analysis in frequency domain | Python + heartpy + Polar H10 | CSV → processing | Research | ~ Partially |
| Raw accelerometer data | Sensor Logger / SensorLog | CSV / JSON / HTTP | Research | ⏱ After export |
| Detailed training data | Garmin/Coros + GoldenCheetah FIT files | FIT → CSV | Average | ⏱ After conversion |
Checklist for starting a study
Wearable data is not perfect science by default. It's a rich, dense, but noisy stream of observations from real life - and that's what makes them valuable.. Apple Health offers the researcher a rare combination: unified access to long-term physiological data collected in vivo without laboratory restrictions. The key to working with this material is to understand where the real signal ends and the algorithmic interpretation begins.