Typed Node.js 18+ SDK for the Console's scoped /api/v1 management API, using built-in fetch. No runtime dependencies. Supports ESM and TypeScript declarations.
This release is distributed as GitHub source, not an npm registry publication. Git installation runs prepare to build with the development TypeScript dependency:
npm install github:lib-x/rustdesk-console-sdk-ts#v0.1.0Alternatively, clone the repository, run npm ci && npm run build && npm pack, then install the generated tarball into your application. npm pack includes built JavaScript and declarations.
Create a devices:read API key in Console → Developer → API keys, then inject RUSTDESK_CONSOLE_URL and RUSTDESK_CONSOLE_API_KEY using your process environment/secret manager. Do not commit keys or put them in command arguments.
import { Client, APIError } from "@lib-x/rustdesk-console-sdk";
const client = new Client({
baseUrl: process.env.RUSTDESK_CONSOLE_URL!,
apiKey: process.env.RUSTDESK_CONSOLE_API_KEY!,
timeoutMs: 15_000,
});
try {
const page = await client.listDevices({ page: 1, page_size: 10 });
for (const device of page.data) {
console.log(device.row_id, device.id, device.alias);
}
} catch (error) {
if (error instanceof APIError) console.error(error.status, error.code, error.message);
else throw error;
}Use your Console root URL, e.g. https://console.example.test or https://example.test/console; do not append /api/v1. Reverse-proxy prefixes are preserved. A runnable JavaScript example is available as node examples/list-devices.mjs after installation/build.
| Methods | Required scope | Visibility |
|---|---|---|
me |
profile:read |
Current owner |
listDevices, getDevice |
devices:read |
Own devices; administrators see all |
updateDevice, deleteDevice |
devices:write |
Administrator only |
listUsers, getUser |
users:read |
Administrator only |
createUser, updateUser, deleteUser |
users:write |
Administrator only; cannot delete self |
listDeviceGroups |
device-groups:read |
Administrator only |
createDeviceGroup |
device-groups:write |
Administrator only |
listStrategies |
strategies:read |
Administrator only; discovery only |
listAddressBooks |
address-books:read |
Own entries |
createAddressBook, deleteAddressBook |
address-books:write |
Own legacy collection entries |
Single-resource methods return the unwrapped typed resource. Delete methods resolve to undefined. List methods return {data,total,page,page_size}. Pagination is explicit (default page 1/size 30, maximum 100); the SDK does not fetch other pages automatically. listDevices additionally accepts an id connection-ID filter. Row ID parameters must be positive safe integers; device row_id is not the RustDesk connection id string.
Omit mutation fields to leave them unchanged; use "" to clear a string. updateUser accepts status 1 enabled / 2 disabled, and creating a user has no administrator-role field.
All methods accept a final RequestOptions argument with a caller AbortSignal:
const controller = new AbortController();
const devices = await client.listDevices({ page: 1 }, { signal: controller.signal });HTTP failures throw APIError with actual status, code and message. Non-JSON failures use http_error. Network, TLS, malformed-response errors use a generic safe Error; timeout/cancellation throws AbortError. API-key occurrences in returned error text are redacted; client formatting/serialization does not expose credentials. Requests never follow redirects or automatically retry mutations. Default whole-request timeout is 30 seconds; response bodies are capped at 8 MiB. HTTPS is strongly recommended remotely; TLS verification is never disabled. This is a Node.js SDK, not a recommendation to place privileged API keys in browser code.
The public OpenAPI document is at <Console root>/api/v1/openapi.json. API-key creation/revocation deliberately stays in the session-authenticated Console UI, not this key-authenticated SDK.
本 SDK 支持 Node.js 18+、ESM 与 TypeScript,使用原生 fetch,无运行时依赖。本次仅发布 GitHub 源码,没有发布 npm 包;使用上面的 GitHub 安装命令,或构建后 npm pack 安装。
- 在 开发者 → API 密钥 创建所需权限,通过环境变量注入 URL 和密钥,不要写进源码或浏览器前端。
- URL 是 Console 根地址,支持反向代理子路径,不加
/api/v1;示例在examples/list-devices.mjs。 - 支持全部 16 个管理操作,分页显式控制,默认 30 条、最多 100 条,不自动翻页或重试写操作。
- 数字参数是 Console 行号,不是 RustDesk 连接 ID;普通用户仅能访问自己的设备/地址簿,管理员操作还需对应 scope。
- 可用
APIError.status/code/message获取失败原因;支持 AbortSignal、默认 30 秒超时、不跟随跳转、响应上限 8 MiB,生产环境使用 HTTPS。 - 对外 OpenAPI:
/api/v1/openapi.json。
npm ci
npm test
npm pack --dry-runTests use a real local HTTP server for all 16 operations, authorization, query/body, errors/redaction, no mutation retry, redirects, timeout and abort.