Filter methods

Use Ubidots Field filters

Just as the Ubidots API supports requests using Field filters as:

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 said filters.

Filter methods

Filter methodDescriptionUsageArgumentsResponse

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

Depends on the <getMethod> used

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

{
  queryParam1: value1 
  ···    
  queryParamN: valueN
}

Depends on the <getMethod> used

Using where method

The example request above can be performed using where as:

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 request above can be performed using addRawParams as:

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

Note from the API definition that the 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 in Javascript, the library's filters are written in camel-case, so the filters above would look like:

  • contains

  • containedBy

  • hasKey

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

Filter in the APIFilter in the library

exact ( = )

exact

in

in

Filter in the APIFilter in the library

exact ( = )

is

isnull

isNull

Filter in the APIFilter in the library

exact

is

range

range

gt ( > )

greaterThan

gte ()

greaterThanEq

lt ( < )

lowerThan

lte ()

lowerThanEq

isnull

isNull

Filter in the APIFilter 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 APIFilter in the library

exact ( = )

exact

contains

contains

contained_by

containedBy

overlap

overlap

len

len

isnull

isNull

Filter in the APIFilter in the library

contains

contains

contained_by

containedBy

has_key

hasKey

has_any_keys

hasAnyKeys

has_keys

hasKeys

isnull

isNull

Filter in the APIFilter 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