Skip to main content

buildfire.services.health

The BuildFire Health Service allows plugins to query HealthKit and Google Fit data.

Requirements

Add Health Feature

In plugin.json, add {"name" : "health"} in your features array:

{
"author": "BuildFire",
"pluginName": "Example Plugin",
"pluginDescription": "Example Plugin JSON",
"supportEmail": "support@buildfire.com",
"control": {
"content": {
"enabled": true
},
"design": {
"enabled": true
},
"settings": {
"enabled": false
}
},
"widget": {
"enabled": true
},
"features": [{ "name": "health" }]
}

Widget

Include healthAPI.js file in your widget's <head>, right after buildfire.min.js

<head>
<script src="../../../scripts/buildfire.min.js"></script>
<script src="../../../scripts/buildfire/services/health/healthAPI.js"></script>
</head>
note

Google Fit uses Google Fit REST API services, thus a valid OAuth 2.0 Client ID must be obtained, and all the needed Google Fit scopes should be selected upon configuring the OAuth consent screen.

Methods

requestAuthorization()

function buildfire.services.health.requestAuthorization(dataTypes<Array>, callback<Function>)

Requests read and write access to a set of data types. This method must be called before using the query methods, even if the authorization has already been given at some point in the past.

Arguments

NameTypeRequiredDescriptionDefault
dataTypesArrayYesArray of data types you want to be granted access to. You can also specify read or write only permissions.N/A
callbackFunctionNoExecuted when the request is complete. Returns an error if something went wrong.N/A

dataTypes

NameTypeRequiredDescriptionDefault
STRING_VALUEStringN/AData type string to request. Grants read and write access.N/A
OBJECT_VALUEObjectN/AObject of separate read and write permissions.N/A

dataTypes[OBJECT_VALUE]

NameTypeRequiredDescriptionDefault
readArrayN/AArray of data type strings to request read access for.N/A
writeArrayN/AArray of data type strings to request write access for.N/A
warning

Currently, we only support reading data

callback(error<String>)

NameTypeDescription
errorStringerror string, null when operation is successful.

Example

// Data types to request read permission for
const dataTypes = [{
read: ['steps', 'height', 'weight']
}];

// Request permissions
buildfire.services.health.requestAuthorization(dataTypes, (err) => {
if (err) console.log(err);
});
info

For Android; If you haven't configured the APIs correctly - particularly the OAuth requirements - you are likely to get "User cancelled the dialog" as an error callback message. This often happens if you mismatch the signing certificate and SHA-1 fingerprint.


query()

function buildfire.services.health.query(options<Object>, callback<Function>)

Fetches all the data points of a certain data type within a certain time window.

Arguments

NameTypeRequiredDescriptionDefault
optionsObjectYesAn object that defines the search parametrs, along with the dataTypes to query.N/A
callbackFunctionNoReturns an array of result objects when the request is sucessful. Returns an error if something went wrong.N/A

options

NameTypeRequiredDescriptionDefault
dataTypestringyesData type to query. See Data Types.N/A
limitnumbernoSets a maximum number of returned values.1000
startDateDateyesStart date for the query.N/A
endDateDateyesEnd date for the query.N/A

callback(error<String>, results<Array>)

NameTypeDescription
errorStringError string, null when operation is successful.
resultsArrayArray of result objects.

results

NameTypeDescription
idStringUnique Identifier.
unitStringThe unit of measure.
valueNumberMeasured value.
sourceNameStringMeasuring device name.
sourceBundleIdStringMeasuring application bundleId.
sourceProductTypeStringMeasuring device product identifier (ex: iPhone 12,2).
sourceOSVersionStringMeasuring device OS version.
startDateStringStarting date string.
endDateStringEnding date string.
deviceNameStringName of the device that generated the data.
deviceModelStringModel of the device that generated the data.
deviceManufacturerStringManufacturer of the device that generated the data.
deviceHardwareVersionStringString representing the hardware version of the device.
deviceSoftwareVersionStringString representing the software version of the device.
deviceFirmwareVersionStringString representing the current version of the firmware running on the device.
metadataObjectMetadata object.

Example

const options = {
dataType: 'steps',
limit: 1000,
startDate: new Date(new Date().getTime() - 3 * 864e5),
endDate: new Date(),
};

buildfire.services.health.query(options, (error, results) => {
if (error) return console.error(error);

results.forEach(result => {
console.log(result);
});
});

queryAggregated()

function buildfire.services.health.queryAggregated(options<Object>, callback<Function>)

Fetches all the data points of a certain data type within a certain time window. Aggregates results into buckets.

Arguments

NameTypeRequiredDescriptionDefault
optionsObjectYesAn object that defines the search parametrs, along with the dataTypes to query.N/A
callbackFunctionNoReturns an array of result objects when the request is sucessful. Returns an error if something went wrong.N/A

options

NameTypeRequiredDescriptionDefault
dataTypeStringyesData type to query. See Supported Data Types.N/A
bucketStringnoTime scale to segment data by.N/A
startDateDateyesStart date for the query.N/A
endDateDateyesEnd date for the query.N/A

callback(error<String>, results<Array>)

NameTypeDescription
errorStringError string, null when operation is successful.
resultsArrayArray of results. If no bucket is passed, returns only the first object.

results

NameTypeDescription
unitStringThe unit of measure
valueNumberMeasured value
startDateStringStarting date string
endDateStringEnding date string

Example

const options = {
dataType: 'steps',
bucket: 'day',
startDate: new Date(new Date().getTime() - 3 * 864e5),
endDate: new Date(),
};

buildfire.services.health.queryAggregated(options, (error, results) => {
if (error) return console.error(error);

results.forEach(result => {
console.log(result);
});
});

Data Types

note
  • HealthKit supports wide range of medical data (e.g. blood glucose), whereas Google Fit focuses more on fitness data. However, Google Fit supports these medical data types

The Health service supports the following data types:

Body and Physical

Data TypeUnitHealthKit EquivalentGoogle Fit Equivalent
abdominal_crampsSeverityHKCategoryTypeIdentifierAbdominalCrampsN/A
acneSeverityHKCategoryTypeIdentifierAcneN/A
activityactivityTypeSee Supported ActivitesTYPE_ACTIVITY_SEGMENT
activitySummaryN/A
appetite_changesSeverityHKCategoryTypeIdentifierAppetiteChangesN/A
appleExerciseTimeminHKQuantityTypeIdentifierAppleExerciseTimeN/A
audio_exposure_eventN/AHKCategoryTypeIdentifierAudioExposureEventN/A
bladder_incontinenceSeverityHKCategoryTypeIdentifierBladderIncontinenceN/A
bloatingSeverityHKCategoryTypeIdentifierBloatingN/A
blood_alcohol_contentpercentHKQuantityTypeIdentifierBloodAlcoholContentN/A
blood_glucosemg/dLHKQuantityTypeIdentifierBloodGlucoseTYPE_BLOOD_GLUCOSE
blood_pressuremmHgHKCorrelationTypeIdentifierBloodPressureTYPE_BLOOD_PRESSURE
blood_pressure_diastolicmmHgHKQuantityTypeIdentifierBloodPressureDiastolicN/A
blood_pressure_systolicmmHgHKQuantityTypeIdentifierBloodPressureSystolicN/A
bmicountHKQuantityTypeIdentifierBodyMassIndexN/A
body_acheSeverityHKCategoryTypeIdentifierGeneralizedBodyAcheN/A
breast_painSeverityHKCategoryTypeIdentifierBreastPainN/A
calorieskcalHKQuantityTypeIdentifierActiveEnergyBurned + HKQuantityTypeIdentifierBasalEnergyBurnedTYPE_CALORIES_EXPENDED
calories.activekcalHKQuantityTypeIdentifierActiveEnergyBurnedTYPE_CALORIES_EXPENDED - (TYPE_BASAL_METABOLIC_RATE * time window)
calories.basalkcalHKQuantityTypeIdentifierBasalEnergyBurnedTYPE_BASAL_METABOLIC_RATE * time window
cervical_mucus_qualitySeverityHKCategoryTypeIdentifierCervicalMucusQualityN/A
chillsSeverityHKCategoryTypeIdentifierChillsN/A
constipationSeverityHKCategoryTypeIdentifierConstipationN/A
contraceptivesTypeHKCategoryTypeIdentifierContraceptiveN/A
coughingSeverityHKCategoryTypeIdentifierCoughingN/A
date_of_birthHKCharacteristicTypeIdentifierDateOfBirthN/A
diarrheaSeverityHKCategoryTypeIdentifierDiarrheaN/A
distancemHKQuantityTypeIdentifierDistanceWalkingRunning + HKQuantityTypeIdentifierDistanceCyclingTYPE_DISTANCE_DELTA
distance.walkingRunningmHKQuantityTypeIdentifierDistanceWalkingRunningN/A
distance.cyclingmHKQuantityTypeIdentifierDistanceCyclingN/A
distance.wheelchairmHKQuantityTypeIdentifierDistanceWheelchairN/A
dizzinessSeverityHKCategoryTypeIdentifierDizzinessN/A
dry_skinSeverityHKCategoryTypeIdentifierDrySkinN/A
electrocardiogramN/A
electrodermal_activitymcSHKQuantityTypeIdentifierElectrodermalActivityN/A
environmental_audio_exposuredBHKQuantityTypeIdentifierEnvironmentalAudioExposure // iOS 13+N/A
environmental_audio_exposure_eventN/AHKCategoryTypeIdentifierEnvironmentalAudioExposureEventN/A
faintingSeverityHKCategoryTypeIdentifierFaintingN/A
fat_percentage%HKQuantityTypeIdentifierBodyFatPercentageTYPE_BODY_FAT_PERCENTAGE
fatigueSeverityHKCategoryTypeIdentifierFatigueN/A
feverSeverityHKCategoryTypeIdentifierFeverN/A
flights_climbedcountHKQuantityTypeIdentifierFlightsClimbedN/A
forced_expiratory_volume1LHKQuantityTypeIdentifierForcedExpiratoryVolume1N/A
forced_vital_capacityLHKQuantityTypeIdentifierForcedVitalCapacityN/A
genderHKCharacteristicTypeIdentifierBiologicalSexN/A
hair_lossSeverityHKCategoryTypeIdentifierHairLossN/A
handwashing_eventN/AHKCategoryTypeIdentifierHandwashingEventN/A
headacheSeverityHKCategoryTypeIdentifierHeadacheN/A
headphone_audio_exposuredBHKQuantityTypeIdentifierHeadphoneAudioExposureN/A
headphone_audio_exposure_eventN/AHKCategoryTypeIdentifierHeadphoneAudioExposureEventN/A
heart_ratecount/minHKQuantityTypeIdentifierHeartRateTYPE_HEART_RATE_BPM
heart_rate_variability_sdnnmsHKQuantityTypeIdentifierHeartRateVariabilitySDNNN/A
heart_rate.restingcount/minHKQuantityTypeIdentifierRestingHearRateN/A
heart_rate.variabilitymsHKQuantityTypeIdentifierHeartRateVariabilitySDNNN/A
heartburnSeverityHKCategoryTypeIdentifierHeartburnN/A
heightmHKQuantityTypeIdentifierHeightTYPE_HEIGHT
high_heart_rate_eventN/AHKCategoryTypeIdentifierHighHeartRateEventN/A
hot_flashesSeverityHKCategoryTypeIdentifierHotFlashesN/A
inhaler_usagecountHKQuantityTypeIdentifierInhalerUsageN/A
insulinIUHKQuantityTypeIdentifierInsulinDeliveryN/A
intermenstrual_bleedingSeverityHKCategoryTypeIdentifierIntermenstrualBleedingN/A
irregular_heart_rhythm_eventN/AHKCategoryTypeIdentifierIrregularHeartRhythmEventN/A
lactationN/AHKCategoryTypeIdentifierLactationN/A
lean_body_masskgHKQuantityTypeIdentifierLeanBodyMassN/A
loss_of_smellSeverityHKCategoryTypeIdentifierLossOfSmellN/A
loss_of_tasteSeverityHKCategoryTypeIdentifierLossOfTasteN/A
low_cardio_eventN/AHKCategoryTypeIdentifierLowCardioFitnessEventN/A
low_heart_rate_eventN/AHKCategoryTypeIdentifierLowHeartRateEventN/A
lower_back_painSeverityHKCategoryTypeIdentifierLowerBackPainN/A
memory_lapseSeverityHKCategoryTypeIdentifierMemoryLapseN/A
menstrual_flowFlowHKCategoryTypeIdentifierMenstrualFlowN/A
mindfulnessminHKCategoryTypeIdentifierMindfulSessionN/A
mindfulnesssecHKCategoryTypeIdentifierMindfulSessionN/A
mood_changesSeverityHKCategoryTypeIdentifierMoodChangesN/A
nauseaSeverityHKCategoryTypeIdentifierNauseaN/A
night_sweatsSeverityHKCategoryTypeIdentifierNightSweatsN/A
number_of_alcoholic_beveragescountHKQuantityTypeIdentifierNumberOfAlcoholicBeveragesN/A
number_of_times_fallencountHKQuantityTypeIdentifierNumberOfTimesFallenN/A
nutritionHKCorrelationTypeIdentifierFoodTYPE_NUTRITION
nutrition.biotinmcgHKQuantityTypeIdentifierDietaryBiotinN/A
nutrition.caffeinegHKQuantityTypeIdentifierDietaryCaffeineN/A
nutrition.calciummgHKQuantityTypeIdentifierDietaryCalciumTYPE_NUTRITION, NUTRIENT_CALCIUM
nutrition.calorieskcalHKQuantityTypeIdentifierDietaryEnergyConsumedTYPE_NUTRITION, NUTRIENT_CALORIES
nutrition.carbs.totalgHKQuantityTypeIdentifierDietaryCarbohydratesTYPE_NUTRITION, NUTRIENT_TOTAL_CARBS
nutrition.chloridemgHKQuantityTypeIdentifierDietaryChlorideN/A
nutrition.cholesterolmgHKQuantityTypeIdentifierDietaryCholesterolTYPE_NUTRITION, NUTRIENT_CHOLESTEROL
nutrition.chromiummcgHKQuantityTypeIdentifierDietaryChromiumN/A
nutrition.coppermgHKQuantityTypeIdentifierDietaryCopperN/A
nutrition.dietary_fibergHKQuantityTypeIdentifierDietaryFiberTYPE_NUTRITION, NUTRIENT_DIETARY_FIBER
nutrition.fat.monounsaturatedgHKQuantityTypeIdentifierDietaryFatMonounsaturatedTYPE_NUTRITION, NUTRIENT_MONOUNSATURATED_FAT
nutrition.fat.polyunsaturatedgHKQuantityTypeIdentifierDietaryFatPolyunsaturatedTYPE_NUTRITION, NUTRIENT_POLYUNSATURATED_FAT
nutrition.fat.saturatedgHKQuantityTypeIdentifierDietaryFatSaturatedTYPE_NUTRITION, NUTRIENT_SATURATED_FAT
nutrition.fat.unsaturatedgN/ATYPE_NUTRITION, NUTRIENT_UNSATURATED_FAT
nutrition.fat.transgN/ATYPE_NUTRITION, NUTRIENT_TRANS_FAT (g)
nutrition.fat.totalgHKQuantityTypeIdentifierDietaryFatTotalTYPE_NUTRITION, NUTRIENT_TOTAL_FAT
nutrition.folatemcgHKQuantityTypeIdentifierDietaryFolateN/A
nutrition.iodinemcgHKQuantityTypeIdentifierDietaryIodineN/A
nutrition.ironmgHKQuantityTypeIdentifierDietaryIronTYPE_NUTRITION, NUTRIENT_IRON
nutrition.magnesiummgHKQuantityTypeIdentifierDietaryMagnesiumN/A
nutrition.molybdenummgHKQuantityTypeIdentifierDietaryMolybdenumN/A
nutrition.niacinmgHKQuantityTypeIdentifierDietaryNiacinN/A
nutrition.pantothenic_acidmgHKQuantityTypeIdentifierDietaryPantothenicAcidN/A
nutrition.phosphorusmgHKQuantityTypeIdentifierDietaryPhosphorusN/A
nutrition.potassiummgHKQuantityTypeIdentifierDietaryPotassiumTYPE_NUTRITION, NUTRIENT_POTASSIUM
nutrition.proteingHKQuantityTypeIdentifierDietaryProteinTYPE_NUTRITION, NUTRIENT_PROTEIN
nutrition.riboflavinmgHKQuantityTypeIdentifierDietaryRiboflavinN/A
nutrition.seleniummcgHKQuantityTypeIdentifierDietarySeleniumN/A
nutrition.sodiummgHKQuantityTypeIdentifierDietarySodiumTYPE_NUTRITION, NUTRIENT_SODIUM
nutrition.sugargHKQuantityTypeIdentifierDietarySugarTYPE_NUTRITION, NUTRIENT_SUGAR
nutrition.thiaminmgHKQuantityTypeIdentifierDietaryThiaminN/A
nutrition.vitamin_amcg (HK), IU (GF)HKQuantityTypeIdentifierDietaryVitaminATYPE_NUTRITION, NUTRIENT_VITAMIN_A
nutrition.vitamin_B12mcgHKQuantityTypeIdentifierDietaryVitaminB12N/A
nutrition.vitamin_B6mgHKQuantityTypeIdentifierDietaryVitaminB6N/A
nutrition.vitamin_cmgHKQuantityTypeIdentifierDietaryVitaminCTYPE_NUTRITION, NUTRIENT_VITAMIN_C
nutrition.vitamin_DmcgHKQuantityTypeIdentifierDietaryVitaminDN/A
nutrition.vitamin_EmgHKQuantityTypeIdentifierDietaryVitaminEN/A
nutrition.vitamin_KmcgHKQuantityTypeIdentifierDietaryVitaminKN/A
nutrition.watermlHKQuantityTypeIdentifierDietaryWaterTYPE_HYDRATION
nutrition.zincmgHKQuantityTypeIdentifierDietaryZincN/A
ovulation_test_resultResultHKCategoryTypeIdentifierOvulationTestResultN/A
oxygen_saturation%HKQuantityTypeIdentifierOxygenSaturationTYPE_OXYGEN_SATURATION
peak_expiratory_flow_rateL/minHKQuantityTypeIdentifierPeakExpiratoryFlowRateN/A
pelvic_painSeverityHKCategoryTypeIdentifierPelvicPainN/A
peripheral_perfusion_indexpercentHKQuantityTypeIdentifierPeripheralPerfusionIndexN/A
pregnancyN/AHKCategoryTypeIdentifierPregnancyN/A
pregnancy_test_resultResultHKCategoryTypeIdentifierPregnancyTestResultN/A
progesterone_test_resultResultHKCategoryTypeIdentifierProgesteroneTestResultN/A
rapid_or_fluttering_heartbeatSeverityHKCategoryTypeIdentifierRapidPoundingOrFlutteringHeartbeatN/A
resp_ratecount/minHKQuantityTypeIdentifierRespiratoryRateN/A
runny_noseSeverityHKCategoryTypeIdentifierRunnyNoseN/A
sexual_activityN/AHKCategoryTypeIdentifierSexualActivityN/A
shortness_of_breathSeverityHKCategoryTypeIdentifierShortnessOfBreathN/A
sinus_congestionSeverityHKCategoryTypeIdentifierSinusCongestionN/A
six_minute_walk_test_distancemHKQuantityTypeIdentifierSixMinuteWalkTestDistanceN/A
skipped_heartbeatSeverityHKCategoryTypeIdentifierSkippedHeartbeatN/A
sleepN/AHKCategoryTypeIdentifierSleepAnalysisTYPE_ACTIVITY_SEGMENT (and/or sleep sessions)
sleep_changesSeverityHKCategoryTypeIdentifierSleepChangesN/A
sore_throatSeverityHKCategoryTypeIdentifierSoreThroatN/A
stair_ascent_speedm/sHKQuantityTypeIdentifierStairAscentSpeedN/A
stair_descent_speedm/sHKQuantityTypeIdentifierStairDescentSpeedN/A
stairscountHKQuantityTypeIdentifierFlightsClimbedN/A
stand_timesHKQuantityTypeIdentifierDietaryVitaminEN/A
stepscountHKQuantityTypeIdentifierStepCountTYPE_STEP_COUNT_DELTA
temperatureCelsiusHKQuantityTypeIdentifierBodyTemperatureN/A
temperature.basaldegCHKQuantityTypeIdentifierBasalBodyTemperatureN/A
tightness_or_painSeverityHKCategoryTypeIdentifierChestTightnessOrPainN/A
toothbrushing_eventN/AHKCategoryTypeIdentifierToothbrushingEventN/A
uv_exposurecountHKQuantityTypeIdentifierUVExposureN/A
vaginal_drynessSeverityHKCategoryTypeIdentifierVaginalDrynessN/A
vo2maxml/(kg * min)HKQuantityTypeIdentifierVO2MaxN/A
vomitingSeverityHKCategoryTypeIdentifierVomitingN/A
waist_circumferencemHKQuantityTypeIdentifierWaistCircumferenceN/A
walking_asymmetry_percentagepercentHKQuantityTypeIdentifierWalkingAsymmetryPercentageN/A
walking_double_support_percentagepercentHKQuantityTypeIdentifierWalkingDoubleSupportPercentageN/A
walking_speedm/sHKQuantityTypeIdentifierWalkingSpeedN/A
walking_steadinesspercentHKQuantityTypeIdentifierAppleWalkingSteadinessN/A
walking_steadiness_eventN/AHKCategoryTypeIdentifierAppleWalkingSteadinessEventN/A
walking_step_lengthcmHKQuantityTypeIdentifierWalkingStepLengthN/A
weightkgHKQuantityTypeIdentifierBodyMassTYPE_WEIGHT
wheezingSeverityHKCategoryTypeIdentifierWheezingN/A

Activities

Activity NameHealthKit EquivalentGoogle Fit Equivalent
archeryHKWorkoutActivityTypeArcheryN/A
badmintonHKWorkoutActivityTypeBadmintonBADMINTON
barreHKWorkoutActivityTypeBarreN/A
baseballHKWorkoutActivityTypeBaseballBASEBALL
basketballHKWorkoutActivityTypeBasketballBASKETBALL
bikingHKWorkoutActivityTypeCyclingBIKING
biking.handHKWorkoutActivityTypeHandCyclingBIKING_HAND
biking.mountainHKWorkoutActivityTypeCyclingBIKING_MOUNTAIN
biking.roadHKWorkoutActivityTypeCyclingBIKING_ROAD
biking.spinningHKWorkoutActivityTypeCyclingBIKING_SPINNING
biking.stationaryHKWorkoutActivityTypeCyclingBIKING_STATIONARY
biking.utilityHKWorkoutActivityTypeCyclingBIKING_UTILITY
bowlingHKWorkoutActivityTypeBowlingN/A
boxingHKWorkoutActivityTypeBoxingBOXING
cooldownHKWorkoutActivityTypeCooldownN/A
core_trainingHKWorkoutActivityTypeCoreTrainingSTRENGTH_TRAINING
cricketHKWorkoutActivityTypeCricketCRICKET
crossfitHKWorkoutActivityTypeCrossTrainingCROSSFIT
curlingHKWorkoutActivityTypeCurlingCURLING
dancingHKWorkoutActivityTypeCardioDanceDANCING
dancing.socialHKWorkoutActivityTypeSocialDanceN/A
disc_sportsHKWorkoutActivityTypeDiscSportsN/A
divingHKWorkoutActivityTypeWaterSportsDIVING
ellipticalHKWorkoutActivityTypeEllipticalELLIPTICAL
fencingHKWorkoutActivityTypeFencingFENCING
fishingHKWorkoutActivityTypeFishingN/A
fitness_gamingHKWorkoutActivityTypeFitnessGamingN/A
flexibilityHKWorkoutActivityTypeFlexibilityGYMNASTICS
football.americanKWorkoutActivityTypeAmericanFootballFOOTBALL_AMERICAN
football.australianHKWorkoutActivityTypeAustralianFootballFOOTBALL_AUSTRALIAN
football.soccerHKWorkoutActivityTypeSoccerFOOTBALL_SOCCER
functional_strengthHKWorkoutActivityTypeFunctionalStrengthTrainingN/A
golfHKWorkoutActivityTypeGolfGOLF
gymnasticsHKWorkoutActivityTypeGymnasticsGYMNASTICS
handballKWorkoutActivityTypeHandballHANDBALL
hikingHKWorkoutActivityTypeHikingHIKING
hockeyHKWorkoutActivityTypeHockeyHOCKEY
horseback_ridingHKWorkoutActivityTypeEquestrianSportsHORSEBACK_RIDING
huntingHKWorkoutActivityTypeHuntingN/A
ice_skatingHKWorkoutActivityTypeSkatingSportsice_skating
interval_trainingHKWorkoutActivityTypeHighIntensityIntervalTrainingINTERVAL_TRAINING
interval_training.high_intensityHKWorkoutActivityTypeHighIntensityIntervalTrainingHIGH_INTENSITY_INTERVAL_TRAINING
jump_ropeHKWorkoutActivityTypeJumpRopeJUMP_ROPE
kayakingHKWorkoutActivityTypePaddleSportsKAYAKING
kick_scooterHKWorkoutActivityTypeCyclingKICK_SCOOTER
kickboxingHKWorkoutActivityTypeKickboxingKICKBOXING
lacrosseHKWorkoutActivityTypeLacrosseN/A
martial_artsHKWorkoutActivityTypeMartialArtsMARTIAL_ARTS
martial_arts.mixedHKWorkoutActivityTypeMartialArtsMIXED_MARTIAL_ARTS
meditationHKWorkoutActivityTypeMindAndBodyMEDITATION
mixed_metabolic_cardioHKWorkoutActivityTypeMixedCardioN/A
otherHKWorkoutActivityTypeOtherOTHER
paddle_sportsHKWorkoutActivityTypePaddleSportsN/A
pickleballHKWorkoutActivityTypePickleballN/A
pilatesHKWorkoutActivityTypePilatesPILATES
playHKWorkoutActivityTypePlayN/A
preparation_and_recoveryHKWorkoutActivityTypePreparationAndRecoveryN/A
racquetballHKWorkoutActivityTypeRacquetballRACQUETBALL
rock_climbingHKWorkoutActivityTypeClimbingROCK_CLIMBING
rowingHKWorkoutActivityTypeRowingROWING
rowing.machineHKWorkoutActivityTypeRowingROWING_MACHINE
rugbyHKWorkoutActivityTypeRugbyRUGBY
runningHKWorkoutActivityTypeRunningRUNNING
running.joggingHKWorkoutActivityTypeRunningRUNNING_JOGGING
running.sandHKWorkoutActivityTypeRunningRUNNING_SAND
running.treadmillHKWorkoutActivityTypeRunningRUNNING_TREADMILL
sailingHKWorkoutActivityTypeSailingSAILING
scuba_divingHKWorkoutActivityTypeWaterSportsSCUBA_DIVING
skateboardingHKWorkoutActivityTypeSkatingSportsSKATEBOARDING
skatingHKWorkoutActivityTypeSkatingSportsSKATING
skating.crossHKWorkoutActivityTypeSkatingSportsSKATING_CROSS
skating.indoorHKWorkoutActivityTypeSkatingSportsSKATING_INDOOR
skating.inlineHKWorkoutActivityTypeSkatingSportsSKATING_INLINE
skiingHKWorkoutActivityTypeSnowSportsSKIING
skiing.back_countryHKWorkoutActivityTypeSnowSportsSKIING_BACK_COUNTRY
skiing.cross_countryHKWorkoutActivityTypeCrossCountrySkiingSKIING_CROSS_COUNTRY
skiing.downhillHKWorkoutActivityTypeDownhillSkiingSKIING_DOWNHILL
skiing.kiteHKWorkoutActivityTypeSnowSportsSKIING_KITE
skiing.rollerHKWorkoutActivityTypeSnowSportsSKIING_ROLLER
sleddingHKWorkoutActivityTypeSnowSportsSLEDDING
sleepHKCategoryValueSleepAnalysisAsleepSLEEP
sleep.awakeHKCategoryValueSleepAnalysisAwakeN/A
sleep.deepHKCategoryValueSleepAnalysisAsleepSLEEP_DEEP
sleep.inBedHKCategoryValueSleepAnalysisInBedN/A
sleep.lightHKCategoryValueSleepAnalysisAsleepSLEEP_LIGHT
sleep.remHKCategoryValueSleepAnalysisAsleepSLEEP_REM
snow_sportsHKWorkoutActivityTypeSnowSportsN/A
snowboardingHKWorkoutActivityTypeSnowboardingSNOWBOARDING
snowmobileHKWorkoutActivityTypeSnowSportsSNOWMOBILE
snowshoeingHKWorkoutActivityTypeSnowSportsSNOWSHOEING
softballHKWorkoutActivityTypeSoftballN/A
squashHKWorkoutActivityTypeSquashSQUASH
stair_climbingHKWorkoutActivityTypeStairClimbingSTAIR_CLIMBING
stair_climbing.machineHKWorkoutActivityTypeStepTrainingSTAIR_CLIMBING_MACHINE
stairsHKWorkoutActivityTypeStairsSTAIR_CLIMBING
standup_paddleboardingHKWorkoutActivityTypePaddleSportsSTANDUP_PADDLEBOARDING
strength_trainingHKWorkoutActivityTypeTraditionalStrengthTrainingSTRENGTH_TRAINING
surfingHKWorkoutActivityTypeSurfingSportsSURFING
swimmingHKWorkoutActivityTypeSwimmingSWIMMING
swimming.open_waterHKWorkoutActivityTypeSwimmingSWIMMING_OPEN_WATER
swimming.poolHKWorkoutActivityTypeSwimmingSWIMMING_POOL
table_tennisHKWorkoutActivityTypeTableTennisTABLE_TENNIS
tai_chiHKWorkoutActivityTypeTaiChiN/A
tennisHKWorkoutActivityTypeTennisTENNIS
track_and_fieldHKWorkoutActivityTypeTrackAndFieldRUNNING
volleyballHKWorkoutActivityTypeVolleyballVOLLEYBALL
volleyball.beachHKWorkoutActivityTypeVolleyballVOLLEYBALL_BEACH
volleyball.indoorHKWorkoutActivityTypeVolleyballVOLLEYBALL_INDOOR
wakeboardingHKWorkoutActivityTypeWaterSportsWAKEBOARDING
walkingHKWorkoutActivityTypeWalkingWALKING
walking.fitnessHKWorkoutActivityTypeWalkingWALKING_FITNESS
walking.nordicHKWorkoutActivityTypeWalkingWALKING_NORDIC
walking.strollerHKWorkoutActivityTypeWalkingWALKING_STROLLER
walking.treadmillHKWorkoutActivityTypeWalkingWALKING_TREADMILL
water_fitnessHKWorkoutActivityTypeWaterFitnessN/A
water_poloHKWorkoutActivityTypeWaterPoloWATER_POLO
water_sportsHKWorkoutActivityTypeWaterSportsN/A
weightliftingHKWorkoutActivityTypeTraditionalStrengthTrainingWEIGHTLIFTING
wheelchairHKWorkoutActivityTypeWheelchairRunPaceWHEELCHAIR
wheelchair.runpaceHKWorkoutActivityTypeWheelchairRunPaceWHEELCHAIR
wheelchair.walkpaceHKWorkoutActivityTypeWheelchairWalkPaceWHEELCHAIR
windsurfingHKWorkoutActivityTypeWaterSportsWINDSURFING
wrestlingHKWorkoutActivityTypeWrestlingN/A
yogaHKWorkoutActivityTypeYogaYOGA

Electrocardiograms (iOS Only)

The health service can query for electrocardiogram as a data type. Electrocardiogram samples contain the following data:

NameTypeDescription
algorithmVersionNumberVersion numbers for the algorithm Apple Watch uses to generate an ECG reading
averageHeartRateNumberAverage heart rate over ECG duration
classificationStringECG’s classification (ex: "SinusRhythm")
samplingFrequencyNumberThe frequency at which the voltage is sampled
voltageMeasurementsArrayCollection of voltage values representing waveforms
{
id: "ECF3C1B4-AEFA-4656-B7F2-B110951835EA",
startDate: "2021-06-06T11:11:43.000Z",
endDate: "2021-06-06T11:12:13.000Z",
algorithmVersion: 1,
averageHeartRate: 62,
classification: "SinusRhythm",
samplingFrequency: 513.7265625,
sourceName: "ECG",
sourceBundleId: "com.apple.NanoHeartRhythm",
sourceProductType: "Watch5,4",
sourceOSVersion: "7.4.1",
deviceName: "Apple Watch",
deviceModel: "Watch",
deviceManufacturer: "Apple Inc.",
deviceLocalIdentifier: "",
deviceHardwareVersion: "Watch5,4",
deviceSoftwareVersion: "7.4.1",
deviceFirmwareVersion: "",
voltageMeasurements: [
[0,-0.00016570074462890624],
[0.0019465608224219476,-0.00019473405456542969],
[0.003893121644843895,-0.00021828952026367186],
[0.005839682467265842,-0.00023469168090820312],
[0.00778624328968779,-0.00024280212402343749]
// ...
]
}