07-20-2016 07:37
07-20-2016 07:37
This post is mainly target to the Fitbit Web API team.
My team is currently working on making use of the Subscription API which is absolutely great. However, we are facing the problem that we cannot completly entirely rely on that mechanism as messages could be missed due to unexpected reasons (e.g. network problems). So, that forces any application that wants to integrate Fitbit to developed a bulk import data process that runs on a regular basis.
The goal of that import process is to be as efficient as possible and minimize the amount of data we pull from Fitbit API and also to make it as fast as hell.
We reached to the conclusion that bulk process could ask one simple question to determine if it needs to pull data for a specific user:
Is there any new data that has been added or updated for this user?
As far as we know, there are only 2 ways for producing or generating data in Fitbit:
We know when each device sends or updates data in Fitbit thanks to the Last Sync Time property from the Devices endpoint.
Unfortunately, there is no way to get the Last Sync Time for Self-entered data.
I strongly believe that if Fitbit API would have a way of obntaining that information, applications that currently uses the API would benefit big time from this. Moreover, this would mean that the Fitbit API would see a direct and significant reduction of messages coming through. Hence, Fitbit would require less infrastructure to deal with incoming traffic.
What are your thoughts about this?
07-20-2016 11:57 - edited 07-20-2016 11:57
07-20-2016 11:57 - edited 07-20-2016 11:57
Perhaps using the Activity Logs List endpoint to pull 'x' amount of activities after last known device sync would be useful? If they've synced their device then manual activities should also be synced up to that point, so you really only need to check for manual activities after last sync.
For example, say my last sync date was on 2016-06-01, I can use this endpoint to grab activities (up to 20) after that date:
https://api.fitbit.com/1/user/-/activities/list.json?afterDate=2016-06-01&offset=0&limit=20&sort=asc
You can also do the reverse of that and grab recent activities before the current day (or entered date):
https://api.fitbit.com/1/user/-/activities/list.json?beforeDate=today&offset=0&limit=20&sort=desc
Which I guess is only helpful if you know the last activity that's previously been synced.
I don't know if that helps, just my thoughts on it.
07-20-2016 12:37
07-20-2016 12:37
Thanks @AndrewFitbit for your quick reply. What you mention makes sense but we could be missing activities data that a user self-entered through the mobile app that is older than the Last Sync Time of the device.
What would happen with users that don't have a Fitbit device and just use the Fitbit mobile app to track of Activities, Weight and Food?
The user story would be something like this: If a user uses his Fitbit mobile app to add/update Weight, Food or Sleep that is 4 days old or even older.
How can we smartly and efficiently pull information assuming that messages from the Subscription API were missed due to network problems?
How hard would it be from a Fitbit Web API perspective to expose an endpoint to get the last time a Fitbit user manually updated information?
07-20-2016 13:55
07-20-2016 13:55
@FedericoArg Ah I was only thinking of activities...sorry.
FedericoArg wrote:How hard would it be from a Fitbit Web API perspective to expose an endpoint to get the last time a Fitbit user manually updated information?
I'll have to get back to you on that.