Using the Command Line API to limit, sort, and offset values returned


When utilizing FileWave's Command Line API to extract inventory information, you may find the need to limit the values returned, sort the data, or return results that are offset by a certain number of values.

Because it can be a topic that can trip someone up it is important to note that API calls are normally done on TCP 443. You may see references to 20445 in some documentation, but that is the Command Line API (v1) and it is on TCP 20445 however you can make a small change in the URL for the API endpoint and use TCP 443 for all calls by prepending /api/ on to the /inv/api/ URLs to make it /api/inv/api/ in the URLs.


FileWave Command Line API (v1)


The following examples include the pipe to Python to make the output multiple line.  Remove this pipe if Python is not installed.  This also assumes 'python3' is pathed, such that the full path is not required.

Limit Values

Syntax required to limit the number of values returned in a query to a value of 25:

curl -s -H "Authorization: not_the_real_key_here" https://<your_server_fqdn>:20445/inv/api/v1/query_result/<queryID>?limit=25 | python3 -mjson.tool

Of course, you can modify the number of values returned to any number that you like. 

Sort Values

You can also sort the results of data returned based on the <column_name> value. For example, to sort the results returned by "device name", ascending: 

curl -s -H "Authorization: not_the_real_key_here" https://<your_server_fqdn>:20445/inv/api/v1/query_result/<queryID>?sort=device_name | python3 -mjson.tool

To do the same sort, but in descending order (note the "-" in front of the column name):

curl -s -H "Authorization: not_the_real_key_here" https://<your_server_fqdn>:20445/inv/api/v1/query_result/<queryID>?sort=-device_name | python3 -mjson.tool

Offset Values

In order to return only a subset of results, offset by some initial number of values returned, you can apply the below syntax:

curl -s -H "Authorization: not_the_real_key_here" https://<your_server_fqdn>:20445/inv/api/v1/query_result/<queryID>?offset=300 | python3 -mjson.tool

The above example will return all values, starting from the 300th value.

Revision #5
Created 4 July 2023 14:44:12 by Sean Holden
Updated 22 April 2024 17:23:04 by Josh Levitsky