List and Query endpoints that return a list of entities allow you to specify sorting and paging options in the request.
This articles gives a general overview of sorting and paging. The implementation changes depending on whether an endpoint is a GET or POST request. Check your API's documentation for specific details, including which fields are sortable.
Most APIs default to sorting by createdDate
in DESC
(descending) order,
although some APIs have a different default sort order.
You can override the default sorting by specifying
a new field and order.
List endpoints are designed to be lightweight HTTP GET requests.
For this reason, sorting is applied through the query parameters,
typically with sort.fieldName
and sort.order
.
For example, to list contacts by last name in ascending order, append these query parameters to the request:
Your API's List endpoint may support sorting by multiple fields.
This is done by adding a new &sort.fieldName
and &sort.order
parameter
for each sort field:
Query endpoints offer more robust filtering capabilities.
When working with a Query endpoint,
sorting is specified in an array in the request body,
typically query.sort
.
For each sort
object,
sorting is applied with the fieldName
and order
parameters.
For example, to list contacts by last name in ascending order, include this structure in the request body:
The standard Wix API pagination includes:
limit: amount of items per response (default is 0
)
offset: number of items to skip
The following examples:
and
Should return items 21-120 in the results.