0

While using the Google Fit Rest API for the fitness activities, It gives me the data of the previous days with appropriate step count but not able to gives the current day's count. Even in my mobile, Google Fit sync process was running properly and my internet was running good.

If I force sync(manually) then it can start to give the current day's step count and other activities data. Otherwise, It can only show the data around before 9 o'clock(or daily first sync cycle). After that, It can only update the step count on the next day with the same time frame in API response.

Following I have shared the API details with required parameters:

HTTP method : POST

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

Request body :

{
  "aggregateBy": [{
    "dataTypeName": "com.google.step_count.delta",
    "dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
  }],
  "bucketByTime": { "durationMillis": 86400000 },
  "startTimeMillis": 1559154600000,
  "endTimeMillis": 1559241000000
}

Response :

{
 "bucket": [
  {
   "startTimeMillis": "1559154600000",
   "endTimeMillis": "1559241000000",
   "dataset": [
    {
     "dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:aggregated",
     "point": [
      {
       "startTimeNanos": "1559181787309598125",
       "endTimeNanos": "1559183772877349957",
       "dataTypeName": "com.google.step_count.delta",
       "originDataSourceId": "raw:com.google.step_count.cumulative:Realme:RMX1833:355d9abc461f5254:STEP_COUNTER",
       "value": [
        {
         "intVal": 233,
         "mapVal": []
        }
       ]
      }
     ]
    }
   ]
  }
 ]
}

Current, It can show only 233 steps count from morning while Google Fit application show me the 4674 steps. How can I get the same figure as Google Fit App can display?

enter image description here

  • It can only give you data from the last point it was synced. That's why you see the data after forcing a sync. – Tony Abrams May 30 '19 at 11:01
  • @TonyAbrams So, How can I see the current steps count without force sync? – Prabhjyot Saini May 30 '19 at 11:05
  • The only way is by running on the same device, and reading the google data stored on the device. – Tony Abrams May 30 '19 at 11:08
  • @TonyAbrams Do you have any reference link or code for understanding your thoughts? Because I have to implement this thing into a Web App. So, Can you please guide me to get that appropriate response at Web App? – Prabhjyot Saini May 30 '19 at 11:15
  • 1
    Sadly, there is nothing you can do from a Web App that will cause you to get the non-synced data from a Google Fit App running on someone's device. You can only get what someone has synced up to Google. – Tony Abrams May 30 '19 at 11:19
  • I'm having a problem, my response from API, field point come empty, someone can help me? or tell me what i can do? – Pedro Pinheiro Mar 16 '20 at 12:28

0 Answers0