#web-api #api-bindings #api #qbittorrent #api-client #api-version #async

qbit-api-rs

A asynchronous Rust wrapper for qBittorrent Web API

3 unstable releases

0.2.0 Nov 29, 2023
0.1.1 Nov 20, 2023
0.1.0 Jul 18, 2023

#886 in Asynchronous

21 downloads per month

MIT/Apache

170KB
4.5K SLoC

qbit-api-rs

GitHub release (release name instead of tag name) Rust docs.rs Static Badge GitHub Repo stars

A asynchronous Rust wrapper for qBittorrent Web API (For version above 4.1).

Usage

add dependency

[dependencies]
qbit-api-rs = "0.1"

or

cargo add qbit-api-rs

a quick start

use qbit_api_rs::client::QbitClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // initialize client with given username and password
    let client = QbitClient::new_with_user_pwd("http://hostname:port", "admin", "adminadmin").unwrap();
    // or from environment variable
    // QBIT_HOST, QBIT_USERNAME, QBIT_PASSWORD must be set
    let client = QbitClient::new_from_env().unwrap();

    // login first
    client.auth_login().await?;

    // call api methods
    println!("{}", client.app_version().await?);

    //...
    Ok(())
}

For more usage, please refer to examples.

Note

  • This crate provides only pure API bindings. There is no such mechanism like reauthentication when the token expires.

  • qBitTorrent uses cookie to authenticate. The authentication required SID token stored in cookie, and will be expired after a while(default 3600 seconds). This expired time can be configured in the Options -> WebUI -> Authentication -> Session timeout. To keep the SID token valid, you can either

    • periodically(within the timeout period) call login method to reauthenticate.
    • or just enable Bypass authentication for clients in whitelisted IP subnets and configure your IP subnets, then you don't need to call login method anymore.
  • For version above 4.6.1, the default credentials are not admin:adminadmin. You have to set your own credentials or the qBittorrent will generate a random one. For more details, refer to the release note

  • This crate is at the early stage of development. Things might break in the future.

Supported APIs

Authentication

  • Login
  • Logout

Application

  • Get application version
  • Get API version
  • Get build info
  • Shutdown application
  • Get application preferences
  • Set application preferences
  • Get default save path

Log

  • Get log
  • Get peer log

Sync

  • Get main data
  • Get torrent peers data

Transfer info

  • Get global transfer info
  • Get alternative speed limits state
  • Toggle alternative speed limits
  • Get global download limit
  • Set global download limit
  • Get global upload limit
  • Set global upload limit
  • Ban peers

Torrent management

  • Get torrent list
  • Get torrent generic properties
  • Get torrent trackers
  • Get torrent web seeds
  • Get torrent contents
  • Get torrent pieces' states
  • Get torrent pieces' hashes
  • Pause torrents
  • Resume torrents
  • Delete torrents
  • Recheck torrents
  • Reannounce torrents
  • Edit trackers
  • Remove trackers
  • Add peers
  • Add new torrent
  • Add trackers to torrent
  • Increase torrent priority
  • Decrease torrent priority
  • Maximal torrent priority
  • Minimal torrent priority
  • Set file priority
  • Get torrent download limit
  • Set torrent download limit
  • Set torrent share limit
  • Get torrent upload limit
  • Set torrent upload limit
  • Set torrent location
  • Set torrent name
  • Set torrent category
  • Get all categories
  • Add new category
  • Edit category
  • Remove categories
  • Add torrent tags
  • Remove torrent tags
  • Get all tags
  • Create tags
  • Delete tags
  • Set automatic torrent management
  • Toggle sequential download
  • Set first/last piece priority
  • Set force start
  • Set super seeding
  • Rename file
  • Rename folder

RSS (experimental)

  • Add folder
  • Add feed
  • Remove item
  • Move item
  • Get all items
  • Mark as read
  • Refresh item
  • Set auto-downloading rule
  • Rename auto-downloading rule
  • Remove auto-downloading rule
  • Get all auto-downloading rules
  • Get all articles matching a rule
  • Start search
  • Stop search
  • Get search status
  • Get search results
  • Delete search
  • Get search plugins
  • Install search plugin
  • Uninstall search plugin
  • Enable search plugin
  • Update search plugins

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~10–22MB
~336K SLoC