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>
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
Name | Type | Required | Description | Default |
---|---|---|---|---|
dataTypes | Array | Yes | Array of data types you want to be granted access to. You can also specify read or write only permissions. | N/A |
callback | Function | No | Executed when the request is complete. Returns an error if something went wrong. | N/A |
dataTypes
Name | Type | Required | Description | Default |
---|---|---|---|---|
STRING_VALUE | String | N/A | Data type string to request. Grants read and write access. | N/A |
OBJECT_VALUE | Object | N/A | Object of separate read and write permissions. | N/A |
dataTypes[OBJECT_VALUE]
Name | Type | Required | Description | Default |
---|---|---|---|---|
read | Array | N/A | Array of data type strings to request read access for. | N/A |
write | Array | N/A | Array of data type strings to request write access for. | N/A |
Currently, we only support reading data
callback(error<String>)
Name | Type | Description |
---|---|---|
error | String | error 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);
});
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
Name | Type | Required | Description | Default |
---|---|---|---|---|
options | Object | Yes | An object that defines the search parametrs, along with the dataTypes to query. | N/A |
callback | Function | No | Returns an array of result objects when the request is sucessful. Returns an error if something went wrong. | N/A |
options
Name | Type | Required | Description | Default |
---|---|---|---|---|
dataType | string | yes | Data type to query. See Data Types. | N/A |
limit | number | no | Sets a maximum number of returned values. | 1000 |
startDate | Date | yes | Start date for the query. | N/A |
endDate | Date | yes | End date for the query. | N/A |
callback(error<String>, results<Array>)
Name | Type | Description |
---|---|---|
error | String | Error string, null when operation is successful. |
results | Array | Array of result objects. |
results
Name | Type | Description |
---|---|---|
id | String | Unique Identifier. |
unit | String | The unit of measure. |
value | Number | Measured value. |
sourceName | String | Measuring device name. |
sourceBundleId | String | Measuring application bundleId. |
sourceProductType | String | Measuring device product identifier (ex: iPhone 12,2). |
sourceOSVersion | String | Measuring device OS version. |
startDate | String | Starting date string. |
endDate | String | Ending date string. |
deviceName | String | Name of the device that generated the data. |
deviceModel | String | Model of the device that generated the data. |
deviceManufacturer | String | Manufacturer of the device that generated the data. |
deviceHardwareVersion | String | String representing the hardware version of the device. |
deviceSoftwareVersion | String | String representing the software version of the device. |
deviceFirmwareVersion | String | String representing the current version of the firmware running on the device. |
metadata | Object | Metadata 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
Name | Type | Required | Description | Default |
---|---|---|---|---|
options | Object | Yes | An object that defines the search parametrs, along with the dataTypes to query. | N/A |
callback | Function | No | Returns an array of result objects when the request is sucessful. Returns an error if something went wrong. | N/A |
options
Name | Type | Required | Description | Default |
---|---|---|---|---|
dataType | String | yes | Data type to query. See Supported Data Types. | N/A |
bucket | String | no | Time scale to segment data by. | N/A |
startDate | Date | yes | Start date for the query. | N/A |
endDate | Date | yes | End date for the query. | N/A |
callback(error<String>, results<Array>)
Name | Type | Description |
---|---|---|
error | String | Error string, null when operation is successful. |
results | Array | Array of results. If no bucket is passed, returns only the first object. |
results
Name | Type | Description |
---|---|---|
unit | String | The unit of measure |
value | Number | Measured value |
startDate | String | Starting date string |
endDate | String | Ending 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
- 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 Type | Unit | HealthKit Equivalent | Google Fit Equivalent |
---|---|---|---|
abdominal_cramps | Severity | HKCategoryTypeIdentifierAbdominalCramps | N/A |
acne | Severity | HKCategoryTypeIdentifierAcne | N/A |
activity | activityType | See Supported Activites | TYPE_ACTIVITY_SEGMENT |
activitySummary | N/A | ||
appetite_changes | Severity | HKCategoryTypeIdentifierAppetiteChanges | N/A |
appleExerciseTime | min | HKQuantityTypeIdentifierAppleExerciseTime | N/A |
audio_exposure_event | N/A | HKCategoryTypeIdentifierAudioExposureEvent | N/A |
bladder_incontinence | Severity | HKCategoryTypeIdentifierBladderIncontinence | N/A |
bloating | Severity | HKCategoryTypeIdentifierBloating | N/A |
blood_alcohol_content | percent | HKQuantityTypeIdentifierBloodAlcoholContent | N/A |
blood_glucose | mg/dL | HKQuantityTypeIdentifierBloodGlucose | TYPE_BLOOD_GLUCOSE |
blood_pressure | mmHg | HKCorrelationTypeIdentifierBloodPressure | TYPE_BLOOD_PRESSURE |
blood_pressure_diastolic | mmHg | HKQuantityTypeIdentifierBloodPressureDiastolic | N/A |
blood_pressure_systolic | mmHg | HKQuantityTypeIdentifierBloodPressureSystolic | N/A |
bmi | count | HKQuantityTypeIdentifierBodyMassIndex | N/A |
body_ache | Severity | HKCategoryTypeIdentifierGeneralizedBodyAche | N/A |
breast_pain | Severity | HKCategoryTypeIdentifierBreastPain | N/A |
calories | kcal | HKQuantityTypeIdentifierActiveEnergyBurned + HKQuantityTypeIdentifierBasalEnergyBurned | TYPE_CALORIES_EXPENDED |
calories.active | kcal | HKQuantityTypeIdentifierActiveEnergyBurned | TYPE_CALORIES_EXPENDED - (TYPE_BASAL_METABOLIC_RATE * time window) |
calories.basal | kcal | HKQuantityTypeIdentifierBasalEnergyBurned | TYPE_BASAL_METABOLIC_RATE * time window |
cervical_mucus_quality | Severity | HKCategoryTypeIdentifierCervicalMucusQuality | N/A |
chills | Severity | HKCategoryTypeIdentifierChills | N/A |
constipation | Severity | HKCategoryTypeIdentifierConstipation | N/A |
contraceptives | Type | HKCategoryTypeIdentifierContraceptive | N/A |
coughing | Severity | HKCategoryTypeIdentifierCoughing | N/A |
date_of_birth | HKCharacteristicTypeIdentifierDateOfBirth | N/A | |
diarrhea | Severity | HKCategoryTypeIdentifierDiarrhea | N/A |
distance | m | HKQuantityTypeIdentifierDistanceWalkingRunning + HKQuantityTypeIdentifierDistanceCycling | TYPE_DISTANCE_DELTA |
distance.walkingRunning | m | HKQuantityTypeIdentifierDistanceWalkingRunning | N/A |
distance.cycling | m | HKQuantityTypeIdentifierDistanceCycling | N/A |
distance.wheelchair | m | HKQuantityTypeIdentifierDistanceWheelchair | N/A |
dizziness | Severity | HKCategoryTypeIdentifierDizziness | N/A |
dry_skin | Severity | HKCategoryTypeIdentifierDrySkin | N/A |
electrocardiogram | N/A | ||
electrodermal_activity | mcS | HKQuantityTypeIdentifierElectrodermalActivity | N/A |
environmental_audio_exposure | dB | HKQuantityTypeIdentifierEnvironmentalAudioExposure // iOS 13+ | N/A |
environmental_audio_exposure_event | N/A | HKCategoryTypeIdentifierEnvironmentalAudioExposureEvent | N/A |
fainting | Severity | HKCategoryTypeIdentifierFainting | N/A |
fat_percentage | % | HKQuantityTypeIdentifierBodyFatPercentage | TYPE_BODY_FAT_PERCENTAGE |
fatigue | Severity | HKCategoryTypeIdentifierFatigue | N/A |
fever | Severity | HKCategoryTypeIdentifierFever | N/A |
flights_climbed | count | HKQuantityTypeIdentifierFlightsClimbed | N/A |
forced_expiratory_volume1 | L | HKQuantityTypeIdentifierForcedExpiratoryVolume1 | N/A |
forced_vital_capacity | L | HKQuantityTypeIdentifierForcedVitalCapacity | N/A |
gender | HKCharacteristicTypeIdentifierBiologicalSex | N/A | |
hair_loss | Severity | HKCategoryTypeIdentifierHairLoss | N/A |
handwashing_event | N/A | HKCategoryTypeIdentifierHandwashingEvent | N/A |
headache | Severity | HKCategoryTypeIdentifierHeadache | N/A |
headphone_audio_exposure | dB | HKQuantityTypeIdentifierHeadphoneAudioExposure | N/A |
headphone_audio_exposure_event | N/A | HKCategoryTypeIdentifierHeadphoneAudioExposureEvent | N/A |
heart_rate | count/min | HKQuantityTypeIdentifierHeartRate | TYPE_HEART_RATE_BPM |
heart_rate_variability_sdnn | ms | HKQuantityTypeIdentifierHeartRateVariabilitySDNN | N/A |
heart_rate.resting | count/min | HKQuantityTypeIdentifierRestingHearRate | N/A |
heart_rate.variability | ms | HKQuantityTypeIdentifierHeartRateVariabilitySDNN | N/A |
heartburn | Severity | HKCategoryTypeIdentifierHeartburn | N/A |
height | m | HKQuantityTypeIdentifierHeight | TYPE_HEIGHT |
high_heart_rate_event | N/A | HKCategoryTypeIdentifierHighHeartRateEvent | N/A |
hot_flashes | Severity | HKCategoryTypeIdentifierHotFlashes | N/A |
inhaler_usage | count | HKQuantityTypeIdentifierInhalerUsage | N/A |
insulin | IU | HKQuantityTypeIdentifierInsulinDelivery | N/A |
intermenstrual_bleeding | Severity | HKCategoryTypeIdentifierIntermenstrualBleeding | N/A |
irregular_heart_rhythm_event | N/A | HKCategoryTypeIdentifierIrregularHeartRhythmEvent | N/A |
lactation | N/A | HKCategoryTypeIdentifierLactation | N/A |
lean_body_mass | kg | HKQuantityTypeIdentifierLeanBodyMass | N/A |
loss_of_smell | Severity | HKCategoryTypeIdentifierLossOfSmell | N/A |
loss_of_taste | Severity | HKCategoryTypeIdentifierLossOfTaste | N/A |
low_cardio_event | N/A | HKCategoryTypeIdentifierLowCardioFitnessEvent | N/A |
low_heart_rate_event | N/A | HKCategoryTypeIdentifierLowHeartRateEvent | N/A |
lower_back_pain | Severity | HKCategoryTypeIdentifierLowerBackPain | N/A |
memory_lapse | Severity | HKCategoryTypeIdentifierMemoryLapse | N/A |
menstrual_flow | Flow | HKCategoryTypeIdentifierMenstrualFlow | N/A |
mindfulness | min | HKCategoryTypeIdentifierMindfulSession | N/A |
mindfulness | sec | HKCategoryTypeIdentifierMindfulSession | N/A |
mood_changes | Severity | HKCategoryTypeIdentifierMoodChanges | N/A |
nausea | Severity | HKCategoryTypeIdentifierNausea | N/A |
night_sweats | Severity | HKCategoryTypeIdentifierNightSweats | N/A |
number_of_alcoholic_beverages | count | HKQuantityTypeIdentifierNumberOfAlcoholicBeverages | N/A |
number_of_times_fallen | count | HKQuantityTypeIdentifierNumberOfTimesFallen | N/A |
nutrition | HKCorrelationTypeIdentifierFood | TYPE_NUTRITION | |
nutrition.biotin | mcg | HKQuantityTypeIdentifierDietaryBiotin | N/A |
nutrition.caffeine | g | HKQuantityTypeIdentifierDietaryCaffeine | N/A |
nutrition.calcium | mg | HKQuantityTypeIdentifierDietaryCalcium | TYPE_NUTRITION, NUTRIENT_CALCIUM |
nutrition.calories | kcal | HKQuantityTypeIdentifierDietaryEnergyConsumed | TYPE_NUTRITION, NUTRIENT_CALORIES |
nutrition.carbs.total | g | HKQuantityTypeIdentifierDietaryCarbohydrates | TYPE_NUTRITION, NUTRIENT_TOTAL_CARBS |
nutrition.chloride | mg | HKQuantityTypeIdentifierDietaryChloride | N/A |
nutrition.cholesterol | mg | HKQuantityTypeIdentifierDietaryCholesterol | TYPE_NUTRITION, NUTRIENT_CHOLESTEROL |
nutrition.chromium | mcg | HKQuantityTypeIdentifierDietaryChromium | N/A |
nutrition.copper | mg | HKQuantityTypeIdentifierDietaryCopper | N/A |
nutrition.dietary_fiber | g | HKQuantityTypeIdentifierDietaryFiber | TYPE_NUTRITION, NUTRIENT_DIETARY_FIBER |
nutrition.fat.monounsaturated | g | HKQuantityTypeIdentifierDietaryFatMonounsaturated | TYPE_NUTRITION, NUTRIENT_MONOUNSATURATED_FAT |
nutrition.fat.polyunsaturated | g | HKQuantityTypeIdentifierDietaryFatPolyunsaturated | TYPE_NUTRITION, NUTRIENT_POLYUNSATURATED_FAT |
nutrition.fat.saturated | g | HKQuantityTypeIdentifierDietaryFatSaturated | TYPE_NUTRITION, NUTRIENT_SATURATED_FAT |
nutrition.fat.unsaturated | g | N/A | TYPE_NUTRITION, NUTRIENT_UNSATURATED_FAT |
nutrition.fat.trans | g | N/A | TYPE_NUTRITION, NUTRIENT_TRANS_FAT (g) |
nutrition.fat.total | g | HKQuantityTypeIdentifierDietaryFatTotal | TYPE_NUTRITION, NUTRIENT_TOTAL_FAT |
nutrition.folate | mcg | HKQuantityTypeIdentifierDietaryFolate | N/A |
nutrition.iodine | mcg | HKQuantityTypeIdentifierDietaryIodine | N/A |
nutrition.iron | mg | HKQuantityTypeIdentifierDietaryIron | TYPE_NUTRITION, NUTRIENT_IRON |
nutrition.magnesium | mg | HKQuantityTypeIdentifierDietaryMagnesium | N/A |
nutrition.molybdenum | mg | HKQuantityTypeIdentifierDietaryMolybdenum | N/A |
nutrition.niacin | mg | HKQuantityTypeIdentifierDietaryNiacin | N/A |
nutrition.pantothenic_acid | mg | HKQuantityTypeIdentifierDietaryPantothenicAcid | N/A |
nutrition.phosphorus | mg | HKQuantityTypeIdentifierDietaryPhosphorus | N/A |
nutrition.potassium | mg | HKQuantityTypeIdentifierDietaryPotassium | TYPE_NUTRITION, NUTRIENT_POTASSIUM |
nutrition.protein | g | HKQuantityTypeIdentifierDietaryProtein | TYPE_NUTRITION, NUTRIENT_PROTEIN |
nutrition.riboflavin | mg | HKQuantityTypeIdentifierDietaryRiboflavin | N/A |
nutrition.selenium | mcg | HKQuantityTypeIdentifierDietarySelenium | N/A |
nutrition.sodium | mg | HKQuantityTypeIdentifierDietarySodium | TYPE_NUTRITION, NUTRIENT_SODIUM |
nutrition.sugar | g | HKQuantityTypeIdentifierDietarySugar | TYPE_NUTRITION, NUTRIENT_SUGAR |
nutrition.thiamin | mg | HKQuantityTypeIdentifierDietaryThiamin | N/A |
nutrition.vitamin_a | mcg (HK), IU (GF) | HKQuantityTypeIdentifierDietaryVitaminA | TYPE_NUTRITION, NUTRIENT_VITAMIN_A |
nutrition.vitamin_B12 | mcg | HKQuantityTypeIdentifierDietaryVitaminB12 | N/A |
nutrition.vitamin_B6 | mg | HKQuantityTypeIdentifierDietaryVitaminB6 | N/A |
nutrition.vitamin_c | mg | HKQuantityTypeIdentifierDietaryVitaminC | TYPE_NUTRITION, NUTRIENT_VITAMIN_C |
nutrition.vitamin_D | mcg | HKQuantityTypeIdentifierDietaryVitaminD | N/A |
nutrition.vitamin_E | mg | HKQuantityTypeIdentifierDietaryVitaminE | N/A |
nutrition.vitamin_K | mcg | HKQuantityTypeIdentifierDietaryVitaminK | N/A |
nutrition.water | ml | HKQuantityTypeIdentifierDietaryWater | TYPE_HYDRATION |
nutrition.zinc | mg | HKQuantityTypeIdentifierDietaryZinc | N/A |
ovulation_test_result | Result | HKCategoryTypeIdentifierOvulationTestResult | N/A |
oxygen_saturation | % | HKQuantityTypeIdentifierOxygenSaturation | TYPE_OXYGEN_SATURATION |
peak_expiratory_flow_rate | L/min | HKQuantityTypeIdentifierPeakExpiratoryFlowRate | N/A |
pelvic_pain | Severity | HKCategoryTypeIdentifierPelvicPain | N/A |
peripheral_perfusion_index | percent | HKQuantityTypeIdentifierPeripheralPerfusionIndex | N/A |
pregnancy | N/A | HKCategoryTypeIdentifierPregnancy | N/A |
pregnancy_test_result | Result | HKCategoryTypeIdentifierPregnancyTestResult | N/A |
progesterone_test_result | Result | HKCategoryTypeIdentifierProgesteroneTestResult | N/A |
rapid_or_fluttering_heartbeat | Severity | HKCategoryTypeIdentifierRapidPoundingOrFlutteringHeartbeat | N/A |
resp_rate | count/min | HKQuantityTypeIdentifierRespiratoryRate | N/A |
runny_nose | Severity | HKCategoryTypeIdentifierRunnyNose | N/A |
sexual_activity | N/A | HKCategoryTypeIdentifierSexualActivity | N/A |
shortness_of_breath | Severity | HKCategoryTypeIdentifierShortnessOfBreath | N/A |
sinus_congestion | Severity | HKCategoryTypeIdentifierSinusCongestion | N/A |
six_minute_walk_test_distance | m | HKQuantityTypeIdentifierSixMinuteWalkTestDistance | N/A |
skipped_heartbeat | Severity | HKCategoryTypeIdentifierSkippedHeartbeat | N/A |
sleep | N/A | HKCategoryTypeIdentifierSleepAnalysis | TYPE_ACTIVITY_SEGMENT (and/or sleep sessions) |
sleep_changes | Severity | HKCategoryTypeIdentifierSleepChanges | N/A |
sore_throat | Severity | HKCategoryTypeIdentifierSoreThroat | N/A |
stair_ascent_speed | m/s | HKQuantityTypeIdentifierStairAscentSpeed | N/A |
stair_descent_speed | m/s | HKQuantityTypeIdentifierStairDescentSpeed | N/A |
stairs | count | HKQuantityTypeIdentifierFlightsClimbed | N/A |
stand_time | s | HKQuantityTypeIdentifierDietaryVitaminE | N/A |
steps | count | HKQuantityTypeIdentifierStepCount | TYPE_STEP_COUNT_DELTA |
temperature | Celsius | HKQuantityTypeIdentifierBodyTemperature | N/A |
temperature.basal | degC | HKQuantityTypeIdentifierBasalBodyTemperature | N/A |
tightness_or_pain | Severity | HKCategoryTypeIdentifierChestTightnessOrPain | N/A |
toothbrushing_event | N/A | HKCategoryTypeIdentifierToothbrushingEvent | N/A |
uv_exposure | count | HKQuantityTypeIdentifierUVExposure | N/A |
vaginal_dryness | Severity | HKCategoryTypeIdentifierVaginalDryness | N/A |
vo2max | ml/(kg * min) | HKQuantityTypeIdentifierVO2Max | N/A |
vomiting | Severity | HKCategoryTypeIdentifierVomiting | N/A |
waist_circumference | m | HKQuantityTypeIdentifierWaistCircumference | N/A |
walking_asymmetry_percentage | percent | HKQuantityTypeIdentifierWalkingAsymmetryPercentage | N/A |
walking_double_support_percentage | percent | HKQuantityTypeIdentifierWalkingDoubleSupportPercentage | N/A |
walking_speed | m/s | HKQuantityTypeIdentifierWalkingSpeed | N/A |
walking_steadiness | percent | HKQuantityTypeIdentifierAppleWalkingSteadiness | N/A |
walking_steadiness_event | N/A | HKCategoryTypeIdentifierAppleWalkingSteadinessEvent | N/A |
walking_step_length | cm | HKQuantityTypeIdentifierWalkingStepLength | N/A |
weight | kg | HKQuantityTypeIdentifierBodyMass | TYPE_WEIGHT |
wheezing | Severity | HKCategoryTypeIdentifierWheezing | N/A |
Activities
Activity Name | HealthKit Equivalent | Google Fit Equivalent |
---|---|---|
archery | HKWorkoutActivityTypeArchery | N/A |
badminton | HKWorkoutActivityTypeBadminton | BADMINTON |
barre | HKWorkoutActivityTypeBarre | N/A |
baseball | HKWorkoutActivityTypeBaseball | BASEBALL |
basketball | HKWorkoutActivityTypeBasketball | BASKETBALL |
biking | HKWorkoutActivityTypeCycling | BIKING |
biking.hand | HKWorkoutActivityTypeHandCycling | BIKING_HAND |
biking.mountain | HKWorkoutActivityTypeCycling | BIKING_MOUNTAIN |
biking.road | HKWorkoutActivityTypeCycling | BIKING_ROAD |
biking.spinning | HKWorkoutActivityTypeCycling | BIKING_SPINNING |
biking.stationary | HKWorkoutActivityTypeCycling | BIKING_STATIONARY |
biking.utility | HKWorkoutActivityTypeCycling | BIKING_UTILITY |
bowling | HKWorkoutActivityTypeBowling | N/A |
boxing | HKWorkoutActivityTypeBoxing | BOXING |
cooldown | HKWorkoutActivityTypeCooldown | N/A |
core_training | HKWorkoutActivityTypeCoreTraining | STRENGTH_TRAINING |
cricket | HKWorkoutActivityTypeCricket | CRICKET |
crossfit | HKWorkoutActivityTypeCrossTraining | CROSSFIT |
curling | HKWorkoutActivityTypeCurling | CURLING |
dancing | HKWorkoutActivityTypeCardioDance | DANCING |
dancing.social | HKWorkoutActivityTypeSocialDance | N/A |
disc_sports | HKWorkoutActivityTypeDiscSports | N/A |
diving | HKWorkoutActivityTypeWaterSports | DIVING |
elliptical | HKWorkoutActivityTypeElliptical | ELLIPTICAL |
fencing | HKWorkoutActivityTypeFencing | FENCING |
fishing | HKWorkoutActivityTypeFishing | N/A |
fitness_gaming | HKWorkoutActivityTypeFitnessGaming | N/A |
flexibility | HKWorkoutActivityTypeFlexibility | GYMNASTICS |
football.american | KWorkoutActivityTypeAmericanFootball | FOOTBALL_AMERICAN |
football.australian | HKWorkoutActivityTypeAustralianFootball | FOOTBALL_AUSTRALIAN |
football.soccer | HKWorkoutActivityTypeSoccer | FOOTBALL_SOCCER |
functional_strength | HKWorkoutActivityTypeFunctionalStrengthTraining | N/A |
golf | HKWorkoutActivityTypeGolf | GOLF |
gymnastics | HKWorkoutActivityTypeGymnastics | GYMNASTICS |
handball | KWorkoutActivityTypeHandball | HANDBALL |
hiking | HKWorkoutActivityTypeHiking | HIKING |
hockey | HKWorkoutActivityTypeHockey | HOCKEY |
horseback_riding | HKWorkoutActivityTypeEquestrianSports | HORSEBACK_RIDING |
hunting | HKWorkoutActivityTypeHunting | N/A |
ice_skating | HKWorkoutActivityTypeSkatingSports | ice_skating |
interval_training | HKWorkoutActivityTypeHighIntensityIntervalTraining | INTERVAL_TRAINING |
interval_training.high_intensity | HKWorkoutActivityTypeHighIntensityIntervalTraining | HIGH_INTENSITY_INTERVAL_TRAINING |
jump_rope | HKWorkoutActivityTypeJumpRope | JUMP_ROPE |
kayaking | HKWorkoutActivityTypePaddleSports | KAYAKING |
kick_scooter | HKWorkoutActivityTypeCycling | KICK_SCOOTER |
kickboxing | HKWorkoutActivityTypeKickboxing | KICKBOXING |
lacrosse | HKWorkoutActivityTypeLacrosse | N/A |
martial_arts | HKWorkoutActivityTypeMartialArts | MARTIAL_ARTS |
martial_arts.mixed | HKWorkoutActivityTypeMartialArts | MIXED_MARTIAL_ARTS |
meditation | HKWorkoutActivityTypeMindAndBody | MEDITATION |
mixed_metabolic_cardio | HKWorkoutActivityTypeMixedCardio | N/A |
other | HKWorkoutActivityTypeOther | OTHER |
paddle_sports | HKWorkoutActivityTypePaddleSports | N/A |
pickleball | HKWorkoutActivityTypePickleball | N/A |
pilates | HKWorkoutActivityTypePilates | PILATES |
play | HKWorkoutActivityTypePlay | N/A |
preparation_and_recovery | HKWorkoutActivityTypePreparationAndRecovery | N/A |
racquetball | HKWorkoutActivityTypeRacquetball | RACQUETBALL |
rock_climbing | HKWorkoutActivityTypeClimbing | ROCK_CLIMBING |
rowing | HKWorkoutActivityTypeRowing | ROWING |
rowing.machine | HKWorkoutActivityTypeRowing | ROWING_MACHINE |
rugby | HKWorkoutActivityTypeRugby | RUGBY |
running | HKWorkoutActivityTypeRunning | RUNNING |
running.jogging | HKWorkoutActivityTypeRunning | RUNNING_JOGGING |
running.sand | HKWorkoutActivityTypeRunning | RUNNING_SAND |
running.treadmill | HKWorkoutActivityTypeRunning | RUNNING_TREADMILL |
sailing | HKWorkoutActivityTypeSailing | SAILING |
scuba_diving | HKWorkoutActivityTypeWaterSports | SCUBA_DIVING |
skateboarding | HKWorkoutActivityTypeSkatingSports | SKATEBOARDING |
skating | HKWorkoutActivityTypeSkatingSports | SKATING |
skating.cross | HKWorkoutActivityTypeSkatingSports | SKATING_CROSS |
skating.indoor | HKWorkoutActivityTypeSkatingSports | SKATING_INDOOR |
skating.inline | HKWorkoutActivityTypeSkatingSports | SKATING_INLINE |
skiing | HKWorkoutActivityTypeSnowSports | SKIING |
skiing.back_country | HKWorkoutActivityTypeSnowSports | SKIING_BACK_COUNTRY |
skiing.cross_country | HKWorkoutActivityTypeCrossCountrySkiing | SKIING_CROSS_COUNTRY |
skiing.downhill | HKWorkoutActivityTypeDownhillSkiing | SKIING_DOWNHILL |
skiing.kite | HKWorkoutActivityTypeSnowSports | SKIING_KITE |
skiing.roller | HKWorkoutActivityTypeSnowSports | SKIING_ROLLER |
sledding | HKWorkoutActivityTypeSnowSports | SLEDDING |
sleep | HKCategoryValueSleepAnalysisAsleep | SLEEP |
sleep.awake | HKCategoryValueSleepAnalysisAwake | N/A |
sleep.deep | HKCategoryValueSleepAnalysisAsleep | SLEEP_DEEP |
sleep.inBed | HKCategoryValueSleepAnalysisInBed | N/A |
sleep.light | HKCategoryValueSleepAnalysisAsleep | SLEEP_LIGHT |
sleep.rem | HKCategoryValueSleepAnalysisAsleep | SLEEP_REM |
snow_sports | HKWorkoutActivityTypeSnowSports | N/A |
snowboarding | HKWorkoutActivityTypeSnowboarding | SNOWBOARDING |
snowmobile | HKWorkoutActivityTypeSnowSports | SNOWMOBILE |
snowshoeing | HKWorkoutActivityTypeSnowSports | SNOWSHOEING |
softball | HKWorkoutActivityTypeSoftball | N/A |
squash | HKWorkoutActivityTypeSquash | SQUASH |
stair_climbing | HKWorkoutActivityTypeStairClimbing | STAIR_CLIMBING |
stair_climbing.machine | HKWorkoutActivityTypeStepTraining | STAIR_CLIMBING_MACHINE |
stairs | HKWorkoutActivityTypeStairs | STAIR_CLIMBING |
standup_paddleboarding | HKWorkoutActivityTypePaddleSports | STANDUP_PADDLEBOARDING |
strength_training | HKWorkoutActivityTypeTraditionalStrengthTraining | STRENGTH_TRAINING |
surfing | HKWorkoutActivityTypeSurfingSports | SURFING |
swimming | HKWorkoutActivityTypeSwimming | SWIMMING |
swimming.open_water | HKWorkoutActivityTypeSwimming | SWIMMING_OPEN_WATER |
swimming.pool | HKWorkoutActivityTypeSwimming | SWIMMING_POOL |
table_tennis | HKWorkoutActivityTypeTableTennis | TABLE_TENNIS |
tai_chi | HKWorkoutActivityTypeTaiChi | N/A |
tennis | HKWorkoutActivityTypeTennis | TENNIS |
track_and_field | HKWorkoutActivityTypeTrackAndField | RUNNING |
volleyball | HKWorkoutActivityTypeVolleyball | VOLLEYBALL |
volleyball.beach | HKWorkoutActivityTypeVolleyball | VOLLEYBALL_BEACH |
volleyball.indoor | HKWorkoutActivityTypeVolleyball | VOLLEYBALL_INDOOR |
wakeboarding | HKWorkoutActivityTypeWaterSports | WAKEBOARDING |
walking | HKWorkoutActivityTypeWalking | WALKING |
walking.fitness | HKWorkoutActivityTypeWalking | WALKING_FITNESS |
walking.nordic | HKWorkoutActivityTypeWalking | WALKING_NORDIC |
walking.stroller | HKWorkoutActivityTypeWalking | WALKING_STROLLER |
walking.treadmill | HKWorkoutActivityTypeWalking | WALKING_TREADMILL |
water_fitness | HKWorkoutActivityTypeWaterFitness | N/A |
water_polo | HKWorkoutActivityTypeWaterPolo | WATER_POLO |
water_sports | HKWorkoutActivityTypeWaterSports | N/A |
weightlifting | HKWorkoutActivityTypeTraditionalStrengthTraining | WEIGHTLIFTING |
wheelchair | HKWorkoutActivityTypeWheelchairRunPace | WHEELCHAIR |
wheelchair.runpace | HKWorkoutActivityTypeWheelchairRunPace | WHEELCHAIR |
wheelchair.walkpace | HKWorkoutActivityTypeWheelchairWalkPace | WHEELCHAIR |
windsurfing | HKWorkoutActivityTypeWaterSports | WINDSURFING |
wrestling | HKWorkoutActivityTypeWrestling | N/A |
yoga | HKWorkoutActivityTypeYoga | YOGA |
Electrocardiograms (iOS Only)
The health
service can query for electrocardiogram
as a data type. Electrocardiogram samples contain the following data:
Name | Type | Description |
---|---|---|
algorithmVersion | Number | Version numbers for the algorithm Apple Watch uses to generate an ECG reading |
averageHeartRate | Number | Average heart rate over ECG duration |
classification | String | ECG’s classification (ex: "SinusRhythm") |
samplingFrequency | Number | The frequency at which the voltage is sampled |
voltageMeasurements | Array | Collection 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]
// ...
]
}