How to use REST selectors effectively?

Different ways to address a subset of flespi items to apply the REST API request to.

Since flespi is a universal telematics API used in a variety of versatile projects, we try to make it maximally flexible in terms of API methods and their configuration. 

Here we will show how REST API selectors when used properly can make operations more efficient.

‘all’ keyword

“All” is used to apply the request to all instances of some entity type in the current account.

For example,

GET /gw/devices/all

will get all devices in the current account.

Important: if you decide to perform a request like GET /devices/all/messages and your devices store quite a lot of data, your account may be blocked because of too many REST API calls per minute (see restrictions).

Filtering by parameter

You can specify the parameter value to be matched for the request to apply to the given entity.

For example,

GET /gw/channels/protocol_name=teltonika

will get the list of all channels with “teltonika” protocol.

Note: the fields available for filtering differ for different entity types and can be found in the appropriate section of the documentation.

For instance, if you use a plugin to attach a static field (e.g. 'driver') to the device, you can then use the following request to filter the devices with the specific field value:

GET /gw/plugins/all/devices/fields.driver=value

Filtering by specific ids

You can list the specific IDs on the items you want to apply the request to.

For example,

POST /gw/devices/1,2,3,4/commands

will send commands into the devices with the specified IDs.

Note: logical AND condition is applied to comma-separated lists of values. 

Using wildcards

You can use wildcard chars * and ? in values in the request.

For example,

GET /gw/devices/configuration.ident=1234*/telemetry/all

will get the telemetry for devices with idents matching the wildcard mask.

Logical conditions

You can use the logical conditions to check the values of certain boolean parameters and apply requests to the matching entities.

For example,

GET /gw/channels/enabled=true

will give you a list of channels in active mode (use 'false' in the selector to get the list of inactive channels).


You can always check what specific filtering options are supported in the given selector, by expanding the selector info in APIBox:

flespi docs apibox selector info

See also
A detailed explanation of what we charge for, when, and on what conditions.
Manually posting messages into a flespi device.