@empa-electronics/tiremo-sdk-client-node
v0.1.5
Published
Node.js client for the TIREMO SDK REST and live WebSocket APIs
Downloads
60
Maintainers
Readme
@empa-electronics/tiremo-sdk-client-node
Node.js client for the TIREMO SDK. Uses native fetch (Node 18+) and native WebSocket (Node 22+).
Documentation
| Topic | Link | | --- | --- | | SDK Live Data | docs.tiremo.ai/developer-guide/sdk-live-data | | API Key Security | docs.tiremo.ai/developer-guide/sdk-api-key-security | | HTML examples | TIREMO-SDK/examples |
Getting started
1. Install
npm install @empa-electronics/tiremo-sdk-client-nodeRequires Node.js 18+ for REST. Live WebSocket requires Node.js 22+.
2. Get an API key
Create a product-scoped API key in the Tiremo Platform Administration → API Credentials UI.
Use a secret key for backend services and scripts. Use createToken() + connectWithToken() when fronting browser clients so the secret never leaves your server.
3. Create a client
import { TiremoClient } from "@empa-electronics/tiremo-sdk-client-node";
const client = new TiremoClient({
baseUrl: "https://sdk.tiremo.ai",
apiKey: process.env.TIREMO_API_KEY!,
});4. Choose a live connection mode
| Mode | When to use |
| --- | --- |
| connectWithSecretKey() | Trusted server scripts, workers, integrations |
| createToken() + connectWithToken() | BFF/API that serves browser clients |
Usage examples
TiremoClient — REST
devices.getTelemetryLatest(deviceIdentifier, options?)
const latest = await client.devices.getTelemetryLatest("cameradevice9", {
keys: ["temperature"],
});
console.log(latest.deviceIdentifier, latest.timestamp, latest.data);live.createToken()
Mint a browser-safe token from your API route:
const { token, expiresAt } = await client.live.createToken();
// return token to caller
return Response.json({ token, expiresAt });live.connectWithToken(token)
const live = client.live.connectWithToken(token);
live.connect();live.connectWithSecretKey()
Direct WebSocket auth with the secret key (server-side only):
const live = client.live.connectWithSecretKey();
live.connect();TiremoLiveClient — WebSocket
connect() / disconnect()
live.connect();
// ...
live.disconnect();on(event, handler)
live.on("connected", () => {
live.subscribeTelemetry({
id: "temp",
deviceIdentifier: "cameradevice9",
keys: ["temperature"],
});
});
live.on("telemetry", (event) => {
console.log(event.deviceIdentifier, event.data);
});
live.on("presence", (event) => {
console.log(event.deviceIdentifier, event.isOnline, event.lastSeenAt);
});
live.on("alarm", (event) => {
console.log(event.alarmType, event.severity);
});
live.on("error", (event) => {
console.error(event.code, event.message);
});
// Returns unsubscribe function
const off = live.on("message", (event) => console.log(event.type));
off();subscribeTelemetry({ id, deviceIdentifier, keys? })
live.subscribeTelemetry({
id: "temp-sub",
deviceIdentifier: "cameradevice9",
keys: ["temperature", "humidity"],
});subscribePresence({ id, deviceIdentifier })
live.subscribePresence({
id: "presence-sub",
deviceIdentifier: "cameradevice9",
});subscribeAlarm({ id, deviceIdentifier })
live.subscribeAlarm({
id: "alarm-sub",
deviceIdentifier: "cameradevice9",
});unsubscribe(subscriptionId)
live.unsubscribe("temp-sub");Full example (server script)
import { TiremoClient } from "@empa-electronics/tiremo-sdk-client-node";
const client = new TiremoClient({
baseUrl: "https://sdk.tiremo.ai",
apiKey: process.env.TIREMO_API_KEY!,
});
const latest = await client.devices.getTelemetryLatest("cameradevice9", {
keys: ["temperature"],
});
console.log("Latest:", latest.data);
const live = client.live.connectWithSecretKey();
live.on("connected", () => {
live.subscribeTelemetry({
id: "temp",
deviceIdentifier: "cameradevice9",
keys: ["temperature"],
});
});
live.on("telemetry", (event) => {
console.log("Live:", event.data);
});
live.connect();Related packages
| Package | Use case |
| --- | --- |
| @empa-electronics/tiremo-sdk-client-js | Browser / bundler |
| tiremo-sdk-client | Python |
License
ISC — Empa Electronics
