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=tempThis library also provides a way to construct custom requests that use these filters.
Filter methods
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.
ID
exact ( = )
exact
in
in
Boolean
exact ( = )
is
isnull
isNull
Number
exact
is
range
range
gt ( > )
greaterThan
gte (≥)
greaterThanEq
lt ( < )
lowerThan
lte (≤)
lowerThanEq
isnull
isNull
String
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
Array
exact ( = )
exact
contains
contains
contained_by
containedBy
overlap
overlap
len
len
isnull
isNull
Object
contains
contains
contained_by
containedBy
has_key
hasKey
has_any_keys
hasAnyKeys
has_keys
hasKeys
isnull
isNull
Date
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?