Ubidots class
Ubidots JavaScript library's main class.
Definition
The Ubidots
class is the entrypoint of the library, providing sub-classes for interacting with each particular supported entity from the API. For example, to use the devices API you can do:
Ubidots.devices.<methods>
Here, the methods exposed by the devices
sub-class allow you to consume the whole devices API.
Ubidots
class properties
Ubidots
class propertiesdevices
Provides access to devices API.
variables
Provides access to variables API.
dashboards
Provides access to dashboards API.
users
Provides access to users API.
organizations
Provides access to organizations API.
Ubidots
class methods
Ubidots
class methodsauthenticate
A valid Ubidots token.
Authenticates with the Ubidots API.
Usage
Authentication
Authentication using a valid Ubidots token is mandatory to use the library:
Ubidots.authenticate('BBFF-ubidots-token');
Instantiation
This class is implemented as a singleton which is instantiated when it is exported, thus, there is no need for creating an instance of it. Instead, you must use it directly:
// Import the class
const { Ubidots } = require('@ubidots/ubidots-javascript-library');
// Call 'authenticate' method with no prior instantation of 'Ubidots'
Ubidots.authenticate('ubidots-valid-token');
General syntax
As stated before, the Ubidots class exposes its methods through entities
for a particular part of the API such as devices or variables, thus providing the following syntax:
Ubidots.<entity>.<getMethod>(, [args]);
Filters syntax
Field filtering is available for each entity
through the following syntax:
Ubidots.<entity>.<filterMethod>(args).<getMethod>(, [args]);
Here:
Last updated
Was this helpful?