Crates.io | qbit-api-rs |
lib.rs | qbit-api-rs |
version | 0.2.0 |
source | src |
created_at | 2023-07-18 19:17:32.364675 |
updated_at | 2023-11-29 21:36:08.030654 |
description | A asynchronous Rust wrapper for qBittorrent Web API |
homepage | |
repository | https://github.com/koro33/qbit-api-rs |
max_upload_size | |
id | 919718 |
size | 225,779 |
A asynchronous Rust wrapper for qBittorrent Web API (For version above 4.1).
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.
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
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.
Licensed under either of
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.