How to compute the lastupdate
In this article, we'll explain why we recommend using the lastupdate
system over relying solely on startdate
and enddate
parameters from the notifications payload. This method ensures that your platform stays synchronized with the most up-to-date health data, even in case of a notification failure.
Why Use lastupdate
?
While the startdate
and enddate
provided in the notification payload may seem convenient, they can lead to potential data gaps if a notification is missed. Such gaps could occur due to issues with your callback URL, your server, or even a temporary problem with Withings’ servers.
When this happens, you could miss out on data entirely unless you have an alternative system in place.
By using the lastupdate
system, you're no longer relying on real-time notifications alone. Instead, you're ensuring that even if there’s a disruption in the notification delivery, your system will still capture and process all relevant data.
This approach also gives you the flexibility to trigger updates on-demand, making it ideal for platforms that need real-time refresh capabilities, whether through a user interface or scheduled updates.
Compute lastupdate
Here's how it to compute your lastupdate:
-
Check the
max(modified)
: Look at the maximummodified
timestamp you’ve already stored for this data type. This represents the most recent data point you’ve processed. -
Make the API Call: When pulling new data from Withings, use this
max(modified)
as yourlastupdate
parameter. The API will then return all data that has been created or modified after this timestamp.