Apple HealthKit API: A Guide for Wearable Integration

The Apple HealthKit API is the front door to health data on every iPhone and Apple Watch. That reach is large: iOS runs on about 39.5% of European smartphones as of July 2026, according to StatCounter. However, the framework does not behave like the cloud APIs most teams expect and that surprises people once they start to build.

This raises a practical question:
Which parts of the Apple HealthKit API can you build on and where does its on-device, consent-first design reshape your architecture?

This guide walks the apple healthkit api. We cover the framework, permissions and entitlements, HealthKit data types, queries, background sync, EU backend delivery and the medical-device line. For the wider multi-vendor picture across Garmin, Oura and the rest, our companion piece on wearable health data integration goes wider.

Table of Content

How the Apple HealthKit API Works

The apple healthkit api is a native HealthKit framework and not a web service. It gives an iOS or watchOS app read and write access to a single on-device store that Apple Health and hundreds of other apps also write to. So the mental model is a shared local database for one person, guarded by that person's consent, rather than a server you call from your backend.

The Apple HealthKit API Is Not a Cloud Backend

This point reshapes most projects. There is no public server endpoint for Apple Health, so you cannot pull a user's data from your own infrastructure. Instead, every read happens through code running on that user's iPhone or Apple Watch, inside an app they installed and authorised.

In practice this means a web-only health app cannot reach HealthKit at all. Therefore a native iOS app has to sit in the flow as the data gateway, even when the main experience is a web dashboard. For the design side of that gateway, our work on wearable app development starts from exactly this constraint.

What the Framework Stores and Guards

The store centralises data from many data sources and keeps it under the user's control. As a result, your app has to cope with values written by other apps and with permissions the user can change at any time.

  • A single HKHealthStore instance is the access point for every read and write your app makes.
  • Data lives on the device and syncs across the user's own Apple devices and not to your servers.
  • The user can add, edit or delete data and revoke your access from the Health app, so your code cannot assume a value it saw yesterday is still there.

-> In short: HealthKit is an on-device framework reached only from a native app with user consent, never from your backend. Treat it as a shared local health database you read through the phone.

"Flowchart titled How the Apple HealthKit API Works showing data sources Apple Watch, iPhone sensors and Other health apps feeding into the HealthKit store on the user's device, then read with consent per data type, then with consent to a native iOS app using HKHealthStore and queries, then upload via TLS to your EU backend for normalise, FHIR and store, with the note that on-device by design there is no server API so a consented native app is the only gateway to your backend"

What To Do:

  • Assume no server API exists and plan a native iOS app as the gateway even for a web product.
  • Create one HKHealthStore and check HKHealthStore.isHealthDataAvailable() before any call.
  • Design for change, since users can revoke access or delete data whenever they choose.

Requesting Permission the Right Way

Permission is where a HealthKit build succeeds or stalls. The apple healthkit api enforces consent per data type, so heart rate, steps and sleep are each authorised separately rather than in one blanket grant. For example, a user can let you read steps while refusing workouts and your app has to keep working either way.

The HealthKit Entitlement and Usage Strings

Before prompts appear, the project needs the HealthKit capability enabled and the right keys in the Info property list. Without them the app crashes on the first request, so this is the first thing to wire up.

  1. Add the HealthKit entitlement to the app's capabilities in Xcode.
  2. Set NSHealthShareUsageDescription to explain why you read data, in plain language the user sees at the prompt.
  3. Set NSHealthUpdateUsageDescription if you also write data back to the store.

Read and Write Authorization per Data Type

You request read and share sets with requestAuthorization(toShare:read:), passing the exact HKObjectType values your app needs. Apple's own guidance on authorizing access to health data sets out the flow in detail.

One privacy rule catches teams out. For read access, the framework will not tell you whether the user has given permission, because this information could reveal health details. Therefore, instead of reading an authorisation status, you design for empty results and request the smallest set of types the feature genuinely needs.

-> In short: Enable the HealthKit entitlement, add both usage-description strings, then request read and write consent per data type. Read status stays hidden by design, so handle empty results gracefully.

What To Do:

  • Request only the HKObjectType values a feature needs, because over-asking lowers consent and draws App Review scrutiny.
  • Write both usage strings clearly, since the user reads them at the exact moment they decide.
  • Never branch on read authorisation status and treat an empty query result as a normal, expected case.

Working With HealthKit Data Types

Every value in the store has a type and the type decides how you read it and what unit it carries. HealthKit models this with a small class hierarchy under HKObjectType, so learning the shape once makes the whole framework predictable.

Quantity, Category, Correlation and Workout Types

Most of the data you encounter is a sample and these samples can be categorised into a few distinct groups. For instance, a heart rate reading is a quantitative sample with a unit of measurement, whereas a sleep stage is a qualitative sample from a fixed set of values.

  • HKQuantityType: numeric values with a unit, such as heart rate, steps, active energy or blood glucose.
  • HKCategoryType: values from a defined set, such as sleep analysis or mindful sessions.
  • HKCorrelationType: grouped samples that belong together, such as a blood-pressure reading or a food entry.
  • HKWorkoutType: workout data, covering duration, energy and associated samples.

Because quantity samples carry a unit, you always read them with an explicit HKUnit. As a result, a value is never ambiguous between, say, count-per-minute and a raw count.

Clinical Records as FHIR Resources

One data family sits apart. With extra permission, HealthKit can surface a user's clinical records and it returns them as HL7 FHIR resources rather than as ordinary samples.

So an allergy, a lab result or an immunisation arrives as structured FHIR your backend can map directly. That makes HealthKit a bridge into HL7 FHIR interoperability, which matters when the app has to talk to hospital systems.

-> In short: Data sits under HKObjectType as quantity, category, correlation and workout samples, each read with the correct HKUnit. Clinical records are separate and arrive as HL7 FHIR resources.

"Diagram titled The HealthKit Data Type Map showing HKObjectType branching into HKClinicalType for clinical records, which maps to HL7 FHIR R4, and HKSampleType, which splits into HKCorrelationType for blood pressure and nutrition, HKCategoryType for sleep and mindful sessions, HKWorkoutType for workouts and samples, and HKQuantityType for heart rate, steps and glucose, which is always read with an HKUnit"

What To Do:

  • Map each metric your product needs to its exact HKQuantityType or HKCategoryType before you design the schema.
  • Always pair a quantity type with its HKUnit, so stored values stay unambiguous.
  • If you need lab or diagnosis data, plan for clinical records as FHIR rather than as plain samples.

Reading Data and Background Sync

Reading Apple HealthKit data is done with queries and picking the right query is what keeps an app responsive and current. The framework offers one-shot reads, incremental reads and background updates, so you match the query to the job rather than reaching for the same one every time.

Queries: One-Shot, Incremental and Statistics

Three query types cover most needs. For instance, an onboarding screen that pulls the last month of steps wants a different query from a screen that shows a daily average.

  • HKSampleQuery: a one-shot fetch of samples matching a predicate, ideal for a single view.
  • HKAnchoredObjectQuery: an incremental read that returns only what changed since your last anchor, which avoids re-reading the whole history.
  • HKStatisticsCollectionQuery: server-style aggregates such as daily sums or averages, computed by the framework.

Background Delivery and Real-Time Workouts

HealthKit is not a live stream and yet you can still react to new data without the app being open. You register an HKObserverQuery and call enableBackgroundDelivery and the system then wakes your app when matching data arrives.

The pattern differs for genuinely continuous data. Rather than background delivery, a live workout uses an Apple Watch workout session to stream heart rate and energy data in real time. Meanwhile, background delivery is better suited to steadier signals, such as sleep data or weight, or for periodic syncs.

-> In short: Use HKSampleQuery for one view, HKAnchoredObjectQuery for incremental reads and HKStatisticsCollectionQuery for aggregates. HKObserverQuery with background delivery wakes the app on new data, while live workouts use a watch session.

What To Do:

  • Default to HKAnchoredObjectQuery for sync, so you fetch only what changed since the last anchor.
  • Enable background delivery for steady signals and reserve a workout session for real-time streaming.
  • Push aggregation into HKStatisticsCollectionQuery instead of summing raw samples on the client.

Getting HealthKit Data to Your Backend

Most products require Apple Health data to be extracted from the phone, whether for clinical use, analytics or a shared dashboard. As there is no server API, HealthKit leaves the data transfer to your app, provided the user consents. Therefore, the sync loop is yours to design and this is where the engineering effort lies.

The pattern is consistent across serious health apps. First the user consents, then the app reads, then it uploads securely and finally your backend does the heavy work.

  1. The user installs the iOS app and grants permission for the chosen data types.
  2. The app reads new Apple HealthKit data, usually with an anchored query for efficiency.
  3. With consent, the app uploads them over TLS to your backend.
  4. Your backend normalises, deduplicates and stores the data.
  5. You present insights back in the app or on a web dashboard.

Normalising and Storing Health Data in the EU

Although raw Apple HealthKit data is rich, it is uneven because different source apps log the same metric in different ways. Therefore, a normalisation layer is required and mapping to HL7 FHIR resources provides a stable, common model across sources.

Storage location matters just as much as structure. For an EU product, host the health data in the EU and keep the data model consistent. That is exactly the ground our piece on wearable health data integration covers for the multi-vendor case.

-> In short: There is no backend API, so a native app reads with consent and uploads to your server, which normalises and stores the data. Map to HL7 FHIR and host health data in the EU.

What To Do:

  • Build the upload on anchored reads plus TLS, so each sync moves only new data securely.
  • Normalise to a FHIR-based model on the backend, since source apps log the same metric differently.
  • Keep health data hosted in the EU from day one, rather than retrofitting residency later.

When a HealthKit App Becomes a Medical Device

This is the aspect that US-based guides tend to overlook, but it determines your entire compliance path. Under the EU's Medical Device Regulation (MDR), a HealthKit app is classified as a medical device based on its intended purpose, so it is the claim you make that determines its classification, not the framework you used. For the software-classification detail, our guide to software as a medical device goes deeper on Rule 11.

The Claim Decides Under EU MDR

An app that shows steps for fitness sits outside the regulation. The same app, marketed to detect or manage a condition, makes a medical claim and becomes a medical device. So the moment your app diagnoses, monitors, predicts or treats, it is regulated.

  • Wellness and lifestyle claims usually stay outside EU MDR.
  • A diagnostic, monitoring or treatment claim pulls the app under EU MDR, and software is classified under Rule 11.
  • Regulated status then brings a conformity assessment, CE marking and a risk file under ISO 14971.

The European Commission's MDCG 2019-11 guidance sets out how software qualifies and classifies under the regulation.

GDPR and App Store Review

Two further gates apply whatever your MDR status. Health data is special-category data under GDPR Article 9, so you need a lawful basis, EU-appropriate hosting and clear consent records.

The App Review adds its own rules on top of this. For example, Apple prohibits the use of HealthKit data for advertising or sales purposes. It also requires a published privacy policy, meaning these constraints shape the product as much as the regulations do.

-> In short: Under EU MDR the claim, not the framework, turns a HealthKit app into a medical device classified under Rule 11. GDPR Article 9 and App Store review apply on top, whatever the MDR status.

"Flowchart titled When a HealthKit App Becomes a Medical Device starting with the question whether the app diagnoses, monitors, predicts or treats, where No leads to a wellness or lifestyle app outside EU MDR with GDPR still applying, and Yes leads to a medical device with software classified under Rule 11, which leads to three requirements: Conformity and CE, ISO 14971 risk, and GDPR Article 9"

What To Do:

  • Write the intended purpose and the exact claim before you build, because the claim sets the regulatory path.
  • If the claim is medical, plan Rule 11 classification, a conformity assessment and an ISO 14971 risk file early.
  • Treat GDPR Article 9 and App Review privacy rules as build requirements, not late paperwork.

Closing Thoughts

The apple healthkit api rewards teams that respect its shape. It is on-device, consent-first and typed, so the wins come from planning the permissions, the data types and the sync loop early rather than fighting the framework later.

When scoping a HealthKit build, fix the data model, the backend sync and the regulatory claim before the code locks. That is the work we fold into custom wearable development, from the first sprint.

FAQs on the Apple HealthKit API

What is the Apple HealthKit API?

A1: The Apple HealthKit API is a native iOS and watchOS framework for health and fitness data. With the user's permission, it gives an app read and write access to a single on-device store shared with Apple Health. It is not a cloud service or a web endpoint. Your app talks to it through HKHealthStore on the user's iPhone or Apple Watch and not from your backend.

Q2: Is there a backend or web API for Apple Health data?

A2: No. There is no public server-side API for Apple Health, so you cannot fetch a user's data from your own infrastructure. All access happens on the device inside a native app the user installed and authorised. To use the data on a server, your app must read it and upload it with consent.

Q3: How do I request HealthKit permissions?

A3: First enable the HealthKit entitlement and add the NSHealthShareUsageDescription and NSHealthUpdateUsageDescription strings. Then call requestAuthorization(toShare:read:) with the exact HKObjectType values you need. Consent is granted per data type and for reads the framework will not reveal whether the user agreed, so design for empty results rather than checking a status.

Q4: Can a web app access HealthKit data?

A4: Not directly. Because HealthKit lives on the device and has no server API, a web-only app cannot reach it. The common pattern is a lightweight native iOS app that reads the data and syncs it to your backend, which then feeds a web dashboard.

Q5: How do I get Apple Health data to my server?

A5: You read it in the app, usually with an HKAnchoredObjectQuery so you only fetch new samples, then upload it securely to your backend with the user's consent. The backend normalises, deduplicates and stores the data. Mapping to HL7 FHIR gives a stable model, and for EU products the store should be hosted in the EU.

Q6: Does an app using the apple healthkit api need CE marking under EU MDR?

A6: Only if it makes a medical claim. When the intended purpose is to diagnose, monitor, predict or treat, the app is a medical device under EU MDR. Its software is then classified under Rule 11. It also needs a conformity assessment and CE marking before sale in the EU. A pure fitness or wellness app with no medical claim usually sits outside MDR.

Q7: Is HealthKit data covered by GDPR?

A7: Yes. Health data is special-category data under GDPR Article 9, so it needs a lawful basis, explicit user consent and appropriate safeguards, whatever the app's MDR status. For an EU product that means EU-appropriate hosting and clear consent records. Apple's own App Review rules add that HealthKit data may not be used for advertising.



What else we can do for You?

Contact us to Schedule a Short Call

Building on Apple Health and unsure about permissions, backend sync or the EU MDR line? Let us talk it through.