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

@xshore/telemetry-client

v1.0.1

Published

TypeScript client for the X-Shore Thingsboard telemetry API at telemetry.xshore.com

Readme

@xshore/telemetry-client

TypeScript client for the X-Shore Thingsboard PE telemetry API at telemetry.xshore.com.

Install

npm install @xshore/telemetry-client

Quick start

import { ThingsboardClient, TelemetryKeys, BASE_URL } from '@xshore/telemetry-client';

// Authenticate with an API key (create one in Thingsboard → Account Settings → Security)
const client = new ThingsboardClient(BASE_URL, {
  apiKey: process.env.XSHORE_API_KEY,
});

// Or log in with username and password
await client.login('[email protected]', 'password');

// Scoped telemetry — no need to repeat 'DEVICE' on every call
const tel = client.telemetry.forDevice(deviceId);

const latest = await tel.getLatest([
  TelemetryKeys.HVBAT_SOC,
  TelemetryKeys.GPS_LATITUDE,
  TelemetryKeys.GPS_LONGITUDE,
  TelemetryKeys.VCU_STATE,
]);

const history = await tel.getHistory({
  keys: [TelemetryKeys.HVBAT_SOC],
  startTs: Date.now() - 24 * 60 * 60 * 1000,
  endTs: Date.now(),
  agg: 'AVG',
  interval: 60 * 60 * 1000,
});

Features

  • Auth — API key, username/password JWT, token persistence and restore
  • Devices — list, paginate, listAll() async generator
  • Telemetry — latest snapshot, historical time-series with aggregation, attributes
  • Realtime — WebSocket subscriptions with auto-reconnect
  • Alarms — list, acknowledge, clear
  • RPC — one-way and two-way device commands
  • Constants — verified TelemetryKeys, VcuStates, resolveVcuState()

Realtime subscriptions

const rt = client.createRealtimeClient();

const unsubscribe = rt.subscribeDevice(deviceId, [TelemetryKeys.MOTOR_RPM], (update) => {
  const rpm = update.data[TelemetryKeys.MOTOR_RPM]?.[0]?.value;
  console.log('RPM:', rpm);
});

// Later:
unsubscribe();
rt.disconnect();

Node.js < 22: pass a WebSocket constructor via new ThingsboardClient(url, { WebSocket: WS.WebSocket }) using the ws package.

VCU state

Thingsboard stores the ECU state as a raw C enum integer. Use resolveVcuState() to decode it:

import { resolveVcuState, VcuStates } from '@xshore/telemetry-client';

const state = resolveVcuState(raw); // '27' → 'E_ECUSTATE_DRIVE'

if (state === VcuStates.DRIVE)   console.log('Underway');
if (state === VcuStates.CHARGE)  console.log('Charging');
if (state === VcuStates.SLEEP)   console.log('Docked');

Error handling

import { ThingsboardError } from '@xshore/telemetry-client';

try {
  await client.devices.listInfos();
} catch (err) {
  if (err instanceof ThingsboardError) {
    console.error(err.status, err.message); // 401, 403, 404, …
  }
}

Requirements

  • Node.js 18+ (uses global fetch)
  • Node.js 22+ for realtime WebSocket support without the ws package