I am using the Google FIT REST API via PHP SDK in order to query the store, fetch the sessions & dataset data, aggregate them and display for the user. In general it works however with automatically tracked activities I have a lot of discrepancies (including time, steps, distance and calories).
Questions:
- Where do automatically detected activities come from?
- How to overcome this and properly query for "autoamtically detected" activities in Google FIT?
- How do they do that (the aggregate from within the app) ?
Scopes granted:
https://www.googleapis.com/auth/fitness.activity.read
https://www.googleapis.com/auth/fitness.location.read
The data from the google fit App: Activity (running): 14 april, 15:41 - 16:00, steps: 2802, calories: 203, move minutes: 19
Aggregated data given for session by calling the /aggregate endpoint: Params:
[
'startTimeMillis' => '1618358400000',
'endTimeMillis' => '1618444799000',
'aggregateBy' => [
["dataTypeName" => "com.google.active_minutes"],
["dataTypeName" => "com.google.calories.expended"],
["dataTypeName" => "com.google.step_count.delta"],
["dataTypeName" => "com.google.distance.delta"]
]
]
Response:
{
"id": "...:activemode:running:...",
"start": "1618408461088",
"startDate": {
"date": "2021-04-14 15:54:21.000000",
"timezone_type": 3,
"timezone": "Europe\/Warsaw"
},
"end": "1618408901980",
"endDate": {
"date": "2021-04-14 16:01:41.000000",
"timezone_type": 3,
"timezone": "Europe\/Warsaw"
},
"name": "bieganie po po\u0142udniu",
"description": null,
"sum": {
"minutes": 7,
"calories": 380.7721481323242,
"distance": 3934.6239171028137,
"steps": 3363
},
}
Aggregated data fetched from Sessions API (and normalized):
{
"activeTimeMillis": null,
"activityType": 8,
"description": "",
"endTimeMillis": "1618408901980", // normalizes to 14 April 2021 16:01:41
"id": "...:activemode:running:...",
"modifiedTimeMillis": "1618411492587",
"name": "bieganie po po\u0142udniu",
"startTimeMillis": "1618408461088", // normalizes to 14 April 2021 15:54:21
"application": {
"detailsUrl": null,
"name": null,
"packageName": "com.google.android.apps.fitness",
"version": null
}
},