Method: users.dataTypes.dataPoints.rollUp

Roll up data points over physical time intervals for supported data types.

HTTP request

POST https://health.googleapis.com/v4/{parent=users/*/dataTypes/*}/dataPoints:rollUp

The URL uses gRPC Transcoding syntax. To know more about valid error responses that can be thrown by this HTTP request, please refer to the service error catalog

Path parameters

Parameters
parent

string

Required. Parent data type of the Data Point collection.

Format: users/{user}/dataTypes/{dataType}, e.g.:

  • users/me/dataTypes/steps
  • users/me/dataTypes/distance

For a list of the supported data types see the RollupDataPoint value union field. It takes the form users/{user}/dataTypes/{datatype}.

Request body

The request body contains data with the following structure:

JSON representation
{
  "range": {
    object (Interval)
  },
  "windowSize": string,
  "pageSize": integer,
  "pageToken": string,
  "dataSourceFamily": string
}
Fields
range

object (Interval)

Required. Closed-open range of data points that will be rolled up. The maximum range for calories-in-heart-rate-zone, heart-rate, active-minutes and total-calories is 14 days. The maximum range for all other data types is 90 days.

windowSize

string (Duration format)

Required. The size of the time window to group data points into before applying the aggregation functions.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

pageSize

integer

Optional. The maximum number of data points to return. If unspecified, at most 1440 data points will be returned. The maximum page size is 10000; values above that will be truncated accordingly.

pageToken

string

Optional. The nextPageToken from a previous request, if any. All other request fields need to be the same as in the initial request when the page token is specified.

dataSourceFamily

string

Optional. The data source family name to roll up.

If empty, data points from all available data sources will be rolled up.

Format: users/me/dataSourceFamilies/{dataSourceFamily}

The supported values are:

  • users/me/dataSourceFamilies/all-sources - default value
  • users/me/dataSourceFamilies/google-wearables - tracker devices
  • users/me/dataSourceFamilies/google-sources - Google first party sources

Response body

Response containing the list of rolled up data points.

If successful, the response body contains data with the following structure:

JSON representation
{
  "rollupDataPoints": [
    {
      object (RollupDataPoint)
    }
  ],
  "nextPageToken": string
}
Fields
rollupDataPoints[]

object (RollupDataPoint)

Values for each aggregation time window.

nextPageToken

string

A token, which can be sent as pageToken to retrieve the next page. If this field is omitted, there are no subsequent pages.

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/googlehealth.activity_and_fitness
  • https://www.googleapis.com/auth/googlehealth.activity_and_fitness.readonly
  • https://www.googleapis.com/auth/googlehealth.health_metrics_and_measurements
  • https://www.googleapis.com/auth/googlehealth.health_metrics_and_measurements.readonly
  • https://www.googleapis.com/auth/googlehealth.location
  • https://www.googleapis.com/auth/googlehealth.location.readonly
  • https://www.googleapis.com/auth/googlehealth.nutrition
  • https://www.googleapis.com/auth/googlehealth.nutrition.readonly
  • https://www.googleapis.com/auth/googlehealth.sleep
  • https://www.googleapis.com/auth/googlehealth.sleep.readonly

For more information, see the OAuth 2.0 Overview.

Interval

Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive).

The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.

JSON representation
{
  "startTime": string,
  "endTime": string
}
Fields
startTime

string (Timestamp format)

Optional. Inclusive start of the interval.

If specified, a Timestamp matching this interval will have to be the same or after the start.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

endTime

string (Timestamp format)

Optional. Exclusive end of the interval.

If specified, a Timestamp matching this interval will have to be before the end.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

RollupDataPoint

Value of a rollup for a single physical time interval (aggregation window)

JSON representation
{
  "startTime": string,
  "endTime": string,

  // Union field value can be only one of the following:
  "steps": {
    object (StepsRollupValue)
  },
  "floors": {
    object (FloorsRollupValue)
  },
  "heartRate": {
    object (HeartRateRollupValue)
  },
  "weight": {
    object (WeightRollupValue)
  },
  "altitude": {
    object (AltitudeRollupValue)
  },
  "distance": {
    object (DistanceRollupValue)
  },
  "bodyFat": {
    object (BodyFatRollupValue)
  },
  "totalCalories": {
    object (TotalCaloriesRollupValue)
  },
  "activeZoneMinutes": {
    object (ActiveZoneMinutesRollupValue)
  },
  "sedentaryPeriod": {
    object (SedentaryPeriodRollupValue)
  },
  "runVo2Max": {
    object (RunVO2MaxRollupValue)
  },
  "caloriesInHeartRateZone": {
    object (CaloriesInHeartRateZoneRollupValue)
  },
  "activityLevel": {
    object (ActivityLevelRollupValue)
  },
  "hydrationLog": {
    object (HydrationLogRollupValue)
  },
  "timeInHeartRateZone": {
    object (TimeInHeartRateZoneRollupValue)
  },
  "activeMinutes": {
    object (ActiveMinutesRollupValue)
  }
  // End of list of possible types for union field value.
}
Fields
startTime

string (Timestamp format)

Start time of the window this value aggregates over

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

endTime

string (Timestamp format)

End time of the window this value aggregates over

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

Union field value. Outcome of a rollup of the requested data type.

{DataType}RollupValue messages for each data type contain aggregated values for all supported fields.

The field names usually follow the format {original_field_name}_{aggregation_function}. For example: confidence_min, confidence_sum.

If there were no data points in this interval, the value will not be set. These messages represent the aggregated data payload for each data type and are embedded within the RollupDataPoint. They are not standalone resources themselves. value can be only one of the following:

steps

object (StepsRollupValue)

Returned by default when rolling up data points from the steps data type, or when requested explicitly using the steps rollup type identifier.

floors

object (FloorsRollupValue)

Returned by default when rolling up data points from the floors data type, or when requested explicitly using the floors rollup type identifier.

heartRate

object (HeartRateRollupValue)

Returned by default when rolling up data points from the heart-rate data type, or when requested explicitly using the heart-rate rollup type identifier.

weight

object (WeightRollupValue)

Returned by default when rolling up data points from the weight data type, or when requested explicitly using the weight rollup type identifier.

altitude

object (AltitudeRollupValue)

Returned by default when rolling up data points from the altitude data type, or when requested explicitly using the altitude rollup type identifier.

distance

object (DistanceRollupValue)

Returned by default when rolling up data points from the distance data type, or when requested explicitly using the distance rollup type identifier.

bodyFat

object (BodyFatRollupValue)

Returned by default when rolling up data points from the body-fat data type, or when requested explicitly using the body-fat rollup type identifier.

totalCalories

object (TotalCaloriesRollupValue)

Returned by default when rolling up data points from the total-calories data type, or when requested explicitly using the total-calories rollup type identifier.

activeZoneMinutes

object (ActiveZoneMinutesRollupValue)

Returned by default when rolling up data points from the active-zone-minutes data type, or when requested explicitly using the active-zone-minutes rollup type identifier.

sedentaryPeriod

object (SedentaryPeriodRollupValue)

Returned by default when rolling up data points from the sedentary-period data type, or when requested explicitly using the sedentary-period rollup type identifier.

runVo2Max

object (RunVO2MaxRollupValue)

Returned by default when rolling up data points from the run-vo2-max data type, or when requested explicitly using the run-vo2-max rollup type identifier.

caloriesInHeartRateZone

object (CaloriesInHeartRateZoneRollupValue)

Returned by default when rolling up data points from the calories-in-heart-rate-zone data type, or when requested explicitly using the calories-in-heart-rate-zone rollup type identifier.

activityLevel

object (ActivityLevelRollupValue)

Returned by default when rolling up data points from the activity-level data type, or when requested explicitly using the activity-level rollup type identifier.

hydrationLog

object (HydrationLogRollupValue)

Returned by default when rolling up data points from the hydration-log data type, or when requested explicitly using the hydration-log rollup type identifier.

timeInHeartRateZone

object (TimeInHeartRateZoneRollupValue)

Returned by default when rolling up data points from the time-in-heart-rate-zone data type, or when requested explicitly using the time-in-heart-rate-zone rollup type identifier.

activeMinutes

object (ActiveMinutesRollupValue)

Returned by default when rolling up data points from the active-minutes data type, or when requested explicitly using the active-minutes rollup type identifier.