pagination

Limiting, scrolling and pages

To interact with lists in platform we are using few query string and header properties like:

  • from - represents element number to begin with
  • size - maximum number of elements

example for given list:
beacon1, beacon2, beacon3, beacon4, beacon5, beacon6, beacon 7, beacon 8, beacon 9

from=2&size=2 will skip two elements and return next two:
beacon3, beacon4

You can also provide only size and page property to say that you want X page and page size is Y like:
size=2&page=3 will skip six elements (page 3 * page size 2) and return two elements (page size 2:
beacon 7, beacon 8

How long is my list? X-Total-Count

With every list response system will send you custom header X-Total-Count with total number of elements on the list

Sorting

It is usually possible to sort elements in the list. To do so please define sort query string. Let's create few examples for list of applications. In documentation you will find that it is possible to define sort query string with possible values: name, platform, api_key, url

to sort this list by platform you need to set query string sort to this value like this:
sort=platform

to reverse order
sort=-platform

to apply advanced sorting
sort=platform-url+name

please note that natural order represented by '+' is default order so you can skip it for first field

# to get page 10 where page size is 5 sorted by platform and later
# by name by in reverse order execute this command
curl -H "X-Auth-Token:token" https://connect.sensorberg.com/api/applications?page=10&size=5&sort=platform-name