Skip to content

George-Miao/qbit

Repository files navigation

Qbit-rs

crates.io docs.rs github

A Rust library for interacting with qBittorrent's Web API.

Implemented according to the official WebUI API (qBittorrent 5.0+). The crate also supports endpoints introduced through qBittorrent 5.2 (Web API v2.16.0), including features not yet covered by the official reference. For the most accurate and complete list of supported API methods and model fields, please refer to this crate's documentation on docs.rs.

Usage

Add dependency by running:

cargo add qbit-rs

or manually add to Cargo.toml:

[dependencies]
qbit-rs = "0.5"

Authentication

Username and password

With WebUI credentials, Qbit logs in automatically and renews the session if its cookie expires:

use qbit_rs::Qbit;
use qbit_rs::model::Credential;

let credential = Credential::new("username", "password");
let api = Qbit::new("http://my-qb-instance.domain", credential);
let version = api.get_version().await;

Cookie

To reuse an existing WebUI session, provide its SID cookie:

use qbit_rs::Qbit;

let api = Qbit::builder()
    .endpoint("http://my-qb-instance.domain")
    .cookie("SID=1234567890")
    .build();
let version = api.get_version().await;

API key

qBittorrent 5.2 and newer versions support stateless API-key authentication. Qbit adds the required Bearer authorization scheme automatically:

use qbit_rs::Qbit;

let api = Qbit::builder()
    .endpoint("http://my-qb-instance.domain")
    .api_key("qbt_your_api_key")
    .build();
let version = api.get_version().await;

API keys cannot access the WebUI's static assets or authentication endpoints such as login and logout.

HTTP Client

The crate by default uses reqwest as the HTTP client. It also supports cyper (HTTP client for compio based on hyper) under the cyper feature flag. To use it, disable default features and enable cyper:

cargo add qbit-rs --no-default-features --features cyper

Notice that this will also disable tls and typed-builder support for args. Make sure to enable builder, native-tls or rustls-tls if you need them.

API Coverage

For all methods, see Qbit.

The authentication, application, log, sync, transfer, torrent-management, RSS, and Search APIs are covered.

  1. Authentication
    1. Login
    2. Logout
    3. API key authentication
    4. Get current cookie
  2. Application
    1. Get application version
    2. Get API version
    3. Get build info
    4. Get process info
    5. Shutdown application
    6. Get application preferences
    7. Set application preferences
    8. Get free space at path
    9. Get default save path
    10. Get cookies
    11. Set cookies
  3. Log
    1. Get log
    2. Get peer log
  4. Sync
    1. Get main data
    2. Get torrent peers data
  5. Transfer info
    1. Get global transfer info
    2. Get alternative speed limits state
    3. Toggle alternative speed limits
    4. Get global and alternative speed limits
    5. Set global and alternative speed limits
    6. Get global download limit
    7. Set global download limit
    8. Get global upload limit
    9. Set global upload limit
    10. Ban peers
  6. Torrent management
    1. Get torrent list
    2. Download torrent file
    3. Get torrent generic properties
    4. Get torrent piece availability
    5. Get torrent trackers
    6. Get torrent web seeds
    7. Get torrent contents
    8. Get torrent pieces' states
    9. Get torrent pieces' hashes
    10. Add new torrent
    11. Stop torrents
    12. Start torrents
    13. Delete torrents
    14. Recheck torrents
    15. Reannounce torrents
    16. Reannounce torrents with selected trackers
    17. Edit trackers
    18. Remove trackers
    19. Add peers
    20. Add trackers to torrent
    21. Increase torrent priority
    22. Decrease torrent priority
    23. Maximal torrent priority
    24. Minimal torrent priority
    25. Set file priority
    26. Get torrent download limit
    27. Set torrent download limit
    28. Set torrent share limit
    29. Get torrent upload limit
    30. Set torrent upload limit
    31. Set torrent location
    32. Set torrent name
    33. Set torrent comment
    34. Set torrent category
    35. Get all categories
    36. Add new category
    37. Edit category
    38. Remove categories
    39. Add torrent tags
    40. Remove torrent tags
    41. Get all tags
    42. Create tags
    43. Delete tags
    44. Set automatic torrent management
    45. Toggle sequential download
    46. Set first/last piece priority
    47. Set force start
    48. Set super seeding
    49. Rename file
    50. Rename folder
  7. RSS (experimental)
    1. Add folder
    2. Add feed
    3. Remove item
    4. Move item
    5. Get all items
    6. Mark as read
    7. Refresh item
    8. Set auto-downloading rule
    9. Rename auto-downloading rule
    10. Remove auto-downloading rule
    11. Get all auto-downloading rules
    12. Get all articles matching a rule
  8. Search
    1. Start search
    2. Stop search
    3. Get search status
    4. Get search results
    5. Delete search
    6. Get search plugins
    7. Install search plugin
    8. Uninstall search plugin
    9. Enable search plugin
    10. Update search plugins
  9. Undocumented
    1. Export torrent1

Footnotes

  1. The endpoint is added in this PR

About

A Rust library for interacting with qBittorrent's Web API

Resources

License

Stars

65 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages