google-sheetsgoogle-apigoogle-fitgoogle-fit-apigoogle-fitness-api

Google Fit Api: Move Minutes Count


I am working with google api to export my Google Fit data to a Google Sheet. I have managed to get the Step count, calories, distance and heart points data exported correctly. However, I am not able to generate the Move Minutes count and the Walking time. I know that these data exist as I have already performed the export using google takeout.

I adapt the code from https://ithoughthecamewithyou.com/post/export-google-fit-daily-steps-to-a-google-sheet, adding the following lines.

var request = {
    "aggregateBy": [
      {
        "dataTypeName": "com.google.step_count.delta",
        "dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
      },
      {
        "dataTypeName": "com.google.distance.delta",
        "dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:merge_distance_delta"
      },
      {
        "dataTypeName": "com.google.calories.expended",
        "dataSourceId": "derived:com.google.calories.expended:com.google.android.gms:merge_calories_expended"
      },
      {
        "dataTypeName": "com.google.active_minutes",
        "dataSourceId": "derived:com.google.active_minutes:com.google.android.gms:merge_active_minutes"
      },
      {
        "dataTypeName": "com.google.heart_minutes",
        "dataSourceId": "derived:com.google.heart_minutes:com.google.android.gms:merge_heart_minutes"
      }
    ],
    "bucketByTime": { "durationMillis": 86400000 },
    "startTimeMillis": start.getTime(),
    "endTimeMillis": end.getTime()
  };

As I said, I have managed to correctly export the data relating to Step count, calories, distance and heart points, i.e. points 1, 2, 3 and 5 of the code. For the Move Minutes count and the Walking time, I tried to see if any of them worked with point 4 of the code (as indicated in https://developers.google.com/fit/datatypes/activity?hl=en), but nothing comes out.

Does anyone know how to get the Move Minutes count and the Walking time?


Solution

  • The platform will only return data that has values. Try to insert sample records first, then read the values back again.

    https://developers.google.com/fit/datatypes/activity?hl=en#rest