HealthKit

Access and share health and fitness data while maintaining the user’s privacy and control.

Overview

HealthKit provides a central repository for health and fitness data on iPhone and Apple Watch. With the user’s permission, apps communicate with the HealthKit store to access and share this data.

Illustration showing the activity, mindfulness, nutrition, and sleep icons from the Health app.

Creating a complete, personalized health and fitness experience includes a variety of tasks:

  • Collecting and storing health and fitness data

  • Analyzing and visualizing the data

  • Enabling social interactions

HealthKit apps take a collaborative approach to building this experience. Your app does not need to provide all of these features. Instead, you can focus just on the subset of tasks that most interests you.

For example, users can select their favorite weight-tracking, step-counting, and health challenge app, each calibrated to their personal needs. Because HealthKit apps freely exchange data (with user permission), the combined suite provides a more customized experience than any single app on its own. For example, when a group of friends joins a daily step-counting challenge, each person can use their preferred hardware device and app to track their steps, while everyone in the group uses the same social app for the challenge.

HealthKit is also designed to manage and merge data from multiple sources. For example, users can view and manage all of their data in the Health App, including adding data, deleting data, and changing an app’s permissions. Therefore, your app needs to handle these changes, even when they occur outside your app.

Topics

First Steps

About the HealthKit Framework

Learn about the architecture and design of the HealthKit framework.

Setting Up HealthKit

Set up and configure your HealthKit store.

Protecting User Privacy

Respect and safeguard your user’s privacy.

class HKHealthStore

The access point for all data managed by HealthKit.

Health Data

Saving Data to HealthKit

Create and share HealthKit samples.

Reading Data from HealthKit

Use queries to request sample data from HealthKit.

Data Types

Specify the kind of data used in HealthKit.

Samples

Create and save health and fitness samples.

Queries

Query health and fitness data.

Workout Data

Workouts and Activity Rings

Manage workouts, workout sessions, and activity summaries.

Errors

struct HKError

An error returned from a HealthKit method.

let HKErrorDomain: String

The domain for all HealthKit errors.

enum HKError.Code

Error codes that may be returned when calling HealthKit methods.