> For the complete documentation index, see [llms.txt](https://dev.ubidots.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ubidots.com/dashboards-and-widgets/html-canvas/built-in-library/api.md).

# API

## JavaScript SDK

The HTML Canvas built-in library exposes the [Ubidots JavaScript SDK](/sdks/javascript.md) 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>
```

{% hint style="info" %}
See the [JavaScript SDK docs](/sdks/javascript.md) for supported entities, methods, and filtering capabilities.
{% endhint %}

## Usage

**With** [**Preload dashboard data**](/dashboards-and-widgets/html-canvas/preload-dashboard-data.md) **enabled:**

```javascript
// 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:**

```javascript
var ubidots = new Ubidots();

let TOKEN;

ubidots.on("ready", async () => {
    TOKEN = ubidots.token;
    
    // Authenticate the SDK with the token
    ubidots.api.authenticate(TOKEN);
    
    // Get the first 100 devices in the account
    var devices = await ubidots.api.devices.get();
    
    // Print an array of Device objects
    console.log(devices);
    
    // YOUR LOGIC FOR THESE 100 DEVICES
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dev.ubidots.com/dashboards-and-widgets/html-canvas/built-in-library/api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
