| Crates.io | torbox-rs |
| lib.rs | torbox-rs |
| version | 0.0.1-alpha.4 |
| created_at | 2025-06-25 22:29:20.207549+00 |
| updated_at | 2025-08-16 17:39:25.833599+00 |
| description | Rust SDK for the Torbox API |
| homepage | https://github.com/RiadYan/torbox-rs |
| repository | https://github.com/RiadYan/torbox-rs |
| max_upload_size | |
| id | 1726571 |
| size | 56,113 |
The official Rust SDK for TorBox's torrent services. Query, manage, and download torrents with full rust experience.
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"] # Enables Specta support for Tauri/JS interop
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>> {
// Initialize client with your API token
let client = TorboxClient::new("your_api_token_here".into());
let api = TorrentApi::new(&client);
// List all your torrents
let torrents = api.list_torrents_query(Default::default()).await?;
println!("My Torrents: {:#?}", torrents.data);
// Create new torrent from magnet link
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?;
// Export as .torrent file
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)?;
// Get download link (always use redirect: true for permalinks!)
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, // Set this to true for direct download links it'll help you and the devs !
}).await?;
println!("Download ready at: {}", download_link);
Ok(())
}
// Pause/resume/delete torrents
api.control_torrent(TorrentControlBody {
source: TorrentId(123), // Use torrent ID or hash
operation: TorrentOperation::Pause, // Pause, Resume, Delete
}).await?;
The API smartly handles both formats:
match api.export_data_query(query).await? {
TorrentExportResponse::Json(json) => { /* Get magnet URI */ },
TorrentExportResponse::File(data) => { /* Save .torrent file */ }
}
// Get detailed info (with 5s timeout)
let info = api.info_query(TorrentInfoQuery {
hash: "6cad4a4671eb622b279619868342171cf5ec1045".into(),
timeout: Some(5),
}).await?;
redirect: true when generating download linksApiError variants for proper error handlingcargo doc --openOpen an issue if you have any issues! I will be happy to help.