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.

Prerequisites

For data to be available, your project must first enable Apple Health data collection and the participant must choose to share their Apple Health data with MyDataHelps.

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 as 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.results collection

A list of AppleHealthActivitySummay data points filtered by the query parameters.

result.results[n].id guid

A unique identifier for this summary.

result.results[n].activeEnergyBurned decimal

The active energy burned recorded by the Apple Watch, in kcal.

result.results[n].activeEnergyBurnedGoal integer

The goal for activeEnergyBurned the participant set for themselves.

result.results[n].appleExerciseTime integer

The total exercise time recorded by the Apple Watch, in minutes.

result.results[n].appleExerciseTimeGoal integer

The goal for appleExerciseTime the participant set for themselves.

result.results[n].appleStandHours integer

The number of hours in the day during which the participant stood up for at least 1 minute.

result.results[n].appleStandHoursGoal integer

The goal for appleStandHours the participant set for themselves.

result.results[n].startDate date

Start date/time for the summary, in ISO8601 format.

result.results[n].endDate date

End date/time for the summary, in ISO8601 format.

result.results[n].insertedDate date

Date when the data was stored by the system, in ISO8601 format.

result.totalResults integer

Number of entries in the results list.

result.nextPageID guid

An ID to be used with subsequent queries. Results from queries using this ID as the pageID parameter will show the next page of results. This field is null if there isn’t a next page.

Availability

MyDataHelps Views
MyDataHelps Embeddables
Web View Steps
Querying Apple Health Activity Summaries
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);
	} );
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); } );
Sample Response Data
{
  "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"
    },
    ...
  ]
}
{ "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 as 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.results collection

A list of AppleHealthWorkout data points filtered by the query parameters.

result.results[n].id guid

A unique identifier for this workout.

result.results[n].startDate date

Start date/time for the workout, in ISO8601 format.

result.results[n].endDate date

End date/time for the workout, in ISO8601 format.

result.results[n].insertedDate date

Date when the data was stored by the system, in ISO8601 format.

result.results[n].source object

Data source information, determined by the source application.

result.results[n].device object

Device information, determined by the source application.

result.results[n].metadata object

Additional metadata specified by the source application.

result.results[n].events object

Detailed events that occurred within the activity (e.g., laps or pauses) specified by the source application.

result.results[n].summary object

Workout summary.

result.results[n].summary.activityType string

The type of workout.

result.results[n].summary.duration decimal

The duration of the workout, in seconds (if recorded).

result.results[n].summary.totalEnergyBurned decimal

The energy burned during the workout, in kcal (if recorded).

result.results[n].summary.totalDistance decimal

The distance traveled during the workout, in meters (if recorded).

result.results[n].summary.totalSwimmingStrokeCount integer

The number of swimming strokes during the workout (if recorded).

result.results[n].summary.totalFlightsClimbed integer

The flights of stairs climbed during the workout (if recorded).

result.totalResults integer

Number of entries in the results list.

result.nextPageID guid

An ID to be used with subsequent queries. Results from queries using this ID as the pageID parameter will show the next page of results. This field is null if there isn’t a next page.

Availability

MyDataHelps Views
MyDataHelps Embeddables
Web View Steps
Querying Apple Health Workouts
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);
	} );
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); } );
Sample Response Data

{
  "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
      },
      ...
      ]
    },
    ...
  ]
}
{ "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 }, ... ] }, ... ] }