Expand description
hightorrent_api provides clients for various Torrenting software APIs. Only QBittorrent is supported at the moment.
Note that hightorrent_api is not a torrenting library. It will not provide any utilities for querying the DHT and/or downloading torrents. It is merely an interface with actual Torrent clients.
It provides the Api trait which various backends can implement, as well as the ApiError struct to represent their error cases. By default, it is built with the qbittorrent feature flag, providing QBittorrentClient API client.
use hightorrent_api::{Api, QBittorrentClient};
let client = QBittorrentClient::login(
"http://localhost:8080",
"admin",
"adminadmin",
).await?;
for torrent in client.list().await? {
println!("Torrent: {}", &torrent.name);
}
§Supported backends
- QBittorrent (v5.0.x, v5.1.x)
- Transmission
§qBittorrent notes
Only the following qBittorrent releases are supported and tested in CI:
- v5.1.2 (2 July 2025)
- v5.0.5 (13 April 2025)
qBittorrent v4.6.x is known not to work properly due to the ever changing API. Checking support in newer releases only requires changing the CI configuration (pull requests welcome). We will not add support for older qBittorrent releases (Debian 13 Trixies packages qBittorrent v5.1.x), but contributions for this are welcome. Bittorrent v2 is only supported since v4.4.0 (6 January 2022) so it’s unlikely we’ll ever support an older release.
The qBittorrent API is surprising (to say the least):
- some responses are JSON, some are plaintext
- an error may be HTTP 200 with plaintext “Fails”, or HTTP 400 “Bad Request”
- client requests may not be chunked, despite being the default when uploading files in many HTTP clients
- does not return the same information in list/get endpoints (issue #18188)
- behaves unexpectedly with v2/hybrid hashes (issue #18185)
- sometimes changes methods on endpoints without bumping the API version to a new major (semantic versioning)
- may change form field names in API without updating the docs (upstream docs PR)
§Supported features
- List torrents
- Get torrent detailed information
- List, add, and remove trackers to a torrent
- Remove torrents
- Add torrents by magnet link or torrent file
§Interacting with a torrent
When interacting with a torrent, you need to use a SingleTarget instance. This may be produced from a parsed InfoHash or from a stringy hash. This SingleTarget may be a full infohash (v1/v2) or a TorrentID (truncated v2 hash or complete v1 hash).
use hightorrent::SingleTarget;
use hightorrent_api::Api;
let target = SingleTarget::from_str("E74C8AEB6F23A0BAEB6563CCF83E52B7094DB18E").unwrap();
if let Some(torrent) = client.get(&target).await? {
println!("{}", &torrent.name);
}
Re-exports§
pub use api::Api;
pub use api_error::ApiError;
pub use qbittorrent::QBittorrentClient;
pub use hightorrent;