Sorting

This section:

  • Explains what sorting is
  • Defines the sorting parameters that are available to use
  • Provides examples calls that include sorting parameters



What is sorting?

Sorting allows you to order results by a selected field in either ascending or descending order. For example, if you make a call asking for every user on your account, you may want to sort the results by the date at which users last accessed the platform. 

Info

Sorting is not supported for every endpoint.

Where it is supported, the fields that can be sorted are highlighted in the endpoint's Reference documentation.



Sorting parameters

The sorting parameters supported by the API include:

ParameterDescription
orderBy

This parameter is used to select the field to sort by and to define whether results are sorted in ascending or descending order.

The supported sort directions are "asc" for ascending order and "desc" for descending order.



Example calls

The following examples demonstrate how to structure a call using sorting parameters.

API Call with an Ascending Sort Parameter
GET "https://api.iot-x.com/users?orderBy=lastAccessDate ASC"
API Call with a Descending Sort Parameter
GET "https://api.iot-x.com/users?orderBy=lastAccessDate DESC"
API Call with Multiple Sort Parameters
GET "https://api.iot-x.com/subscribers/active?orderBy=connectionDate ASC, tariff DESC"