nrfCloud Location History via REST API

Hi,

When calling https://api.nrfcloud.com/v1/location/history, The records start chronologically from old to new. Is there a way to only get the most recent location update instead of having to fetch all the pages to get to it? Alternatively, is it possible to change the sort order so that location history is returned "new-to-old" instead of "old-to-new"?

Kind Regards,
Iman Biglari

  • Hello,

    Is there a way to only get the most recent location update instead of having to fetch all the pages to get to it?

    The API documentation mentions a "pageLimit" parameter that can be used to limit the number of pages. Have you tried that? I'm not sure if it will return the most recent pages though.

  • 0
    56 pts.
    in reply to Hakon

    Hi Hakan,

    I'm afraid using pageLimit does not change the order of entries returned. Oldest position report is still the first record returned.

    What I need is a way to fetch device's latest reported position only, regardless of its source (A-GPS / GNSS). Does such a function exist in your REST API?

    I have been working on my own cloud driver to replace nrfCloud / AWS / Azure driver that comes with asset_tracker_v2, but couldn't find an easy way to merge the changes in 1.7x branch into my code (which was based on 1.6.1). That's why I decided to revert back to nrfCloud and try and fetch the location data via REST API.

  • Improvements to this endpoint that give you the functionality you want are complete, including sorting and date range queries. We also added a way to only get the latest location for all devices in your account with a single request.

    These improvements are not deployed to production yet. Expect it sometime in the next 2-3 weeks. 

  • Hi Patrick,

    That's good news. Do these improvements include GNSS position reports as well?

    Kind Regards,
    Iman

  • Yes, as long as the device reports its position (for a GPS-based location is calculated on the device). Devices report position over MQTT or via the SendDeviceMessage REST endpoint by sending a GPS message per this schema: https://github.com/nRFCloud/application-protocols/blob/v1/schemas/deviceToCloud/gps/gps.json. When the changes to the GetLocationHistory endpoint are deployed, we will also deploy JWT support for the SendDeviceMessage endpoint so that devices using REST can also send GPS messages that get stored in their location history.

Related