Aria2.JsonRpcClient

Aria2.JsonRpcClient Documentation - Home | Client | Requests | Models | Examples

IAria2Client Interface

Overview

Provides methods for interacting with aria2 via its JSON‑RPC interface.


Methods

AddUri

Adds a new download. uris is an array of HTTP/FTP/SFTP/BitTorrent URIs (strings) pointing to the same resource. If you mix URIs pointing to different resources, the download may fail or be corrupted. For BitTorrent Magnet URIs, uris must have only one element.options is a struct with option name/value pairs. If position is given (an integer starting at 0), the new download is inserted at that position in the waiting queue; if omitted or out of range, it is appended to the end. Returns the GID of the newly registered download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.addUri

Signature: System.Threading.Tasks.Task<string> AddUri(string[] uris, Aria2DownloadOptions? options = null, int? position = null, string? id = null)

Parameters:

Returns:

The GID of the newly registered download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


AddTorrent

Adds a new BitTorrent download by uploading a torrent file (base64 encoded).options is a struct with option name/value pairs. If position is provided, the new download is inserted at that position in the waiting queue; otherwise, appended. Returns the GID of the newly registered download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.addTorrent

Signature: System.Threading.Tasks.Task<string> AddTorrent(string torrent, Aria2DownloadOptions? options = null, int? position = null, string? id = null)

Parameters:

Returns:

The GID of the newly registered download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


Adds new downloads from a Metalink file (base64 encoded).options is a struct with option name/value pairs. If position is provided, the downloads are inserted at that position; otherwise, appended. Returns the GID of the newly registered download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.addMetalink

Signature: System.Threading.Tasks.Task<string> AddMetalink(string metalink, Aria2DownloadOptions? options = null, int? position = null, string? id = null)

Parameters:

Returns:

The GID of the newly registered download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


Remove

Removes the download denoted by gid from the download queue. If the download is in progress, it is stopped first. Returns the GID of the removed download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.remove

Signature: System.Threading.Tasks.Task<string> Remove(string gid, string? id = null)

Parameters:

Returns:

The GID of the removed download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ForceRemove

Forcefully removes the download denoted by gid from the download queue without performing time‑consuming actions. Returns the GID of the removed download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.forceRemove

Signature: System.Threading.Tasks.Task<string> ForceRemove(string gid, string? id = null)

Parameters:

Returns:

The GID of the removed download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


Pause

Pauses the download denoted by gid. Returns the GID of the paused download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.pause

Signature: System.Threading.Tasks.Task<string> Pause(string gid, string? id = null)

Parameters:

Returns:

The GID of the paused download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


PauseAll

Pauses all active and waiting downloads.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.pauseAll

Signature: System.Threading.Tasks.Task PauseAll(string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ForcePause

Forcefully pauses the download denoted by gid without performing extra actions. Returns the GID of the paused download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.forcePause

Signature: System.Threading.Tasks.Task<string> ForcePause(string gid, string? id = null)

Parameters:

Returns:

The GID of the paused download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ForcePauseAll

Forcefully pauses all active and waiting downloads without extra actions.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.forcePauseAll

Signature: System.Threading.Tasks.Task ForcePauseAll(string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


Unpause

Unpauses the download denoted by gid, changing its status to waiting. Returns the GID of the unpaused download.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.unpause

Signature: System.Threading.Tasks.Task<string> Unpause(string gid, string? id = null)

Parameters:

Returns:

The GID of the unpaused download.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


UnpauseAll

Unpauses all paused downloads.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.unpauseAll

Signature: System.Threading.Tasks.Task UnpauseAll(string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellStatus

Returns the status of the download denoted by gid. The returned object includes various properties describing the download’s progress, speed, and other details. If keys is specified, only those keys are returned.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellStatus

Signature: System.Threading.Tasks.Task<Aria2.JsonRpcClient.Models.Aria2Status> TellStatus(string gid, string[]? keys = null, string? id = null)

Parameters:

Returns:

An Aria2Status object describing the download’s status.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellStatus

Returns the status of the download denoted by gid. The returned object includes various properties describing the download’s progress, speed, and other details. If keysSelector is specified, only those keys are returned.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellStatus

Signature: System.Threading.Tasks.Task<Aria2.JsonRpcClient.Models.Aria2Status> TellStatus(string gid, Expression<Func<Aria2Status, object?>> keysSelector, string? id = null)

Parameters:

Returns:

An Aria2Status object describing the download’s status.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetUris

Returns an array of URI objects used by the download denoted by gid. Each URI object contains the URI and its status.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getUris

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Uri>> GetUris(string gid, string? id = null)

Parameters:

Returns:

A read-only list of Aria2Uri objects.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetFiles

Returns an array of file objects associated with the download denoted by gid. Each file object includes details such as file path, size, and progress.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getFiles

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2File>> GetFiles(string gid, string? id = null)

Parameters:

Returns:

A read-only list of Aria2File objects.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetPeers

Returns an array of peer objects associated with the download denoted by gid. Each peer object contains details such as IP address, port, and speed information.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getPeers

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Peer>> GetPeers(string gid, string? id = null)

Parameters:

Returns:

A read-only list of Aria2Peer objects.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetServers

Returns a list of currently connected servers for the download denoted by gid. Each server object contains the original URI, current URI, and download speed.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getServers

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Server>> GetServers(string gid, string? id = null)

Parameters:

Returns:

A read-only list of Aria2Server objects.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellActive

Returns a list of active downloads. Each download’s status is represented as an Aria2Status object.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellActive

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Status>> TellActive(string[]? keys = null, string? id = null)

Parameters:

Returns:

A read-only list of active downloads.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellActive

Returns a list of active downloads. Each download’s status is represented as an Aria2Status object.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellActive

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Status>> TellActive(Expression<Func<Aria2Status, object?>> keysSelector, string? id = null)

Parameters:

Returns:

A read-only list of active downloads.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellWaiting

Returns a list of waiting downloads.offset specifies the starting index (can be negative) and num specifies the maximum number to return.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellWaiting

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Status>> TellWaiting(int offset, int num, string[]? keys = null, string? id = null)

Parameters:

Returns:

A read-only list of waiting downloads.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellWaiting

Returns a list of waiting downloads.offset specifies the starting index (can be negative) and num specifies the maximum number to return.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellWaiting

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Status>> TellWaiting(int offset, int num, Expression<Func<Aria2Status, object?>> keysSelector, string? id = null)

Parameters:

Returns:

A read-only list of waiting downloads.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellStopped

Returns a list of stopped downloads.offset specifies the starting index (can be negative) and num specifies the maximum number to return.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellStopped

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Status>> TellStopped(int offset, int num, string[]? keys = null, string? id = null)

Parameters:

Returns:

A read-only list of stopped downloads.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


TellStopped

Returns a list of stopped downloads.offset specifies the starting index (can be negative) and num specifies the maximum number to return.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.tellStopped

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Aria2.JsonRpcClient.Models.Aria2Status>> TellStopped(int offset, int num, Expression<Func<Aria2Status, object?>> keysSelector, string? id = null)

Parameters:

Returns:

A read-only list of stopped downloads.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ChangePosition

Changes the position of the download denoted by gid in the queue.pos is an integer, and how specifies the mode: ‘POS_SET’, ‘POS_CUR’, or ‘POS_END’. Returns the new position as an integer.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.changePosition

Signature: System.Threading.Tasks.Task<int> ChangePosition(string gid, int pos, string how, string? id = null)

Parameters:

Returns:

The new position.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ChangeUri

Removes URIs specified in delUris and appends URIs in addUris for the download (and file index) denoted by gid.fileIndex is 1-based. position specifies the insertion position after deletion. Returns an array with two integers: the number of URIs deleted and the number of URIs added.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.changeUri

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<int>> ChangeUri(string gid, int fileIndex, IEnumerable<string> delUris, IEnumerable<string> addUris, int? position = null, string? id = null)

Parameters:

Returns:

An array of two integers: [number deleted, number added].

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetOption

Returns the options of the download denoted by gid as a struct. Only options that have been set or have defaults are returned.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getOption

Signature: System.Threading.Tasks.Task<Aria2.JsonRpcClient.Models.Aria2Options> GetOption(string gid, string? id = null)

Parameters:

Returns:

An Aria2Options object with the download’s options.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ChangeOption

Changes the options for the download denoted by gid.options is a struct containing option name/value pairs.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.changeOption

Signature: System.Threading.Tasks.Task ChangeOption(string gid, Aria2Options options, string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetGlobalOption

Returns the global options as a struct. Only options that have been set or have defaults are returned.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getGlobalOption

Signature: System.Threading.Tasks.Task<Aria2.JsonRpcClient.Models.Aria2GlobalOptions> GetGlobalOption(string? id = null)

Parameters:

Returns:

A dictionary of global options.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ChangeGlobalOption

Changes the global options dynamically.options is a struct containing option name/value pairs.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.changeGlobalOption

Signature: System.Threading.Tasks.Task ChangeGlobalOption(Aria2GlobalOptions options, string? id = null)

Parameters:


GetGlobalStat

Returns global statistics for the aria2 session. The returned struct includes overall download/upload speeds and counts of active, waiting, and stopped downloads.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getGlobalStat

Signature: System.Threading.Tasks.Task<Aria2.JsonRpcClient.Models.Aria2GlobalStat> GetGlobalStat(string? id = null)

Parameters:

Returns:

An Aria2GlobalStat object with global statistics.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetVersion

Returns version information of aria2, including enabled features.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getVersion

Signature: System.Threading.Tasks.Task<Aria2.JsonRpcClient.Models.Aria2Version> GetVersion(string? id = null)

Parameters:

Returns:

An Aria2Version object with version information.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


GetSessionInfo

Returns session information of the current aria2 session, including the session ID.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.getSessionInfo

Signature: System.Threading.Tasks.Task<Aria2.JsonRpcClient.Models.Aria2SessionInfo> GetSessionInfo(string? id = null)

Parameters:

Returns:

An Aria2SessionInfo object with session information.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


Shutdown

Gracefully shuts down aria2, allowing active downloads to complete.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.shutdown

Signature: System.Threading.Tasks.Task Shutdown(string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ForceShutdown

Forcefully shuts down aria2 immediately without waiting for active downloads.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.forceShutdown

Signature: System.Threading.Tasks.Task ForceShutdown(string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


SaveSession

Saves the current session to a file specified by the –save-session option.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.saveSession

Signature: System.Threading.Tasks.Task SaveSession(string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


PurgeDownloadResult

Purges completed, error, or removed downloads from memory.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.purgeDownloadResult

Signature: System.Threading.Tasks.Task PurgeDownloadResult(string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


RemoveDownloadResult

Removes a download result (completed/error/removed) from memory, identified by gid.

https://aria2.github.io/manual/en/html/aria2c.html#aria2.removeDownloadResult

Signature: System.Threading.Tasks.Task RemoveDownloadResult(string gid, string? id = null)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


SystemMulticall

Encapsulates multiple method calls in a single request.methods is an array of JsonRpcRequest. Returns an array of responses.

https://aria2.github.io/manual/en/html/aria2c.html#system.multicall

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<object?>> SystemMulticall(params JsonRpcRequest[] methods)

Parameters:

Returns:

A list of responses for the method calls.


SystemMulticall

Encapsulates multiple method calls in a single request.methods is an array of JsonRpcRequest. Returns an array of responses.

https://aria2.github.io/manual/en/html/aria2c.html#system.multicall

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<object?>> SystemMulticall(JsonRpcRequest[] methods, string? id = null)

Parameters:

Returns:

A list of responses for the method calls.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


SystemListMethods

Returns an array of all available RPC method names.

https://aria2.github.io/manual/en/html/aria2c.html#system.listMethods

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>> SystemListMethods(string? id = null)

Parameters:

Returns:

A list of method names.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


SystemListNotifications

Returns an array of all available RPC notification names.

https://aria2.github.io/manual/en/html/aria2c.html#system.listNotifications

Signature: System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>> SystemListNotifications(string? id = null)

Parameters:

Returns:

A list of notification names.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ExecuteRequest

Executes the a request with a return type of .

Signature: System.Threading.Tasks.Task<T> ExecuteRequest(JsonRpcRequest<T> request)

Parameters:

Returns:

The result of the request.

Throws:

Aria2Exception Thrown when an aria2 error occurs.


ExecuteRequest

Executes a request with a void return type.

Signature: System.Threading.Tasks.Task ExecuteRequest(JsonRpcRequest request)

Parameters:

Throws:

Aria2Exception Thrown when an aria2 error occurs.


Events

DownloadStarted

This notification will be sent when a download is started. The paramter is the GID of the download.

Callback: System.Action<string>


DownloadPaused

This notification will be sent when a download is paused. The paramter is the GID of the download.

Callback: System.Action<string>


DownloadStopped

This notification will be sent when a download is stopped by the user. The paramter is the GID of the download.

Callback: System.Action<string>


DownloadComplete

This notification will be sent when a download is complete.For BitTorrent downloads, this notification is sent when the download is complete and seeding is over. The paramter is the GID of the download.

Callback: System.Action<string>


DownloadError

This notification will be sent when a download is stopped due to an error. The paramter is the GID of the download.

Callback: System.Action<string>


BtDownloadComplete

This notification will be sent when a torrent download is complete but seeding is still going on. The paramter is the GID of the download.

Callback: System.Action<string>


Top
© lantean-code - Generated on 2025-04-02