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

class HKCharacteristicType

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

class HKQuantityType

Quantity types identify samples that store numerical values.

class HKCategoryType

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

class HKCorrelationType

Correlation types identify samples that group multiple subsamples.

class HKActivitySummaryType

Activity summary types identify activity summary objects.

class HKSeriesType

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

class HKObjectType

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

class HKSampleType

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

class HKClinicalType

Clinical types identify samples that contain clinical record data.

Characteristic Identifiers

static let biologicalSex: HKCharacteristicTypeIdentifier

A characteristic type identifier for the user’s sex.

static let bloodType: HKCharacteristicTypeIdentifier

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

static let dateOfBirth: HKCharacteristicTypeIdentifier

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

static let fitzpatrickSkinType: HKCharacteristicTypeIdentifier

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

static let wheelchairUse: HKCharacteristicTypeIdentifier

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

Body Measurements

static let height: HKQuantityTypeIdentifier

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

static let bodyMass: HKQuantityTypeIdentifier

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

static let bodyMassIndex: HKQuantityTypeIdentifier

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

static let leanBodyMass: HKQuantityTypeIdentifier

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

static let bodyFatPercentage: HKQuantityTypeIdentifier

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

static let waistCircumference: HKQuantityTypeIdentifier

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

Vital Signs

static let heartRate: HKQuantityTypeIdentifier

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

static let lowHeartRateEvent: HKCategoryTypeIdentifier

A category sample type for low heart rate events.

static let highHeartRateEvent: HKCategoryTypeIdentifier

A category sample type for high heart rate events.

static let irregularHeartRhythmEvent: HKCategoryTypeIdentifier

A category sample type for irregular heart rhythm events.

static let restingHeartRate: HKQuantityTypeIdentifier

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

static let heartRateVariabilitySDNN: HKQuantityTypeIdentifier

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

static let walkingHeartRateAverage: HKQuantityTypeIdentifier

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

static let oxygenSaturation: HKQuantityTypeIdentifier

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

static let bodyTemperature: HKQuantityTypeIdentifier

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

static let bloodPressure: HKCorrelationTypeIdentifier

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

static let bloodPressureSystolic: HKQuantityTypeIdentifier

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

static let bloodPressureDiastolic: HKQuantityTypeIdentifier

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

static let respiratoryRate: HKQuantityTypeIdentifier

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

static let vo2Max: HKQuantityTypeIdentifier

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

Lab and Test Results

static let bloodAlcoholContent: HKQuantityTypeIdentifier

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

static let bloodGlucose: HKQuantityTypeIdentifier

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

static let electrodermalActivity: HKQuantityTypeIdentifier

A quantity sample type that measures electrodermal activity.

static let forcedExpiratoryVolume1: HKQuantityTypeIdentifier

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.

static let forcedVitalCapacity: HKQuantityTypeIdentifier

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

static let inhalerUsage: HKQuantityTypeIdentifier

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

static let insulinDelivery: HKQuantityTypeIdentifier

A quantity sample that measures the amount of insulin delivered.

static let numberOfTimesFallen: HKQuantityTypeIdentifier

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

static let peakExpiratoryFlowRate: HKQuantityTypeIdentifier

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

static let peripheralPerfusionIndex: HKQuantityTypeIdentifier

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

static let mindfulSession: HKCategoryTypeIdentifier

A category sample type for recording a mindful session.

static let sleepAnalysis: HKCategoryTypeIdentifier

A category sample type for sleep analysis information.

Activity

static let stepCount: HKQuantityTypeIdentifier

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

static let distanceWalkingRunning: HKQuantityTypeIdentifier

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

static let distanceCycling: HKQuantityTypeIdentifier

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

static let pushCount: HKQuantityTypeIdentifier

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

static let distanceWheelchair: HKQuantityTypeIdentifier

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

static let swimmingStrokeCount: HKQuantityTypeIdentifier

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

static let distanceSwimming: HKQuantityTypeIdentifier

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

static let distanceDownhillSnowSports: HKQuantityTypeIdentifier

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

static let basalEnergyBurned: HKQuantityTypeIdentifier

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

static let activeEnergyBurned: HKQuantityTypeIdentifier

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

static let flightsClimbed: HKQuantityTypeIdentifier

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

static let nikeFuel: HKQuantityTypeIdentifier

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

static let appleExerciseTime: HKQuantityTypeIdentifier

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

static let appleStandHour: HKCategoryTypeIdentifier

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

Reproductive Health

static let sexualActivity: HKCategoryTypeIdentifier

A category sample type for recording sexual activity.

static let intermenstrualBleeding: HKCategoryTypeIdentifier

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

static let menstrualFlow: HKCategoryTypeIdentifier

A category sample type for representing menstrual cycles.

static let ovulationTestResult: HKCategoryTypeIdentifier

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

static let cervicalMucusQuality: HKCategoryTypeIdentifier

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

static let basalBodyTemperature: HKQuantityTypeIdentifier

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

UV Exposure

static let uvExposure: HKQuantityTypeIdentifier

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

Clinical Records

struct HKClinicalTypeIdentifier

Type identifiers for the different categories of clinical records.

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.