HealthKit is Apple’s developer framework and on-device data store for health and fitness information, introduced with iOS 8 in 2014. Among Wearable platforms, it is the layer that connects Apple Watch sensors, third-party devices and apps through one shared, permission-controlled repository, while the Apple Health app is the user-facing view of the same data.
HealthKit does not measure anything by itself. It defines standardized data types, units and storage rules, so that a running app, a smart scale, a sleep tracker and Apple Watch can all contribute to one record. Its design puts user consent and on-device privacy at the center, which shapes how developers build every integration.
How HealthKit stores and shares data
HealthKit works as a central, encrypted database on the device that apps access through a single entry point called HKHealthStore. An app does not talk directly to other apps; it writes samples into the store and reads samples that the user has allowed it to see, so the store acts as a broker between data producers and consumers.
Every record carries metadata about its source, device and time range, which lets the system merge data from several producers. When both an iPhone and Apple Watch count steps during the same walk, HealthKit uses a source priority order set by the user to avoid double counting in statistics.
The table below lists the core building blocks that developers encounter in almost every HealthKit integration.
| Building block | Role | Typical use |
|---|---|---|
| `HKHealthStore` | Access point to the data store | Request authorization, run queries, save samples |
| `HKQuantitySample` | Numeric value with a unit and time | Heart rate, steps, body mass |
| `HKCategorySample` | Value from a fixed list of states | Sleep stages, mindful sessions |
| `HKWorkout` | Exercise session with summary data | Runs, swims, strength training |
| `HKSource` and device | Origin of each sample | Deduplication and source priority |
Health data is encrypted on the device and protected when the iPhone is locked. When the user enables syncing, Apple describes Health data in iCloud as end-to-end encrypted for accounts with two-factor authentication, so the data is not readable on Apple’s servers.
Data types and units in HealthKit
HealthKit organizes information into typed categories with explicit units, which is what allows data from different vendors to be combined reliably. A developer must declare the exact type and use the HKUnit system, so a weight written in pounds and one written in kilograms remain directly comparable.
The following table summarizes the major type families and representative examples.
| Type family | What it represents | Examples |
|---|---|---|
| Quantity types | Measured numeric values | Heart rate, active energy, blood oxygen |
| Category types | Discrete states or events | Sleep analysis, menstrual flow, high heart rate events |
| Characteristic types | Rarely changing personal facts | Date of birth, biological sex, blood type |
| Workout types | Activity sessions and routes | Workout records with GPS route samples |
| Correlation types | Related samples grouped together | Blood pressure, food entries |
| Clinical record types | Imported medical records | Lab results and medications in FHIR format |
Quantity types are further split into cumulative and discrete values. Steps and active energy are cumulative, so statistics sum them; heart rate and body temperature are discrete, so statistics compute minimum, maximum and average instead.
Permissions, privacy and App Store rules
HealthKit uses granular, per-type authorization, meaning that the user grants or denies read and write access separately for each data type. An app that requests heart rate and sleep must ask for each one, and the user can allow writing workouts while refusing to share any readings.
- Read denial is hidden: an app cannot tell whether it was denied read access or whether no data exists, which prevents inferring sensitive facts from a refusal.
- Purpose strings are mandatory: the app must explain in its configuration why it reads and writes health data.
- Advertising use is prohibited: App Store rules forbid using HealthKit data for advertising or selling it to data brokers.
- No casual cloud copies: guidelines restrict storing personal health information in a regular iCloud container.
- Revocation is instant: the user can change permissions at any time in the Health app or system settings.
These rules make HealthKit stricter than many general-purpose APIs, and they are a frequent reason for App Store rejection when a developer requests more types than the app visibly uses.
Queries, background delivery and Apple Watch workouts
Apps read HealthKit data through specialized query classes, each suited to a different access pattern. Choosing the right query is the main performance decision in a HealthKit integration, because a naive sample query over months of heart rate data can return hundreds of thousands of samples.
The decision table below matches common tasks to the appropriate query type.
| Task | Recommended query | Reason |
|---|---|---|
| Show daily step totals for a chart | Statistics collection query | Aggregates by interval with source deduplication |
| Sync new data to a server | Anchored object query | Returns only additions and deletions since last anchor |
| React when new data arrives | Observer query with background delivery | Wakes the app at a set frequency |
| Show one total for today | Statistics query | Returns a single aggregated value |
| List recent individual samples | Sample query with a limit | Simple retrieval with sorting |
On watchOS, HealthKit also drives live workout tracking through HKWorkoutSession and HKLiveWorkoutBuilder. A workout session keeps sensors running at higher sampling rates, lets the app stay active in the foreground, and builds a complete workout record with heart rate, energy and distance that is saved to the store when the session ends.
HealthKit compared with other health data platforms
HealthKit is one of several health data hubs in the wearable ecosystem, and its closest counterpart on Android is Health Connect. The platforms share the idea of a consent-based shared store but differ in where data lives and who controls the ecosystem.
| Platform | Ecosystem | Data location |
|---|---|---|
| HealthKit | iPhone, Apple Watch, iPad | On device, optional encrypted iCloud sync |
| Health Connect | Android phones and Wear OS | On device, shared between apps |
| Google Fit | Android, legacy APIs being retired | Cloud account storage |
| Samsung Health | Galaxy phones and watches | App storage with Samsung account sync |
A practical consequence is that cross-platform apps need two integrations. Services such as Strava, Garmin Connect or Polar Flow typically write workouts into HealthKit on iPhone and into Health Connect on Android, mapping their own data model to each platform’s types and units.
In plain words
HealthKit is like a locked filing cabinet for health numbers on an iPhone. Apple Watch, a smart scale or a running app can put their measurements into it, such as steps, heart rate or workouts.
Other apps may look inside only when the owner gives permission, and each drawer needs its own permission. A diet app may be allowed to see weight but not sleep. The point is that health information stays in one place under the owner’s control instead of being scattered across many apps.
A real-world example
A small development team builds a strength training app for iPhone and Apple Watch. Users log sets on the watch, and the team wants each session to appear in Apple Health and to count toward Activity rings without building separate sensor code.
The team starts an HKWorkoutSession on the watch, uses a live workout builder to collect heart rate and active energy, and saves a traditional strength training workout at the end. On iPhone, the app requests read access only to body mass and resting heart rate, and uses a statistics collection query to chart weekly averages.
The result is a lean integration without custom sensor handling. After release, users who also wear a smart scale see their weight trends next to training volume, and App Review approves the app on the first attempt because each requested data type is clearly visible in the interface.