A TypeScript-first, dependency-free client for the SURF IoTroam REST API.
This package provides a fully typed API client for managing device groups, devices, and profiles in IoTroam. All endpoints, parameters, and responses are statically typed, enabling compile-time safety and excellent IDE autocompletion.
The client is built directly on the native fetch() API and is suitable for Node.js, Bun, Deno, and modern browsers.
fetchfetchImpl override for:
$headers{id} path parameter replacementRequestInitnpm install iotroam
TypeScript typings (.d.ts) are included.
import { iotroam } from "iotroam";
const api = iotroam({
apiKey: process.env.IOTROAM_API_KEY!,
});
Default base URL:
https://iotroam.nl
const groups = await iotroam.groups.list({
limit: 25,
offset: 0,
});
console.log(groups.items);
console.log("Total:", groups.count);
const group = await iotroam.groups.get({ id: 123 });
console.log(group.name);
console.log(group.profile?.vlan);
const devices = await iotroam.groups.devices(
{ id: 123 },
{ limit: 10 }
);
devices.items.forEach(device => {
console.log(device.id, device.name, device.mac);
});
const device = await iotroam.devices.create({
name: "sensor-01",
mac: "AA:BB:CC:DD:EE:FF",
password: "secret-password",
owner: {
type: "group",
id: 123,
},
location: "Lab A",
});
const updated = await iotroam.devices.update(
{ id: device.id },
{
name: "sensor-01-renamed",
location: "Lab B",
}
);
await iotroam.devices.delete({ id: device.id });
| Method | Description |
|---|---|
groups.list(query?) |
List device groups (paged) |
groups.get({ id }) |
Get group details |
groups.devices({ id }, query?) |
List devices in a group |
| Method | Description |
|---|---|
devices.create(body) |
Create a device |
devices.get({ id }) |
Get device details |
devices.update({ id }, body) |
Update a device |
devices.delete({ id }) |
Delete a device |
Each request follows a consistent parameter model:
{
$path?: Record<string, string | number>;
$query?: Record<string, any>;
$body?: unknown;
$headers?: {
"X-API-Key"?: string;
};
}
Example with manual headers:
await iotroam.request(
"/api/v1/group/list",
"GET",
{
$headers: {
"X-API-Key": "override-key",
},
}
);
The low-level request helper is exposed for advanced use cases:
const result = await iotroam.request(
"/api/v1/device/{id}/details",
"GET",
{ $path: { id: 123 } }
);
This is useful for:
Non-2xx responses throw a standard Error:
try {
await iotroam.devices.get({ id: 999999 });
} catch (err) {
console.error(err.message);
}
The error message includes:
fetch)fetch📡 IoTroam API documentation https://iotroam.nl/api/v1/docs
Apache 2.0 See LICENSE