Filter methods

Use Ubidots field filters.

The Ubidots API supports requests that use 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 use these filters.

Filter methods

Filter method
Description
Usage
Arguments
Response

where

Applies a filter to 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 to multiple properties of the given entity

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

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

Depends on the <getMethod> used.

Using the where method

The example GET request at the top of this page can be reproduced with the library's where method:

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

Here:

  • <entity> = devices

  • <entity-property> = 'label'

  • <filter> = startsWith

  • <filter-value> = 'temp'

  • <getMethod> = get

Using the addRawParams method

The example GET request at the top of this page can be reproduced with the library's addRawParams method:

Here:

  • <entity> = devices

  • <queryObject> = filterParameters

  • <getMethod> = get

  • <queryParam1> = label__startswith

  • <value1> = 'temp'

Accessing the filters

API filters are written in snake case. For example, these object filters are supported:

  • contains

  • contained_by

  • has_key

To follow JavaScript's camel-case convention, the library's filters use camel case, so those same filters look like this:

  • contains

  • containedBy

  • hasKey

Below is the full list of filters, showing the API names and their library equivalents.

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

Was this helpful?