google-fitgoogle-fit-sdk

How to get Heart points in google fit REST API


I am trying to get heart points from google fit REST API. I see that heart rate data in google fit app (110 bmg) but i am getting empty data through the API.

API: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate

BODY:

{
  "aggregateBy": [{
    "dataTypeName": "com.google.heart_rate.bpm",
    "dataSourceId": "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes"
  }],
  "bucketByTime": { "durationMillis": 86400000 },
  "startTimeMillis": 1580533200000, // feb 01 2020
  "endTimeMillis": 1582866000000 // feb 28 2020
}

Result :

i am getting empty records like :

{
    "bucket": [ 
....
{
            "startTimeMillis": "1580619600000",
            "endTimeMillis": "1580706000000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.heart_minutes.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
....
    ]
}

Am i missing anything?


Solution

  • Never mind, I got it. It took some time to update the API i guess, I had to update the body:

    {
      "aggregateBy": [{
        "dataTypeName": "com.google.heart_minutes"
        //"dataSourceId": "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes"
      }],
      "bucketByTime": { "durationMillis": 86400000 },
      "startTimeMillis": 1580533200000, // feb 01 2019
      "endTimeMillis": 1580878800000 // feb 6 2020 1582866000000 // feb 28 2020
    }