Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/kingstinct/react-native-healthkit/llms.txt

Use this file to discover all available pages before exploring further.

Overview

HealthKit samples represent health and fitness data points. Each sample type extends the base sample structure and includes type-specific properties. Samples are the fundamental data structures returned by HealthKit queries.

BaseSample

Base interface inherited by all sample types.
interface BaseSample extends BaseObject {
  sampleType: SampleType
  startDate: Date
  endDate: Date
  hasUndeterminedDuration: boolean
  
  // Metadata fields
  metadataWeatherCondition?: WeatherCondition
  metadataWeatherHumidity?: Quantity
  metadataWeatherTemperature?: Quantity
  metadataInsulinDeliveryReason?: InsulinDeliveryReason
  metadataHeartRateMotionContext?: HeartRateMotionContext
}
sampleType
SampleType
required
The type of sample, including metadata about restrictions and capabilities.
startDate
Date
required
The start date and time of the sample.
endDate
Date
required
The end date and time of the sample.
hasUndeterminedDuration
boolean
required
Whether the sample has an undetermined duration.

Inherited from BaseObject

uuid
string
required
Unique identifier for the sample.
sourceRevision
SourceRevision
required
Information about the source that created this sample.
device
Device
The device that recorded this sample.
metadata
AnyMap
required
Raw metadata dictionary containing additional information.

QuantitySample

Represents a sample with a numerical value and unit.
interface QuantitySample extends BaseSample {
  quantityType: QuantityTypeIdentifier
  quantity: number
  unit: string
}
quantityType
QuantityTypeIdentifier
required
The type of quantity (e.g., 'HKQuantityTypeIdentifierStepCount', 'HKQuantityTypeIdentifierHeartRate').
quantity
number
required
The numerical value of the sample.
unit
string
required
The unit of measurement (e.g., 'count', 'count/min'). See Units for details.

Example

const heartRateSample: QuantitySample = {
  uuid: '12345-abcde',
  quantityType: 'HKQuantityTypeIdentifierHeartRate',
  quantity: 72,
  unit: 'count/min',
  startDate: new Date('2024-03-01T10:00:00Z'),
  endDate: new Date('2024-03-01T10:00:00Z'),
  // ... other BaseSample fields
}

QuantitySampleForSaving

Structure for creating new quantity samples.
interface QuantitySampleForSaving {
  startDate: Date
  endDate: Date
  quantityType: QuantityTypeIdentifier
  quantity: number
  unit: string
  metadata?: AnyMap
  sourceRevision?: SourceRevision
}

Example

const newStepsSample: QuantitySampleForSaving = {
  startDate: new Date('2024-03-01T10:00:00Z'),
  endDate: new Date('2024-03-01T11:00:00Z'),
  quantityType: 'HKQuantityTypeIdentifierStepCount',
  quantity: 1000,
  unit: 'count',
  metadata: {
    HKWasUserEntered: true
  }
}

CategorySample

Represents categorical data with predefined values.
interface CategorySample extends BaseSample {
  categoryType: CategoryTypeIdentifier
  value: CategoryValue
}
categoryType
CategoryTypeIdentifier
required
The category type identifier (e.g., 'HKCategoryTypeIdentifierSleepAnalysis').
value
CategoryValue
required
The categorical value. Type depends on the category type (see CategoryValue).

CategoryValue

Category values vary by type:
type CategoryValue =
  | CategoryValueAppetiteChanges
  | CategoryValueCervicalMucusQuality
  | CategoryValueMenstrualFlow
  | CategoryValueOvulationTestResult
  | CategoryValuePresence
  | CategoryValueSeverity
  | CategoryValueSleepAnalysis
  | number

CategoryValueSleepAnalysis

enum CategoryValueSleepAnalysis {
  inBed = 0,
  asleepUnspecified = 1,
  awake = 2,
  asleepCore = 3,
  asleepDeep = 4,
  asleepREM = 5,
}

CategoryValueSeverity

enum CategoryValueSeverity {
  notPresent = 1,
  mild = 2,
  moderate = 3,
  severe = 4,
  unspecified = 0,
}

CategoryValuePresence

enum CategoryValuePresence {
  notPresent = 1,
  present = 0,
}

Example

const sleepSample: CategorySample = {
  uuid: '67890-fghij',
  categoryType: 'HKCategoryTypeIdentifierSleepAnalysis',
  value: CategoryValueSleepAnalysis.asleepDeep,
  startDate: new Date('2024-03-01T23:00:00Z'),
  endDate: new Date('2024-03-02T07:00:00Z'),
  // ... other BaseSample fields
}

WorkoutSample

Represents a workout or physical activity session.
interface WorkoutSample extends BaseSample {
  workoutActivityType: WorkoutActivityType
  duration: Quantity
  totalEnergyBurned?: Quantity
  totalDistance?: Quantity
  totalSwimmingStrokeCount?: Quantity
  totalFlightsClimbed?: Quantity
  events?: readonly WorkoutEvent[]
  activities?: readonly WorkoutActivity[]
  
  // Metadata
  metadataAverageMETs?: Quantity
  metadataElevationAscended?: Quantity
  metadataElevationDescended?: Quantity
  metadataIndoorWorkout?: boolean
  metadataAverageSpeed?: Quantity
  metadataMaximumSpeed?: Quantity
}
workoutActivityType
WorkoutActivityType
required
The type of workout activity. See WorkoutActivityType.
duration
Quantity
required
The total duration of the workout.
totalEnergyBurned
Quantity
Total energy burned during the workout (typically in kilocalories).
totalDistance
Quantity
Total distance covered during the workout.
events
WorkoutEvent[]
Array of events that occurred during the workout (e.g., pause, resume, lap markers).

WorkoutActivityType

Enum representing types of physical activities:
enum WorkoutActivityType {
  running = 37,
  walking = 52,
  cycling = 13,
  swimming = 46,
  yoga = 57,
  functionalStrengthTraining = 20,
  highIntensityIntervalTraining = 63,
  // ... and many more
}
Common activity types include:
  • running - Running workouts
  • walking - Walking workouts
  • cycling - Cycling workouts
  • swimming - Swimming workouts
  • yoga - Yoga sessions
  • functionalStrengthTraining - Free weights and bodyweight exercises
  • highIntensityIntervalTraining - HIIT workouts

WorkoutEvent

interface WorkoutEvent {
  type: WorkoutEventType
  startDate: Date
  endDate: Date
}

enum WorkoutEventType {
  pause = 1,
  resume = 2,
  lap = 3,
  marker = 4,
  motionPaused = 5,
  motionResumed = 6,
  segment = 7,
  pauseOrResumeRequest = 8,
}

Example

const runSample: WorkoutSample = {
  uuid: 'abc-123',
  workoutActivityType: WorkoutActivityType.running,
  duration: { quantity: 1800, unit: 's' }, // 30 minutes
  totalDistance: { quantity: 5000, unit: 'm' }, // 5 km
  totalEnergyBurned: { quantity: 300, unit: 'kcal' },
  startDate: new Date('2024-03-01T06:00:00Z'),
  endDate: new Date('2024-03-01T06:30:00Z'),
  events: [
    {
      type: WorkoutEventType.lap,
      startDate: new Date('2024-03-01T06:10:00Z'),
      endDate: new Date('2024-03-01T06:10:00Z')
    }
  ],
  // ... other BaseSample fields
}

CorrelationSample

Represents a correlation between multiple related samples.
interface CorrelationSample extends BaseSample {
  correlationType: CorrelationTypeIdentifier
  objects: readonly (CategorySample | QuantitySample)[]
  metadataFoodType?: string
}
correlationType
CorrelationTypeIdentifier
required
The type of correlation. Common values:
  • 'HKCorrelationTypeIdentifierBloodPressure' - Blood pressure (systolic/diastolic)
  • 'HKCorrelationTypeIdentifierFood' - Food intake with nutritional data
objects
(CategorySample | QuantitySample)[]
required
Array of related samples that make up this correlation.
metadataFoodType
string
For food correlations, the type of food consumed.

Example: Blood Pressure

const bloodPressure: CorrelationSample = {
  uuid: 'bp-12345',
  correlationType: 'HKCorrelationTypeIdentifierBloodPressure',
  objects: [
    {
      // Systolic pressure
      quantityType: 'HKQuantityTypeIdentifierBloodPressureSystolic',
      quantity: 120,
      unit: 'mmHg',
      // ... other fields
    },
    {
      // Diastolic pressure
      quantityType: 'HKQuantityTypeIdentifierBloodPressureDiastolic',
      quantity: 80,
      unit: 'mmHg',
      // ... other fields
    }
  ],
  startDate: new Date('2024-03-01T08:00:00Z'),
  endDate: new Date('2024-03-01T08:00:00Z'),
  // ... other BaseSample fields
}

ElectrocardiogramSample

Represents an ECG recording sample.
interface ElectrocardiogramSample extends BaseSample {
  classification: ElectrocardiogramClassification
  symptomsStatus: ElectrocardiogramSymptomsStatus
  averageHeartRateBpm?: number
  samplingFrequencyHz?: number
  numberOfVoltageMeasurements: number
  voltages?: readonly ElectrocardiogramVoltage[]
}
classification
ElectrocardiogramClassification
required
The ECG classification result:
  • 'notSet' - No classification
  • 'sinusRhythm' - Normal sinus rhythm
  • 'atrialFibrillation' - AFib detected
  • 'inconclusiveLowHeartRate' - Inconclusive due to low heart rate
  • 'inconclusiveHighHeartRate' - Inconclusive due to high heart rate
  • 'inconclusivePoorReading' - Inconclusive due to poor signal quality
  • 'inconclusiveOther' - Inconclusive for other reasons
symptomsStatus
ElectrocardiogramSymptomsStatus
required
Whether symptoms were present:
  • 'notSet' - Not specified
  • 'none' - No symptoms
  • 'present' - Symptoms present
averageHeartRateBpm
number
Average heart rate in beats per minute.
voltages
ElectrocardiogramVoltage[]
Array of voltage measurements. Only included if requested in query options.

Example

const ecgSample: ElectrocardiogramSample = {
  uuid: 'ecg-456',
  classification: 'sinusRhythm',
  symptomsStatus: 'none',
  averageHeartRateBpm: 68,
  samplingFrequencyHz: 512,
  numberOfVoltageMeasurements: 15360,
  startDate: new Date('2024-03-01T12:00:00Z'),
  endDate: new Date('2024-03-01T12:00:30Z'),
  // ... other BaseSample fields
}

DeletedSample

Represents a deleted sample in anchor-based queries.
interface DeletedSample {
  uuid: string
  metadata?: AnyMap
}
uuid
string
required
The UUID of the deleted sample.
metadata
AnyMap
Metadata associated with the deleted sample.

Common Response Types

Most query methods return results with both samples and deletion information:
interface QuantitySamplesWithAnchorResponse {
  samples: readonly QuantitySample[]
  deletedSamples: readonly DeletedSample[]
  newAnchor: string
}

interface CategorySamplesWithAnchorResponse {
  samples: readonly CategorySample[]
  deletedSamples: readonly DeletedSample[]
  newAnchor: string
}

interface QueryWorkoutSamplesWithAnchorResponse {
  workouts: readonly WorkoutProxy[]
  deletedSamples: readonly DeletedSample[]
  newAnchor: string
}

Build docs developers (and LLMs) love