Aggregates data of a certain type or stream into buckets divided by a given type of boundary. Multiple data sets of multiple types and from multiple sources can be aggregated into exactly one bucket type per request. Try it now .
Request
HTTP request
POST https://www.googleapis.com/fitness/v1/users/ userId /dataset:aggregate
Parameters
userId
string
me
to indicate
the authenticated user. Only me
is supported at this time.Authorization
This request requires authorization with at least one of the following scopes:
Scope |
---|
https://www.googleapis.com/auth/fitness.activity.read
|
https://www.googleapis.com/auth/fitness.activity.write
|
https://www.googleapis.com/auth/fitness.location.read
|
https://www.googleapis.com/auth/fitness.location.write
|
https://www.googleapis.com/auth/fitness.body.read
|
https://www.googleapis.com/auth/fitness.body.write
|
https://www.googleapis.com/auth/fitness.nutrition.read
|
https://www.googleapis.com/auth/fitness.nutrition.write
|
https://www.googleapis.com/auth/fitness.blood_pressure.read
|
https://www.googleapis.com/auth/fitness.blood_pressure.write
|
https://www.googleapis.com/auth/fitness.blood_glucose.read
|
https://www.googleapis.com/auth/fitness.blood_glucose.write
|
https://www.googleapis.com/auth/fitness.oxygen_saturation.read
|
https://www.googleapis.com/auth/fitness.oxygen_saturation.write
|
https://www.googleapis.com/auth/fitness.body_temperature.read
|
https://www.googleapis.com/auth/fitness.body_temperature.write
|
https://www.googleapis.com/auth/fitness.reproductive_health.read
|
https://www.googleapis.com/auth/fitness.reproductive_health.write
|
For more information, see the authentication and authorization page.
Request body
In the request body, supply data with the following structure:
{ "startTimeMillis" : long , "endTimeMillis" : long , "aggregateBy" : [ { "dataTypeName" : string , "dataSourceId" : string } ], "filteredDataQualityStandard" : [ string ], "bucketByTime" : { "durationMillis" : long , "period" : { "type" : string , "value" : integer , "timeZoneId" : string } } , "bucketBySession" : { "minDurationMillis" : long } , "bucketByActivityType" : { "minDurationMillis" : long , "activityDataSourceId" : string } , "bucketByActivitySegment" : { "minDurationMillis" : long , "activityDataSourceId" : string } }
startTimeMillis
long
endTimeMillis
long
aggregateBy[]
list
aggregateBy[].
dataTypeName
string
aggregateBy[].
dataSourceId
string
filteredDataQualityStandard[]
list
bucketByTime
nested object
bucketByTime.
durationMillis
long
bucketByTime.
period
nested object
bucketByTime.period.
type
string
Acceptable values are:
- "
day
" - "
month
" - "
week
"
bucketByTime.period.
value
integer
bucketByTime.period.
timeZoneId
string
bucketBySession
nested object
bucketBySession.
minDurationMillis
long
bucketByActivityType
nested object
bucketByActivityType.
minDurationMillis
long
bucketByActivityType.
activityDataSourceId
string
bucketByActivitySegment
nested object
bucketByActivitySegment.
minDurationMillis
long
bucketByActivitySegment.
activityDataSourceId
string
Response
If successful, this method returns a response body with the following structure:
{ "bucket" : [ { "type" : string , "startTimeMillis" : long , "endTimeMillis" : long , "dataset" : [ users . dataSources . datasets Resource ], "session" : { "id" : string , "name" : string , "description" : string , "startTimeMillis" : long , "endTimeMillis" : long , "modifiedTimeMillis" : long , "application" : { "packageName" : string , "version" : string , "detailsUrl" : string , "name" : string } , "activityType" : integer , "activeTimeMillis" : long } , "activity" : integer } ] }
bucket[]
list
bucket[].
type
string
Acceptable values are:
- "
activitySegment
" - "
activityType
" - "
session
" - "
time
" - "
unknown
"
bucket[].
startTimeMillis
long
bucket[].
endTimeMillis
long
bucket[].
dataset[]
list
bucket[].
session
nested object
bucket[].session.
id
string
bucket[].session.
name
string
bucket[].session.
description
string
bucket[].session.
startTimeMillis
long
bucket[].session.
endTimeMillis
long
bucket[].session.
modifiedTimeMillis
long
bucket[].session.
application
nested object
bucket[].session.application.
packageName
string
bucket[].session.application.
version
string
bucket[].session.application.
detailsUrl
string
bucket[].session.application.
name
string
bucket[].session.
activityType
integer
bucket[].session.
activeTimeMillis
long
bucket[].
activity
integer
Try it!
Use the APIs Explorer below to call this method on live data and see the response.