Collections and pagination
API supports paging, filtering, sorting on big lists (GET operation on collection resources). Paging, filtering, and sorting are handled as query parameters in requests, while meta data describing the response are returned as header parameters.
Only the collection GET requests that handle large datasets implement this feature.
Paging
Paging accepts query parameters that specify:
per_page- maximum number of resources to be retrieved within a single response (page size)- If
per_pageis < 1 the default page size is used per_pageis set to a predefined maximum value if it’s too big
- If
page- number of returned chunk within the complete set (page#).- If the requested page doesn’t exist the first (for page < 1) or the last page (for page >
last_page) is returned
- If the requested page doesn’t exist the first (for page < 1) or the last page (for page >
The response header contains:
Link- URLs for navigational links used to retrieve first, previous, next and last page in a datasetX-Count-Per-Page- Requestedper_pageparameterX-Current-Page- Current page number within the setX-Total-Count- Total element count in the datasetX-Total-Pages- Total pages count in the dataset
Example
Request
Response header
Link header should contain any (optional) filter, sort, and expansion query parameters.
Filtering
Filtering criteria is included in the request URL as q query parameter which accepts a comma-separated list of field:criteria pairs.
The following example demonstrates a GET request to /api/v1/endpoint.
The q parameter then has the following query parameters:
status=0name=arduino
To form this request, the following pattern would be required:
/api/v1/endpoint?q=status:0,name:arduino
A valid curl for a query of this type would look like the following:
When using query parameters, the following match patterns apply to queries:
If filtering is applied the header contains:
X-Filter- filter criteria
Sorting
Sorting criteria is included in the request URL as {sort} parameter as a comma separated list of sorting properties.
The default sort order is ascending.
Descending order is specified with - (dash).
If sorting is applied the header contains:
X-Sort- sort criteria