Node.js API
Node.js API
Use the Risuko download engine from Node.js with native bindings.
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-jsOverview
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 |
| Queries | tellStatus, tellActive, tellWaiting, tellStopped, getGlobalStat, getFiles, getPeers, getUris |
| Events | onEvent |
| Options | getOption, getGlobalOption, changeOption, changeGlobalOption |
| Session | saveSession, purgeDownloadResult, removeDownloadResult |
Quick Example
import {
startEngine,
addUri,
tellStatus,
onEvent,
stopEngine,
} from "@risuko/risuko-js";
await startEngine({ rpcPort: 16800 });
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:
import type { EngineConfig, EngineEventName } from "@risuko/risuko-js";