Accessing the Latest Information
By default, bulk data calls are ordered by the timestamp of an individual activity. The challenge here is that if an individual was on vacation for a week and syncs a device upon returning, how will you know of data that occurred a week ago but only just made it into the Validic system?
The latest
endpoint gives you the latest data recorded and updated in Validic, regardless of when the activity occurred based on the last_updated field. For example, if you pulled and processed Validic data at 4:00 a.m., and then you want to update your system again at 8:00 a.m., you can specify to only receive new and updated data that was added to our system between 4 a.m. and 8 a.m. by appending a timestamp with the start_date
and end_date
.
The following returns the most recently recorded/updated fitness activities for all users of an Organization that were recorded/updated between start_date
and end_date
:
GET https://api.validic.com/v1/organizations/5176906c6deddac02c000001/fitness/l atest.json?start_date=2013-06-01T04:00:00-04:00&access_token=e61467e3845e8a 66f7453dc55ea3fc445d1b879a6f96ebe7b243badbeae04f63 200 { "summary": { ... }, "fitness": [{ "_id": "5176903b6dedda539c000001", "timestamp": "2013-06-01T04:07:01+00:00", "utc_offset": "-05:00" "type": "Running", "intensity": "high", "start_time": null, "distance": 2242.74, "duration": 1683, "source": "sample_app", "source_name": "Sample App", "last_updated" : "2013-06-01T04:07:01+00:00",
Latest.json Example:
A best practices implementation of /routine/latest.json calls would look something like this:
/routine/latest.json?start_date=2014-03-09T10:00:00Z&end_date=2014-03-09T10:04:59Z / routine/latest.json?start_date=2014-03-09T10:05:00Z&end_date=2014-03-09T10:09:59Z /r outine/latest.json?start_date=2014-03-09T10:10:00Z&end_date=2014-03-09T10:14:59Z /ro utine/latest.json?start_date=2014-03-09T10:15:00Z&end_date=2014-03-09T10:19:59Z /rou tine/latest.json?start_date=2014-03-09T10:20:00Z&end_date=2014-03-09T10:24:59Z /rout ine/latest.json?start_date=2014-03-09T10:25:00Z&end_date=2014-03-09T10:29:59Z /routi ne/latest.json?start_date=2014-03-09T10:30:00Z&end_date=2014-03-09T10:34:59Z /routin e/latest.json?start_date=2014-03-09T10:35:00Z&end_date=2014-03-09T10:39:59Z /routine /latest.json?start_date=2014-03-09T10:40:00Z&end_date=2014-03-09T10:44:59Z /routine/ latest.json?start_date=2014-03-09T10:45:00Z&end_date=2014-03-09T10:49:59Z
The benefit of this series of calls is that you ping Validic every five minutes (could be every 2 minutes, every 10 minutes, etc.) and you receive any updates that have been made for your organization in the specified time range. So for example, if a user doesn’t sync her Fitbit for 5 days and then syncs it on 2014-03- 09T10:47:39Z, Validic will return all of her Fitbit activities from the last 5 days in the last call in the series above.
Latest.json vs Push Notifications
Please refer to our Knowledge Base Article for further information regarding discussion around leveraging the latest.json call vs push notification service and user level data calls.