How to export the devices list to CSV?

Options to retrieve the devices list in an account or assigned to a group, channel, plugin or stream.

Retrieving data with a REST API call always results in a standard JSON output, but sometimes a fast-and-easy export to a human-readable format is required. While any operations to the devices via API are explicitly described in the Devices API documentation, in this article, we'll highlight some particular cases for retrieving the device data and exporting to CSV format.

Export devices list

If you need to export or sort a list of all devices in your account navigate to Gateway API > Devices > Manage section: 

Here you need to apply 'all' for the 'dev-selector' path and click on the 'eye' icon at the bottom to perform the REST API call.

Alternatively, you can get the same results by performing the following API call:

GET /gw/devices/all

A window will pop up, and then you can switch to the 'Table' view where you have the option to quickly sort the result by any column or filter out custom parameters. 

To sort all your devices by some column, for example by name or messages size, click on the corresponding column header in the table. Click again if you want to change the sort order.

Clicking the 'Export to CSV' icon on the upper-right will provide you with a .csv file.

Export devices list with selected parameters

By default, you receive the list of all default device parameters, but you may only require some of them. In this case, you can narrow down the search by specifying the desired parameters in the 'fields' section. For example, to export only the 'device id' and 'name', select them by clicking the '+' sign:

Or you can use the following request:

GET /gw/devices/all?fields=id,name

You may notice that some parameters are not listed here, but you can still manually add a required one by clicking the '{...}' icon and modifying JSON. For example, if we need to include the 'configuration.ident' parameter in our list of devices: 

Or perform the following request:

GET /gw/devices/all?fields=id,name,configuration.ident

Keep in mind that you can always switch to the table view in the output window to download a .csv file with the results.