API

Access the Ubidots JavaScript SDK from HTML Canvas

JavaScript SDK

The HTML Canvas built-in library exposes the Ubidots JavaScript SDK through ubidots.api. This simplifies interactions with the Ubidots API when you develop in HTML Canvas. It avoids manual requests and custom wrappers.

Use the following syntax to access SDK methods:

ubidots.api.<JS_SDK_METHODS>

See the JavaScript SDK docs for supported entities, methods, and filtering capabilities.

Usage

With Preload dashboard data enabled:

// Get the token from the Ubidots built-in library
const TOKEN = ubidots.token;

// Authenticate the SDK with the token
ubidots.api.authenticate(TOKEN);

// Get the first 100 devices in the account
ubidots.api.devices.get().then((devices) => {
    // Print an array of Device objects
    console.log(devices);
    
    // YOUR LOGIC FOR THESE 100 DEVICES
});

With Preload dashboard data disabled:

Last updated

Was this helpful?