Chapter 4. Sorting in the API
To give you examples that are easy to follow, we use the following URL throughout this guide:
https://<gateway server name>/api/controller/v2/groups/
https://<gateway server name>/api/controller/v2/groups/
Procedure
To specify that {{ model_verbose_name_plural }} are returned in a particular order, use the
order_byquery string parameter on theGETrequest:https://<gateway server name>/api/controller/v2/model_verbose_name_plural?order_by={{ order_field }}https://<gateway server name>/api/controller/v2/model_verbose_name_plural?order_by={{ order_field }}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Prefix the field name with a dash (
-) to sort in reverse:https://<gateway server name>/api/controller/v2/model_verbose_name_plural?order_by=-{{ order_field }}https://<gateway server name>/api/controller/v2/model_verbose_name_plural?order_by=-{{ order_field }}Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can specify the sorting fields by separating the field names with a comma (
,):https://<gateway server name>/api/controller/v2/model_verbose_name_plural?order_by={{ order_field }},some_other_fieldhttps://<gateway server name>/api/controller/v2/model_verbose_name_plural?order_by={{ order_field }},some_other_fieldCopy to Clipboard Copied! Toggle word wrap Toggle overflow