Package: aria2p
aria2pCommand-line tool and Python library to interact with anaria2cdaemon process through JSON-RPC.To avoid confusion:aria2is a lightweight multi-protocol & multi-source, cross platform download utility operated in command-line.
It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink.aria2cis the name of the command-line executable provided byaria2. It can act as a daemon.aria2p(pfor Python) is a command-line client that can interact with anaria2cdaemon.
It is not an official client. There are other Python packages allowing you to interact with anaria2cdaemon.
These other packages do not offer enough usability (in my opinion), this is why I'm developingaria2p.Purpose:aria2ccan run in the foreground, for one-time downloads, or in the background, as a daemon.
This is wherearia2pintervenes: when an instance ofaria2cis running in the background,aria2pwill be able to communicate with it to add downloads to the queue, remove, pause or resume them, etc.In order foraria2pto be able to communicate with thearia2cprocess, RPC mode must be enabled
with the--enable-rpcoption ofaria2c. RPC stands forRemote Procedure Call.
Althougharia2csupports both JSON-RPC and XML-RPC protocols,aria2pworks with JSON only(not XML).
More information about how to configurearia2cto run as a daemon with RPC mode enabled
can be found in theConfiguration sectionof the documentation.Table of contentsRequirementsInstallationUsage as a libraryUsage on the command lineTroubleshootSupportRequirementsaria2must be installed. On systems withapt-get:sudoapt-getinstallaria2InstallationWithpip:python3.6-mpipinstallaria2p[tui]Withpipx:python3.8-mpipinstall--userpipx
pipxinstallaria2p[tui]Thetuiextra is needed for the interactive interface. If you don't need the interface (for example when you are
writing a Python package with a dependency to aria2p), simply installaria2pwithout any extra.Usage (as a library)This library is still a work in progress. More examples will be added later.
In the meantime, you can read theReference sectionon the official documentation.importaria2p# initialization, these are the default valuesaria2=aria2p.API(aria2p.Client(host="http://localhost",port=6800,secret=""))# list downloadsdownloads=aria2.get_downloads()fordownloadindownloads:print(download.name,download.download_speed)# add downloadsmagnet_uri="magnet:?xt=urn:..."download=aria2.add_magnet(magnet_uri)Usage (command-line)usage: aria2p [GLOBAL_OPTS...] COMMAND [COMMAND_OPTS...]

Command-line tool and Python library to interact with an `aria2c` daemon
process through JSON-RPC.

Global options:
  -h, --help            Show this help message and exit. Commands also accept
                        the -h/--help option.
  -p PORT, --port PORT  Port to use to connect to the remote server.
  -H HOST, --host HOST  Host address for the remote server.
  -s SECRET, --secret SECRET
                        Secret token to use to connect to the remote server.
  -L {TRACE,DEBUG,INFO,SUCCESS,WARNING,ERROR,CRITICAL}, --log-level {TRACE,DEBUG,INFO,SUCCESS,WARNING,ERROR,CRITICAL}
                        Log level to use
  -P LOG_PATH, --log-path LOG_PATH
                        Log path to use. Can be a directory or a file.
  -T CLIENT_TIMEOUT, --client-timeout CLIENT_TIMEOUT
                        Timeout in seconds for requests to the remote server.
                        Floats supported. Default: 60.0.

Commands:
  
    add                 Add downloads with URIs/Magnets/torrents/Metalinks.
    add-magnets (add-magnet)
                        Add downloads with Magnet URIs.
    add-metalinks (add-metalink)
                        Add downloads with Metalink files.
    add-torrents (add-torrent)
                        Add downloads with torrent files.
    autopurge (autoclear)
                        Automatically purge completed/removed/failed
                        downloads.
    call                Call a remote method through the JSON-RPC client.
    pause (stop)        Pause downloads.
    remove (rm, del, delete)
                        Remove downloads.
    resume (start)      Resume downloads.
    show                Show the download progression.
    top                 Launch the top-like interactive interface.
    listen              Listen to notifications.Callingaria2pwithout any arguments will by default call thetopcommand,
which is a console interactive interface.Commands:addadd-magnetsadd-metalinksadd-torrentsautopurgecalllistenpauseremoveresumeshowtopaddusage: aria2p add [-h] [-f FROM_FILE] [uris [uris ...]]

Add downloads with URIs/Magnets/torrents/Metalinks.

positional arguments:
  uris                  The URIs/file-paths to add.

optional arguments:
  -h, --help            Show this help message and exit.
  -f FROM_FILE, --from-file FROM_FILE
                        Load URIs from a file.add-magnetsusage: aria2p add-magnets [-h] [-f FROM_FILE] [uris [uris ...]]

Add downloads with Magnet URIs.

positional arguments:
  uris                  The magnet URIs to add.

optional arguments:
  -h, --help            Show this help message and exit.
  -f FROM_FILE, --from-file FROM_FILE
                        Load URIs from a file.add-metalinksusage: aria2p add-metalinks [-h] [-f FROM_FILE]
                            [metalink_files [metalink_files ...]]

Add downloads with Metalink files.

positional arguments:
  metalink_files        The paths to the metalink files.

optional arguments:
  -h, --help            Show this help message and exit.
  -f FROM_FILE, --from-file FROM_FILE
                        Load file paths from a file.add-torrentsusage: aria2p add-torrents [-h] [-f FROM_FILE]
                           [torrent_files [torrent_files ...]]

Add downloads with torrent files.

positional arguments:
  torrent_files         The paths to the torrent files.

optional arguments:
  -h, --help            Show this help message and exit.
  -f FROM_FILE, --from-file FROM_FILE
                        Load file paths from a file.autopurgeusage: aria2p autopurge [-h]

Automatically purge completed/removed/failed downloads.

optional arguments:
  -h, --help  Show this help message and exit.callusage: aria2p call [-h] [-P PARAMS [PARAMS ...] | -J PARAMS] method

Call a remote method through the JSON-RPC client.

positional arguments:
  method                The method to call (case insensitive). Dashes and
                        underscores will be removed so you can use as many as
                        you want, or none. Prefixes like 'aria2.' or 'system.'
                        are also optional.

optional arguments:
  -h, --help            Show this help message and exit.
  -P PARAMS [PARAMS ...], --params-list PARAMS [PARAMS ...]
                        Parameters as a list of strings.
  -J PARAMS, --json-params PARAMS
                        Parameters as a JSON string. You should always wrap it
                        at least once in an array '[]'.As explained in the help text,
themethodcan be the exact method name,
or just the name without the prefix.
It is case-insensitive, and dashes and underscores will be removed.The following are all equivalent:aria2.addUriaria2.adduriaddUriADDURIaria2.ADD-URIadd_uriA-d_D-u_R-i(yes it's valid)A---R---I---A---2.a__d__d__u__r__i(I think you got it)and even more ugly forms...ExamplesList all available methods.This example usesjq.$aria2pcalllistmethods|jq["aria2.addUri","aria2.addTorrent","aria2.getPeers","aria2.addMetalink","aria2.remove","aria2.pause","aria2.forcePause","aria2.pauseAll","aria2.forcePauseAll","aria2.unpause","aria2.unpauseAll","aria2.forceRemove","aria2.changePosition","aria2.tellStatus","aria2.getUris","aria2.getFiles","aria2.getServers","aria2.tellActive","aria2.tellWaiting","aria2.tellStopped","aria2.getOption","aria2.changeUri","aria2.changeOption","aria2.getGlobalOption","aria2.changeGlobalOption","aria2.purgeDownloadResult","aria2.removeDownloadResult","aria2.getVersion","aria2.getSessionInfo","aria2.shutdown","aria2.forceShutdown","aria2.getGlobalStat","aria2.saveSession","system.multicall","system.listMethods","system.listNotifications"]List the GIDs (identifiers) of all active downloads.Note that we must give the parameters as a JSON string.$aria2pcalltellactive-J'[["gid"]]'[{"gid": "b686cad55029d4df"}, {"gid": "4b39a1ad8fd94e26"}, {"gid": "9d331cc4b287e5df"}, {"gid": "8c9de0df753a5195"}]Pause a download using its GID.Note that when a single string argument is required, it can be passed directly with-P.$aria2pcallpause-Pb686cad55029d4df"b686cad55029d4df"Add a download using magnet URIs.This example usesjq -rto remove the quotation marks around the result.$aria2pcalladduri-J'[["magnet:?xt=urn:..."]]'|jq-r4b39a1ad8fd94e26fPurge download results (remove completed downloads from the list).$aria2pcallpurge_download_result"OK"listenusage: aria2p listen [-h] [-c CALLBACKS_MODULE] [-t TIMEOUT]
                     [event_types [event_types ...]]

Listen to notifications.

positional arguments:
  event_types           The types of notifications to process: start, pause,
                        stop, error, complete or btcomplete. Example: aria2p
                        listen error btcomplete. Useful if you want to spawn
                        multiple specialized aria2p listener, for example one
                        for each type of notification, but still want to use
                        only one callback file.

optional arguments:
  -h, --help            Show this help message and exit.
  -c CALLBACKS_MODULE, --callbacks-module CALLBACKS_MODULE
                        Path to the Python module defining your notifications
                        callbacks.
  -t TIMEOUT, --timeout TIMEOUT
                        Timeout in seconds to use when waiting for data over
                        the WebSocket at each iteration. Use small values for
                        faster reactivity when stopping to listen.pauseusage: aria2p pause [-h] [-a] [-f] [gids [gids ...]]

Pause downloads.

positional arguments:
  gids         The GIDs of the downloads to pause.

optional arguments:
  -h, --help   Show this help message and exit.
  -a, --all    Pause all the downloads.
  -f, --force  Pause without contacting servers first.removeusage: aria2p remove [-h] [-a] [-f] [gids [gids ...]]

Remove downloads.

positional arguments:
  gids         The GIDs of the downloads to remove.

optional arguments:
  -h, --help   Show this help message and exit.
  -a, --all    Remove all the downloads.
  -f, --force  Remove without contacting servers first.resumeusage: aria2p resume [-h] [-a] [gids [gids ...]]

Resume downloads.

positional arguments:
  gids        The GIDs of the downloads to resume.

optional arguments:
  -h, --help  Show this help message and exit.
  -a, --all   Resume all the downloads.showusage: aria2p show [-h]

Show the download progression.

optional arguments:
  -h, --help  Show this help message and exit.topusage: aria2p top [-h]

Launch the top-like interactive interface.

optional arguments:
  -h, --help  Show this help message and exit.TroubleshootingError outputs like below when usingaria2pas a Python library:requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=6800): Max retries exceeded with url: /jsonrpc (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1115b1908>: Failed to establish a new connection: [Errno 61] Connection refused',))Solution:aria2cneeds to be up and running first.SupportTo support me as an open-source software author,
consider donating or be a supporter through one of the following platformsGitHubKo-fiLiberapayPatreonPaypalThank you!