examples/

directory
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: MIT

README

Examples

These programs expect an aria2c daemon with JSON-RPC enabled. For local use:

aria2c --enable-rpc --rpc-listen-port=6800 --rpc-secret=rpc-secret

Each example accepts -endpoint and -secret flags. Their defaults match the command above.

Example Demonstrates
version Creating an HTTP client and reading daemon information
add-download Adding a URI with options and polling its status
batch Sending several independent calls in one JSON-RPC request
concurrent-status Sharing a client safely between goroutines
websocket Calling methods and consuming download notifications over WebSocket

Run an example from the module root, for example:

go run ./examples/version
go run ./examples/add-download -url https://example.com/archive.zip -dir ./downloads
go run ./examples/concurrent-status 0123456789abcdef fedcba9876543210
go run ./examples/websocket

The add-download example creates a real aria2 download. The WebSocket example only observes notifications; create, pause, or complete a download in another terminal to see events.

Directories

Path Synopsis
Program add-download submits a URI and follows it until it stops.
Program add-download submits a URI and follows it until it stops.
Program batch combines independent JSON-RPC calls into one request.
Program batch combines independent JSON-RPC calls into one request.
Program concurrent-status fetches several download statuses concurrently.
Program concurrent-status fetches several download statuses concurrently.
Program version prints information about the aria2c daemon.
Program version prints information about the aria2c daemon.
Program websocket prints aria2 download events until interrupted.
Program websocket prints aria2 download events until interrupted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL