npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

losant-rest

v4.1.3

Published

REST client for accessing the Losant API

Readme

Losant Javascript REST API Client

Build Status npm version

The Losant REST API client provides a simple way to use the comprehensive Losant API. You can authenticate either as a Losant device or with your user account, and have access to all the functionality of the Losant platform.

This client works both in browsers and node.js (v20 and newer), and only supports promises. It uses Axios under the covers for the actual HTTP communication.

Installation

The latest stable version is available in NPM and can be installed using

npm install --save losant-rest

Example

Below is a high-level example of using the Losant JavaScript REST API client to authenticate against the Losant Platform and report state for a device.

import api from 'losant-rest';
import mySensor from './my-analog-sensor';

const client = api.createClient();
const {
  applicationId, token
} = await client.auth.authenticateDevice({ credentials: {
  deviceId: 'my-device-id',
  key: 'my-app-access-key',
  secret: 'my-app-access-secret'
}});

client.setOption('accessToken', token);
const sendSensorDataToLosant = async () => {
  const state = { data: { temperature: mySensor.read() }, time: Date.now() };
  return client.device.sendState({
    deviceId: 'my-device-id',
    applicationId: appId,
    deviceState: state
  });
};

setInterval(async () => {
  await sendSensorDataToLosant();
}, 60000);

API Documentation

const client = api.createClient({ accessToken: undefined, url: 'https://api.losant.com' });

The losant-rest module exposes a single function named createClient which returns a client instance. It takes the following options:

  • accessToken
    The access token to be used for authentication - by default there is no access token. An access token can be acquired through any of the Auth methods, or can be created for a particular application through applicationApiTokens.

  • url
    The url of the Losant API - by default https://api.losant.com.

Client

A client is a single api instance. By default, it is unauthenticated, but can be given an access token to perform authenticated requests.

Functions

  • setOption(name, value)
    The setOption function can be used to change any of the options currently set on the client, such as the access token.

  • getOption(name)
    The getOption function can be used to retrieve the current value of any of the options set on the client instance.

API Reference


Copyright (c) 2026 SUSE

https://www.losant.com