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

A type that represents data that does not typically change over time.

HKQuantityType

A type that identifies samples that store numerical values.

HKCategoryType

A type that identifies samples that contain a value from a small set of possible values.

HKCorrelationType

A type that identifies samples that group multiple subsamples.

HKActivitySummaryType

A type that identifies activity summary objects.

HKAudiogramSampleType

A type that identifies samples that contain audiogram data.

Beta
HKSeriesType

A type that indicates the 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

A type that identifies samples that contain clinical record data.

HKWorkoutType

A type that identifies samples that store information about a workout.

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.

HKQuantityTypeIdentifierWaistCircumference

A quantity sample type that measures the user’s waist circumference.

Vital Signs

HKQuantityTypeIdentifierHeartRate

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

HKCategoryTypeIdentifierLowHeartRateEvent

A category sample type for low heart rate events.

HKCategoryTypeIdentifierHighHeartRateEvent

A category sample type for high heart rate events.

HKCategoryTypeIdentifierIrregularHeartRhythmEvent

A category sample type for irregular heart rhythm events.

HKQuantityTypeIdentifierRestingHeartRate

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

HKQuantityTypeIdentifierHeartRateVariabilitySDNN

A quantity sample type that measures the standard deviation of heartbeat intervals.

HKQuantityTypeIdentifierWalkingHeartRateAverage

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

HKDataTypeIdentifierHeartbeatSeries

A series sample containing heartbeat data.

Beta
HKQuantityTypeIdentifierOxygenSaturation

A quantity sample type that measures the user’s oxygen saturation.

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.

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.

Lab and Test Results

HKQuantityTypeIdentifierBloodAlcoholContent

A quantity sample type that measures the user’s blood alcohol content.

HKQuantityTypeIdentifierBloodGlucose

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

HKQuantityTypeIdentifierElectrodermalActivity

A quantity sample type that measures electrodermal activity.

HKQuantityTypeIdentifierForcedExpiratoryVolume1

A quantity sample type that measures the amount of air that can be forcibly exhaled from the lungs during the first second of a forced exhalation.

HKQuantityTypeIdentifierForcedVitalCapacity

A quantity sample type that measures the amount of air that can be forcibly exhaled from the lungs after taking the deepest breath possible.

HKQuantityTypeIdentifierInhalerUsage

A quantity sample type that measures the number of puffs the user takes from their inhaler.

HKQuantityTypeIdentifierInsulinDelivery

A quantity sample that measures the amount of insulin delivered.

HKQuantityTypeIdentifierNumberOfTimesFallen

A quantity sample type that measures the number of times the user has fallen.

HKQuantityTypeIdentifierPeakExpiratoryFlowRate

A quantity sample type that measures the user’s maximum flow rate generated during a forceful exhalation.

HKQuantityTypeIdentifierPeripheralPerfusionIndex

A quantity sample type that measures the user’s peripheral perfusion index.

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.

HKQuantityTypeIdentifierDistanceDownhillSnowSports

A quantity sample type that measures the distance the user has traveled while skiing or snowboarding.

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 spent exercising.

HKCategoryTypeIdentifierAppleStandHour

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

HKQuantityTypeIdentifierAppleStandTime

A quantity sample type that measures the amount of time the user has spent standing.

Beta

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.

Audio Exposure

HKCategoryTypeIdentifierAudioExposureEvent

A category sample type for audio exposure events.

Beta
HKQuantityTypeIdentifierEnvironmentalAudioExposure

A quantity sample type that measures audio exposure to sounds in the environment.

Beta
HKQuantityTypeIdentifierHeadphoneAudioExposure

A quantity sample type that measures audio exposure from headphones.

Beta

Self Care

HKCategoryTypeIdentifierToothbrushingEvent

A category sample type for toothbrushing.

Beta

Clinical Records

HKClinicalTypeIdentifier

Type identifiers for the different categories of clinical records.

Workouts

HKWorkoutTypeIdentifier

The workout type identifier.

HKWorkoutRouteTypeIdentifier

A series sample containing location data that defines the route the user took during a workout.

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.

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