Health Data Types

Specify the kind of data used in HealthKit.

Overview

HealthKit uses HKObjectType subclasses to identify the different types of data stored in HealthKit:

  • HKCharacteristicType represents data that does not typically change over time (for example, blood type).

  • HKQuantityType represents samples that contain a numeric value (for example calories consumed).

  • HKCategoryType represents samples that contain an option from a short list of possible values (for example sleep analysis).

  • HKCorrelationType represents complex samples that contain a number of quantity or category samples (for example, a food sample that includes a number of nutrition samples).

  • HKWorkoutType represents a workout and its associated data (for more information, see Workouts).

  • Other object types (for example, HKActivitySummaryType, HKDocumentType, and HKSeriesType) represent other, specialized data types.

To create a type object, call the appropriate HKObjectType class method, and pass in the desired type identifier.

let bloodType = HKObjectType.characteristicType(forIdentifier: .bloodType)

let caloriesConsumed = HKObjectType.quantityType(forIdentifier: .dietaryEnergyConsumed)

let sleepAnalysis = HKObjectType.categoryType(forIdentifier: .sleepAnalysis)

You can use the resulting object types to request permission to access the data, to save new data to the HealthKit store, or to read data from the HealthKit store.

Topics

Type Objects

HKCharacteristicType

Characteristic types represent data that does not typically change over time.

HKQuantityType

Quantity types identify samples that store numerical values.

HKCategoryType

Category types identify samples that contain a value from a small set of possible values.

HKCorrelationType

Correlation types identify samples that group multiple subsamples.

HKActivitySummaryType

Activity summary types identify activity summary objects.

HKSeriesType

An identifier that indicates the type for data stored in a series sample.

HKObjectType

The abstract superclass for all classes that identify a specific type of data when working with the HealthKit store.

HKSampleType

An abstract superclass for all classes that identify a specific type of sample when working with the HealthKit store.

HKClinicalType

Clinical types identify samples that contain clinical record data.

Beta

Characteristic Identifiers

HKCharacteristicTypeIdentifierBiologicalSex

A characteristic type identifier for the user’s sex.

HKCharacteristicTypeIdentifierBloodType

A characteristic type identifier for the user’s blood type.

HKCharacteristicTypeIdentifierDateOfBirth

A characteristic type identifier for the user’s date of birth.

HKCharacteristicTypeIdentifierFitzpatrickSkinType

A characteristic type identifier for the user’s skin type.

HKCharacteristicTypeIdentifierWheelchairUse

A characteristic identifier for the user’s use of a wheelchair.

Body Measurements

HKQuantityTypeIdentifierHeight

A quantity sample type that measures the user’s height.

HKQuantityTypeIdentifierBodyMass

A quantity sample type that measures the user’s weight.

HKQuantityTypeIdentifierBodyMassIndex

A quantity sample type that measures the user’s body mass index.

HKQuantityTypeIdentifierLeanBodyMass

A quantity sample type that measures the user’s lean body mass.

HKQuantityTypeIdentifierBodyFatPercentage

A quantity sample type that measures the user’s body fat percentage.

Vital Signs

HKQuantityTypeIdentifierHeartRate

A quantity sample type that measures the user’s heart rate.

HKQuantityTypeIdentifierBodyTemperature

A quantity sample type that measures the user’s body temperature.

HKCorrelationTypeIdentifierBloodPressure

Blood pressure correlation types combine a systolic sample and a diastolic sample into a single blood pressure reading.

HKQuantityTypeIdentifierBloodPressureSystolic

A quantity sample type that measures the user’s systolic blood pressure.

HKQuantityTypeIdentifierBloodPressureDiastolic

A quantity sample type that measures the user’s diastolic blood pressure.

HKQuantityTypeIdentifierBloodGlucose

A quantity sample type that measures the user’s blood glucose level.

HKQuantityTypeIdentifierInsulinDelivery

A quantity sample that measures the amount of insulin delivered.

HKQuantityTypeIdentifierRespiratoryRate

A quantity sample type that measures the user’s respiratory rate.

HKQuantityTypeIdentifierVO2Max

A quantity sample that measures the maximal oxygen consumption during incremental exercise.

Nutrition

Nutrition Type Identifiers

Type identifiers used for tracking diet and nutrition.

Mindfullness and Sleep

HKCategoryTypeIdentifierMindfulSession

A category sample type for recording a mindful session.

HKCategoryTypeIdentifierSleepAnalysis

A category sample type for sleep analysis information.

Activity

HKQuantityTypeIdentifierStepCount

A quantity sample type that measures the number of steps the user has taken.

HKQuantityTypeIdentifierDistanceWalkingRunning

A quantity sample type that measures the distance the user has moved by walking or running.

HKQuantityTypeIdentifierDistanceCycling

A quantity sample type that measures the distance the user has moved by cycling.

HKQuantityTypeIdentifierPushCount

A quantity sample type that measures the number of pushes that the user has performed while using a wheelchair.

HKQuantityTypeIdentifierDistanceWheelchair

A quantity sample type that measures the distance the user has moved using a wheelchair.

HKQuantityTypeIdentifierSwimmingStrokeCount

A quantity sample type that measures the number of strokes performed while swimming.

HKQuantityTypeIdentifierDistanceSwimming

A quantity sample type that measures the distance the user has moved while swimming.

HKQuantityTypeIdentifierBasalEnergyBurned

A quantity sample type that measures the resting energy burned by the user.

HKQuantityTypeIdentifierActiveEnergyBurned

A quantity sample type that measures the amount of active energy the user has burned.

HKQuantityTypeIdentifierFlightsClimbed

A quantity sample type that measures the number flights of stairs that the user has climbed.

HKQuantityTypeIdentifierNikeFuel

A quantity sample type that measures the number of NikeFuel points the user has earned.

HKQuantityTypeIdentifierAppleExerciseTime

A quantity sample type that measures the amount of time the user moved at an average intensity of a brisk walk or greater.

HKCategoryTypeIdentifierAppleStandHour

A category sample type indicating whether the user has stood for at least one minute during the sample.

Reproductive Health

HKCategoryTypeIdentifierSexualActivity

A category sample type for recording sexual activity.

HKCategoryTypeIdentifierIntermenstrualBleeding

A category sample type for representing spotting outside the normal menstruation period.

HKCategoryTypeIdentifierMenstrualFlow

A category sample type for representing menstrual cycles.

HKCategoryTypeIdentifierOvulationTestResult

A category sample type for recording the result of an ovulation home test.

HKCategoryTypeIdentifierCervicalMucusQuality

A category sample type for representing the quality of the user’s cervical mucus.

HKQuantityTypeIdentifierBasalBodyTemperature

A quantity sample type that measures the user’s basal body temperature.

UV Exposure

HKQuantityTypeIdentifierUVExposure

A quantity sample type that measures the user’s exposure to UV radiation.

Clinical Records

HKClinicalTypeIdentifier

Type identifiers for the different categories of clinical records.

Beta

See Also

Health Data

Saving Data to HealthKit

Create and share HealthKit samples.

Reading Data from HealthKit

Use queries to request sample data from HealthKit.

Health and Fitness Samples

Create and save health and fitness samples.

Queries

Query health and fitness data.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software