How to Query Results

Summary

You can query the results of a GET request in our API with specific parameters. Many of those listed below can meet use cases where only specific data is required. For larger data sets, read the Cursor section to learn how to obtain a consistent sort order in the data response.

ParameterPurposeExample
?whereTo pass a string containing a JavaScript expression/locations?where={"account":"5f327*****f5cd5"\}
max_resultsThe limit is 500 results. Only 25 results are returned if this parameter is not set.?max_results=500
sortSpecify the order in which the query returns the results. Add - for descending e.g. sort=-_created and without for ascending sort=_created?sort=-_created
cursorView the Cursor section. ?cursor=new
$eqThe value of the specified field is equal to a specified value
$gteThe value of the specified field is greater than or equal."$gte": "YYYY-MM-DDTHH:mm:ss.SSSSSSZ"
$lteThe value of the specified field is lesser than or equal."$lte": "YYYY-MM-DDTHH:mm:ss.SSSSSSZ"
$sizeTo match an array to a specified number of elements.{"$size":5}
$inThe value of the specified field is equal to any value in the specified array"$in":[1, 2]
$neResults are returned where the specified value does no exist."$ne":"5be9*********46d4"
$existsA boolean to filter out results where a value exists or not."$exists": true,

Cursor

When sending a query that returns paged results but no sorting is requested, Deliverect returns the results with a warning:

"`warning": "For more correct paged results, please use sort, cursor or preference"

When paging through results with each page request, our database won't always return the data in the same order.

While you could use ?sort=-_created to return a consistent order, we recommend that you query using &cursor=new as this has more reliability.

Here is an example of a Get Locations query:

https://api.deliverect.com/locations?where={"account":"61*********34"}&cursor=new&max_results=500

This provides within the first page of results a "cursor" ID (view the example below).

All subsequent calls should then pass this ID as &cursor={CURSOR_STRING_FROM_META} to ensure you are retrieving data from our database using the same cursor point.

},  
    "_meta": {
    "page": 1,
    "max_results": 500,
    "total": 584,
    "cursor": "e8c9b36f***ccfbeff08fe"
}

To page through to the next set of results, subsequent requests would be sent using:

https://api.deliverect.com/locations?where={"account":"61******34"}&cursor=e8c9b36f****eff08fe&max_results=500&page=2