Getting started

Install and import UJ

Installation

Run either of the following commands on the root of your project depending on the package manager that you use:

Npm

npm install @ubidots/ubidots-javascript-library --save-dev

Yarn

yarn add @ubidots/ubidots-javascript-library [--dev/-D]

Importing the library

Depending on your project being JS or TS based, import the library as:

Javascript

const { Ubidots } = require('@ubidots/ubidots-javascript-library');

Typescript

import { Ubidots } from '@ubidots/ubidots-javascript-library';

Usage

// Import the library using the correct syntax as outlined above
const { Ubidots } = require('@ubidots/ubidots-javascript-library'); // Javascript import
//import { Ubidots } from '@ubidots/ubidots-javascript-library'; // Typescript import

// Authenticate with the API
Ubidots.authenticate("<ubidots-token>");


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

Last updated