Node.js API
Use the Risuko download engine from Node.js with native bindings.
@risuko/risuko-js provides native Node.js bindings to the Risuko download engine via napi-rs. It ships as pre-built platform-specific binaries — no Rust toolchain needed.
Installation
npm install @risuko/risuko-jsRequires Node.js 22 or later. Pre-built binaries cover macOS, Linux (glibc), and Windows on x64 and arm64.
The package is CommonJS, so ESM code imports the default export and destructures the functions from it; named imports such as import { startEngine } from "@risuko/risuko-js" fail with a SyntaxError.
Overview
The API is organized into six areas:
| Area | Functions |
|---|---|
| Engine Lifecycle | startEngine, stopEngine |
| Task Operations | addUri, addTorrent, addMagnet, addEd2k, addM3u8, addFtp, pause, unpause, remove, pauseAll, unpauseAll, updateTask |
| Queries | tellStatus, tellActive, tellWaiting, tellStopped, getGlobalStat, getFiles, getPeers, getUris |
| Events | onEvent |
| Options | getOption, getGlobalOption, changeOption, changeGlobalOption |
| Session | saveSession, purgeDownloadResult, removeDownloadResult |
Some engine features have no Node binding and are only reachable over JSON-RPC (start the engine with enableRpc): addMedia, addMetalink, addNzb, changePosition, getServers, forcePause/forcePauseAll, forceRemove, the routing-rule methods, and setBtPeerBlocklist.
Quick Example
import risuko from "@risuko/risuko-js";
const { startEngine, addUri, tellStatus, onEvent, stopEngine } = risuko;
await startEngine({ rpcPort: 16800 });
await onEvent((event, gid) => {
console.log(`[${event}] ${gid}`);
});
const gid = await addUri(
["https://example.com/file.zip"],
{ split: "16", dir: "/downloads" }
);
const status = await tellStatus(gid);
console.log(`Progress: ${status.completedLength}/${status.totalLength}`);
await stopEngine();TypeScript Support
Full TypeScript declarations are included. All types are exported from the main module (type-only imports are erased, so they are unaffected by the CommonJS limitation):
import type { EngineConfig, EngineEventName } from "@risuko/risuko-js";