---
title: heartRate
framework: healthkit
role: symbol
role_heading: Type Property
path: healthkit/hkquantitytypeidentifier/heartrate
---

# heartRate

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

## Declaration

```swift
static let heartRate: HKQuantityTypeIdentifier
```

## Mentioned in

Accessing condensed workout samples Running workout sessions

## Discussion

Discussion These samples use count/time units (described in HKUnit) and measure discrete values (described in HKQuantityAggregationStyle). Sample data may be condensed and/or coalesced by HealthKit. For more information, see Accessing condensed workout samples. Heart rate samples may include motion context information, which is stored as metadata using the HKMetadataKeyHeartRateMotionContext key. The value of this key is an NSNumber object that contains a HKHeartRateMotionContext value. The motion context gives additional information about the user’s activity level when the heart rate sample was taken. Apple Watch uses the following guidelines when setting the motion context: If the user has been still for at least 5 minutes prior to the sample, the context is set to the HKHeartRateMotionContext.sedentary value. If the user is in motion, the context is set to the HKHeartRateMotionContext.active value. You can add motion context to the metadata of any heart rate samples that you create. This means other apps may also save heart rate samples with (or without) the HKMetadataKeyHeartRateMotionContext metadata key. Note that not all heart rate samples have a motion context. For example, if Apple Watch cannot determine the motion context, it creates samples without a HKMetadataKeyHeartRateMotionContext metadata key. In addition, heart rate samples recorded by an Apple Watch (1st generation) or by a device running watchOS 3 or earlier do not have the motion context metadata key. Treat these samples as if they used the HKHeartRateMotionContext.notSet motion context.

## Topics

### Metadata Keys

- [HKMetadataKeyHeartRateSensorLocation](healthkit/hkmetadatakeyheartratesensorlocation.md)
- [HKMetadataKeyHeartRateMotionContext](healthkit/hkmetadatakeyheartratemotioncontext.md)

## See Also

### Related Documentation

- [HKQuantityTypeIdentifier](healthkit/hkquantitytypeidentifier.md)
- [HKQuantitySample](healthkit/hkquantitysample.md)
- [HKQuantity](healthkit/hkquantity.md)

### Vital signs

- [lowHeartRateEvent](healthkit/hkcategorytypeidentifier/lowheartrateevent.md)
- [highHeartRateEvent](healthkit/hkcategorytypeidentifier/highheartrateevent.md)
- [irregularHeartRhythmEvent](healthkit/hkcategorytypeidentifier/irregularheartrhythmevent.md)
- [restingHeartRate](healthkit/hkquantitytypeidentifier/restingheartrate.md)
- [heartRateVariabilitySDNN](healthkit/hkquantitytypeidentifier/heartratevariabilitysdnn.md)
- [heartRateRecoveryOneMinute](healthkit/hkquantitytypeidentifier/heartraterecoveryoneminute.md)
- [atrialFibrillationBurden](healthkit/hkquantitytypeidentifier/atrialfibrillationburden.md)
- [walkingHeartRateAverage](healthkit/hkquantitytypeidentifier/walkingheartrateaverage.md)
- [HKDataTypeIdentifierHeartbeatSeries](healthkit/hkdatatypeidentifierheartbeatseries.md)
- [HKElectrocardiogramType](healthkit/hkelectrocardiogramtype.md)
- [oxygenSaturation](healthkit/hkquantitytypeidentifier/oxygensaturation.md)
- [bodyTemperature](healthkit/hkquantitytypeidentifier/bodytemperature.md)
- [bloodPressure](healthkit/hkcorrelationtypeidentifier/bloodpressure.md)
- [bloodPressureSystolic](healthkit/hkquantitytypeidentifier/bloodpressuresystolic.md)
- [bloodPressureDiastolic](healthkit/hkquantitytypeidentifier/bloodpressurediastolic.md)
