Introduction
API Query options
Options
Sorting
Change the order of the response.
As a query, use: 'OrderBy' to sort fields. You can sort based on one or more fields. For example to sort Channels based on 'id' field descending & 'unit' ascending you can use:
/measurements/eancodes/871234567890123456/Channels?OrderBy=id desc, unit
Pagination
When the data is too long a pagination can be used.
As a query, use: 'PageNumber' && 'PageSize' to paginate lists. Page size is how many objects you want to receive, Page number is which page to return. For example, if we want the first page of Channels with a page size of 10 you can use:
/measurements/eancodes/871234567890123456/Channels?PageNumber=1&PageSize=10&OrderBy=id desc,unit
notee that, pagination can be used in combination with other queries like sorting and data shaping.
Retuned header: "x-pagination"
For you to check if there is a next page or a previous one, or to know which page size or page number were used, you can check the 'x-pagination' response header. It's Json format and text escaped. It will preserve your filters e.g:
content-type: application/json; charset=utf-8
date: Thu,04 Aug 2022 08:21:14 GMT
server: Kestrel
x-pagination:
{
"totalCount":3,
"pageSize":2,
"currentPage":2,
"totalPages":2,
"previousPageLink" : ".../measurements/EanCodes/8712345678901234561/Channels?fields=id,%20unit%20\u0026orderBy=id%20desc,%20unit\u0026pageNumber=1\u0026pageSize=2",
"nextPageLink":null}
Data Shaping
Make it possible to not return all the data objects.
As a query, use: 'Fields' to get an object with only info you need. For example: to get list of channels ids and unit, you can input: fields=id, unit
/measurements/eancodes/871234567890123456/Channels?PageNumber=1&PageSize=10&OrderBy=id desc,unit&Fields=id, unit
Note that, shaping can be used in combination with other queries like sorting and pagination
Search Query
As a query, use: 'SearchQuery' to get objects that may contain a certain value For example: to get list of channels that has has the letters 'Kwh' in it we add query "SearchQuery=kwh"
/measurements/eancodes/871234567890123456/Channels?SearchQuery=kwh
Note that, Search can be used in combination with other queries like sorting, shaping and pagination