Filter methods

Use Ubidots field filters.

The Ubidots API supports requests using field filters, like this:

GET https://industrial.api.ubidots.com/api/v2.0/devices/?label__startswith=temp

This library also provides a way to construct custom requests that take advantage of these filters.

Filter methods

Filter method
Description
Usage
Arguments
Response

where

Applies a filter on a single property of the given entity

Ubidots.<entity>.where(<entity-property>).<filter>(<filter-value>).<get-method>(, [args])

A valid property of the given entity

addRawParams

Applies filters on multiple properties of the given entity

Ubidots.<entity>.addRawParams(<query-object>).<get-method>(, [args])

query-object: object An object containing queryparam-value pairs

Using where method

The example GET request shown at the top of this page can be replicated using the library's where method, like this:

const tempDevices = await Ubidots.devices.where('label').startsWith('temp').get();

Here:

  • <entity> = devices

  • <entity-property> = 'label'

  • <filter> = startsWith

  • <filter-value> = 'temp'

  • <getMethod> = get

Using addRawParams method

The example GET request shown at the top of this page can be replicated using the library's addRawParams method, like this:

const filterParameters = {
  label__startswith: 'temp',
};
const tempDevices = await Ubidots.devices.addRawParams(filterParameters).get();

Here:

  • <entity> = devices

  • <queryObject> = filterParameters

  • <getMethod> = get

  • <queryParam1> = label__startswith

  • <value1> = 'temp'

Accessing the filters

API filters are written in snake-case. Take a look at some of the supported object filters for example:

  • contains

  • contained_by

  • has_key

In order to maintain the camel-case standard of JavaScript, the library's filters are written in camel-case, so the previous filters would look like this:

  • contains

  • containedBy

  • hasKey

Below you'll find the full list filters, as defined in the API vs. how they look in the library.

Filter in the API
Filter in the library

exact ( = )

exact

in

in

Filter in the API
Filter in the library

exact ( = )

is

isnull

isNull

Filter in the API
Filter in the library

exact

is

range

range

gt ( > )

greaterThan

gte ()

greaterThanEq

lt ( < )

lowerThan

lte ()

lowerThanEq

isnull

isNull

Filter in the API
Filter in the library

exact ( = ) (case sensitive)

exact

iexact (case sensitive)

iexact

contains

contains

icontains (case insensitive)

iContains

startswith

startsWith

istartswith (case insensitive)

iStartsWith

endswith

endsWith

iendswith (case insensitive)

iEndsWith

in (case sensitive)

in

isnull

isNull

Filter in the API
Filter in the library

exact ( = )

exact

contains

contains

contained_by

containedBy

overlap

overlap

len

len

isnull

isNull

Filter in the API
Filter in the library

contains

contains

contained_by

containedBy

has_key

hasKey

has_any_keys

hasAnyKeys

has_keys

hasKeys

isnull

isNull

Filter in the API
Filter in the library

exact ( = )

exact

date

date

year

year

quarter

quarter

month

month

week

week

day

day

hour

hour

minute

minute

second

second

isnull

isNull

Last updated