torbox-rs 🦀

The official Rust SDK for TorBox's torrent services. Query, manage, and download torrents with full rust experience.
📦 Installation
Add to your Cargo.toml
:
[dependencies]
torbox-rs = "0.0.1-alpha.2"
Need TypeScript type generation? Add the specta
feature:
[dependencies.torbox-rs]
version = "0.0.1-alpha.2"
features = ["specta"]
🚀 Quick Start
Here's how to get rolling with the basics:
use torbox_rs::{TorboxClient, TorrentApi};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = TorboxClient::new("your_api_token_here".into());
let api = TorrentApi::new(&client);
let torrents = api.list_torrents_query(Default::default()).await?;
println!("My Torrents: {:#?}", torrents.data);
let new_torrent = api.create_torrent(TorrentCreateBody {
source: "magnet:?xt=urn:btih:EXAMPLE_HASH".into(),
seed: None,
allow_zip: true,
name: Some("ubuntu-22.04".into()),
as_queued: None,
}).await?;
let torrent_file = api.export_data_query(TorrentExportDataQuery {
torrent_id: new_torrent.data.unwrap().id,
data_type: TorrentExportType::File,
}).await?;
std::fs::write("ubuntu.torrent", torrent_file)?;
let download_link = api.request_download_link(TorrentRequestLinkQuery {
token: api.token().to_string(),
torrent_id: new_torrent.data.unwrap().id,
file_id: None,
zip_link: true,
user_ip: None,
redirect: true, }).await?;
println!("Download ready at: {}", download_link);
Ok(())
}
🔍 Key Features
📥 Torrent Management
api.control_torrent(TorrentControlBody {
source: TorrentId(123), operation: TorrentOperation::Pause, }).await?;
🔄 Dual Response Handling
The API smartly handles both formats:
match api.export_data_query(query).await? {
TorrentExportResponse::Json(json) => { },
TorrentExportResponse::File(data) => { }
}
📊 Torrent Inspection
let info = api.info_query(TorrentInfoQuery {
hash: "6cad4a4671eb622b279619868342171cf5ec1045".into(),
timeout: Some(5),
}).await?;
💡 Pro Tips
- Permalinks: Always use
redirect: true
when generating download links
- Caching: Torrent lists update every 10 minutes unless forced
- Errors: Check
ApiError
variants for proper error handling
📚 Documentation
🤝 Need Help?
Open an issue if you have any issues! I will be happy to help.