Library and for aria2, "The next generation download utility."

Usage no npm install needed!

<script type="module">
  import aria2 from '';



JavaScript (Node.js and browsers) library for aria2, "The next generation download utility."


aria2.js controls aria2 via its JSON-RPC interface and features

  • Node.js and browsers support
  • multiple transports
  • promise API

See aria2 methods and aria2 notifications.

Getting started

Start aria2 with rpc, example:

aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all

Install aria2.js

npm install aria2


const Aria2 = require("aria2");
const aria2 = new Aria2([options]);

default options match aria2c defaults and are

  host: 'localhost',
  port: 6800,
  secure: false,
  secret: '',
  path: '/jsonrpc'

secret is optional and refers to --rpc-secret. If you define it, it will be added to every call for you.

If the WebSocket is open (via the open method) aria2.js will use the WebSocket transport, otherwise the HTTP transport.

The "aria2." prefix can be omitted from both methods and notifications.

open opens the WebSocket connection. All subsequent requests will use the WebSocket transport instead of HTTP.

  .then(() => console.log("open"))
  .catch(err => console.log("error", err));


aria2.close() closes the WebSocket connection. All subsequent requests will use the HTTP transport instead of WebSocket.

  .then(() => console.log("closed"))
  .catch(err => console.log("error", err));

call calls a method. Parameters are provided as arguments.

  const magnet =
  const [guid] = await"addUri", [magnet], { dir: "/tmp" });


aria2.multicall() is a helper for system.multicall. It returns an array of results or throw if any of the call failed.

const multicall = [
  [methodA, param1, param2],
  [methodB, param1, param2]

const results = await aria2.multicall(multicall);


aria2.batch() is a helper for batch. It behaves the same as multicall except it returns an array of promises which gives more flexibility in handling errors.

const batch = [
  [methodA, param1, param2],
  [methodB, param1, param2]

const promises = await aria2.batch(batch);


aria2.listNotifications() is a helper for system.listNotifications. The difference with'listNotifications') is that it removes the "aria2." prefix from the results.

const notifications = await aria2.listNotifications();

// notifications logger example
notifications.forEach((notification) => {
  aria2.on(notification, (params) => {
    console.log('aria2', notification, params)


aria2.listMethods() is a helper for system.listMethods. The difference with'listMethods') is that it removes the "aria2." prefix for the results.

const methods = await aria2.listMethods();
[ 'addUri',
  'system.listNotifications' ]



// emitted when the WebSocket is open.
aria2.on('open', () => {
  console.log('aria2 OPEN');

// emitted when the WebSocket is closed.
aria2.on('close', () => {
  console.log('aria2 CLOSE');

// emitted for every message sent.
aria2.on("output", m => {
  console.log("aria2 OUT", m);

// emitted for every message received.
aria2.on("input", m => {
  console.log("aria2 IN", m);

Additionally every aria2 notifications received will be emitted as an event (with and without the "aria2." prefix). Only available when using WebSocket, see open.

aria2.on("onDownloadStart", ([guid]) => {
  console.log("aria2 onDownloadStart", guid);