Read Aggregate Daily Nutrition Data

This section demonstrates reading the aggregate daily nutrition from a specific data source. The response contains a list of buckets (one per 24-hour period), each with a single dataset and datapoint that contains a field for all recorded nutrition data types. If no nutrition values exist for a particular time period, there is no dataset. If more than one meal_type is recorded, the value will be set to UNKNOWN.


Your app can read the aggregate daily nutrition data for a user by creating a data read request, and specifying the aggregate for the 'DataType.TYPE_NUTRITION' and 'DataType.AGGREGATE_NUTRITION_SUMMARY' data types, as shown in the following example:

val readRequest = DataReadRequest.Builder()
    .bucketByTime(1, TimeUnit.DAYS)
    .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)


Your app can read the aggregate daily nutrition data for a user by making a POST request and querying the specified data source. You must make a separate query for each data source.

HTTP method


Request URL

Request body

  "aggregateBy": [{
  "bucketByTime": { "durationMillis": 86400000 },
  "startTimeMillis": 1471244400000,
  "endTimeMillis": 1471259040000


If the data source is created successfully, the response is a 200 OK status code. The response body contains a JSON representation of the data source, including a datasource.dataStreamId property that you can use as the data source ID for subsequent requests.

CURL command

$ curl --header "Authorization: Bearer ya29.yourtokenvalue --request POST \
--header "Content-Type: application/json;encoding=utf-8" --data @aggregate.json \