How to sort and filter REST API call response

UI options to control the order of items received via REST API

REST API calls results are presented in clean JSON format and can be easily exported to a .csv file. It is not possible to directly control the order of response you receive from flespi via REST API. However, filtering and sorting options are available in the ApiBox to help you customize the output, making it easier for a quick view and analysis. You can open ApiBox via tools menu in top-right corner of your flespi panel UI.

For instance, sending this basic GET /gw/devices/all request returns standard set of parameters for all devices in the account. Click on the 'table view' icon in the lower-right corner to switch from JSON view. 

Nevertheless, you can hide some columns while adding others to the response. Below, we will show how to customize the data output for various tasks.

For example, our task is to identify the devices in a specific group that never went online by some reason. In this case, the 'dev-selector' will include specific ‘groups.id’ value, and the 'fields' section should be populated with the ‘name’, ‘id’, and ‘last_active’ parameters. To access the drop-down menu, click the green '+' sign.

When the request is sent, switch to the table view and click on the ‘last_active’ column to sort the devices in ascending order by this parameter.

Additionally, you can apply filters in the output window, but keep in mind that it will consist only of the preselected parameters you’ve included in the request.

For example, you’d like to filter out only Concox devices that used maximum of message storage. In addition to 'id' and 'name', you also need the 'protocol_name' and 'message_size' parameters.

After you’ve performed the request, click on the ‘filter’ icon in the top-right, mark the ‘Protocol name’ checkbox, and fill in 'concox'. Then, click on 'messages_size' to sort.

Filters are applied on the go and wildcards are allowed. To clear a filter, just click on the name of the filter applied and confirm the deletion.


See also
How to add data generated by calculators to device messages
How to automate the process of forms creation for your web-project.