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

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

class HKQuantityType

A type that identifies samples that store numerical values.

class HKCategoryType

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

class HKCorrelationType

A type that identifies samples that group multiple subsamples.

class HKActivitySummaryType

A type that identifies activity summary objects.

class HKAudiogramSampleType

A type that identifies samples that contain audiogram data.

Beta
class HKSeriesType

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

A type that identifies samples that contain clinical record data.

class HKWorkoutType

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

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.

let HKDataTypeIdentifierHeartbeatSeries: String

A series sample containing heartbeat data.

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

static let appleStandHour: HKCategoryTypeIdentifier

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

static let appleStandTime: HKQuantityTypeIdentifier

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

Beta

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.

Audio Exposure

static let audioExposureEvent: HKCategoryTypeIdentifier

A category sample type for audio exposure events.

Beta
static let environmentalAudioExposure: HKQuantityTypeIdentifier

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

Beta
static let headphoneAudioExposure: HKQuantityTypeIdentifier

A quantity sample type that measures audio exposure from headphones.

Beta

Self Care

static let toothbrushingEvent: HKCategoryTypeIdentifier

A category sample type for toothbrushing.

Beta

Clinical Records

struct HKClinicalTypeIdentifier

Type identifiers for the different categories of clinical records.

Workouts

let HKWorkoutTypeIdentifier: String

The workout type identifier.

let HKWorkoutRouteTypeIdentifier: String

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