Apple Health Data
Although complete Apple Health data can be queried via the Device Data methods, several specific methods exist to aggregate commonly-used data in useful ways.
Query Apple Health Activity Summaries
MyDataHelps.queryAppleHealthActivitySummaries(queryParameters)
The daily activity summary reports on several common activity measures.
Parameters
startDate
date
Filters data after this date, in ISO8601 format.
endDate
date
Filters data before this date, in ISO8601 format.
pageSize
int
How many entries to include in each page of results. Default and maximum is 100.
pageID
guid
Each page of results will return a nextPageID
if there are additional pages that can be queried. Supply that to pageID
to query the next page. When excluded, retrieves the first page.
Returns
Promise<AppleHealthSummariesPageResults>
Resolves to a result
object containing a page of activity summaries.
+ Result Fields
Availability
var queryParameters = {
startDate: "2021-02-18",
endDate: "2021-03-01T12:00:00-4:00",
pageSize: 100,
pageID: "c123b398-bf20-4b6f-989c-b0dcb4c3d75c"
};
MyDataHelps.queryAppleHealthActivitySummaries(queryParameters)
.then( function(result) {
console.log(result);
} );
{
"nextPageID": "1f2464dd-7d05-421e-bd48-14b169f53fd1",
"totalResults": 100,
"results": [
{
"id": "c11bcf07-10f3-ed11-aac7-0afb9334277d",
"activeEnergyBurned": 610.317999999999,
"activeEnergyBurnedGoal": 340,
"appleExerciseTime": 64,
"appleExerciseTimeGoal": 30,
"appleStandHours": 13,
"appleStandHoursGoal": 12,
"startDate": "2023-05-14T00:00:00-04:00",
"endDate": "2023-05-14T23:59:59-04:00",
"insertedDate": "2023-05-15T11:02:53.74Z"
},
{
"id": "7d0c6f48-12f2-ed11-aac7-0afb9334277d",
"activeEnergyBurned": 437.63,
"activeEnergyBurnedGoal": 340,
"appleExerciseTime": 37,
"appleExerciseTimeGoal": 30,
"appleStandHours": 11,
"appleStandHoursGoal": 12,
"startDate": "2023-05-13T00:00:00-04:00",
"endDate": "2023-05-13T23:59:59-04:00",
"insertedDate": "2023-05-14T04:46:30.76Z"
},
...
]
}
Query Apple Health Workouts
MyDataHelps.queryAppleHealthWorkouts(queryParameters)
The workout summary provides details about workouts the participant has recorded.
Parameters
startDate
date
Filters data after this date, in ISO8601 format.
endDate
date
Filters data before this date, in ISO8601 format.
pageSize
int
How many entries to include in each page of results. Default and maximum is 100.
pageID
guid
Each page of results will return a nextPageID
if there are additional pages that can be queried. Supply that to pageID
to query the next page. When excluded, retrieves the first page.
Returns
Promise<AppleHealthWorkoutsPageResults>
Resolves to a result
object containing a page of workouts.
+ Result Fields
Availability
var queryParameters = {
startDate: "2021-02-18",
endDate: "2021-03-01T12:00:00-4:00",
pageSize: 100,
pageID: "c123b398-bf20-4b6f-989c-b0dcb4c3d75c"
};
MyDataHelps.queryAppleHealthWorkouts(queryParameters)
.then( function(result) {
console.log(result);
} );
{
"nextPageID": "aeabdae1-75ca-4d8f-814a-a017818382d2",
"totalResults": 100,
"results": [
{
"id": "c956165b-78f2-ed11-aac7-0afb9334277d",
"startDate": "2023-05-14T11:58:40-04:00",
"endDate": "2023-05-14T12:33:03-04:00",
"insertedDate": "2023-05-14T16:57:11.247Z",
"summary": {
"activityType": "Swimming",
"duration": 2062.91047000885,
"totalEnergyBurned": 191.938478011434,
"totalDistance": 914.400024414063,
"totalSwimmingStrokeCount": 358,
"totalFlightsClimbed": null
},
...
]
},
...
]
}