| Crates.io | cloudreve-api |
| lib.rs | cloudreve-api |
| version | 0.5.0 |
| created_at | 2026-01-14 07:55:27.623683+00 |
| updated_at | 2026-01-24 01:27:34.312577+00 |
| description | A Rust library for interacting with Cloudreve API |
| homepage | |
| repository | https://github.com/larriti/cloudreve-api |
| max_upload_size | |
| id | 2042388 |
| size | 417,967 |
A Rust library for interacting with the Cloudreve API. This library provides asynchronous access to all major Cloudreve API endpoints with proper error handling and type safety.
Add this to your Cargo.toml:
[dependencies]
cloudreve-api = "0.3"
tokio = { version = "1", features = ["full"] }
Or use cargo-edit:
cargo add cloudreve-api
use cloudreve_api::{CloudreveAPI, Result};
#[tokio::main]
async fn main() -> Result<()> {
// Create a client instance (auto-detects API version)
let mut api = CloudreveAPI::new("https://your-cloudreve-instance.com").await?;
// Login
api.login("user@example.com", "password").await?;
println!("Successfully logged in!");
Ok(())
}
use cloudreve_api::{CloudreveAPI, Result};
#[tokio::main]
async fn main() -> Result<()> {
let mut api = CloudreveAPI::new("https://your-cloudreve-instance.com").await?;
api.login("user@example.com", "password").await?;
// List files in a directory
let files = api.list_files("/").await?;
println!("Found {} items", files.total_count());
for item in files.items() {
if item.is_folder {
println!(" 📁 {}/", item.name);
} else {
println!(" 📄 {} ({} bytes)", item.name, item.size);
}
}
Ok(())
}
use cloudreve_api::{CloudreveAPI, Result};
#[tokio::main]
async fn main() -> Result<()> {
let mut api = CloudreveAPI::new("https://your-cloudreve-instance.com").await?;
api.login("user@example.com", "password").await?;
// Create a new directory
api.create_directory("/photos/vacation").await?;
println!("Directory created successfully!");
Ok(())
}
use cloudreve_api::{CloudreveAPI, Result};
#[tokio::main]
async fn main() -> Result<()> {
let mut api = CloudreveAPI::new("https://your-cloudreve-instance.com").await?;
api.login("user@example.com", "password").await?;
// Upload a file
let content = b"Hello, World!".to_vec();
api.upload_file("/hello.txt", content, None).await?;
println!("File uploaded successfully!");
Ok(())
}
use cloudreve_api::{CloudreveAPI, Result};
#[tokio::main]
async fn main() -> Result<()> {
let mut api = CloudreveAPI::new("https://your-cloudreve-instance.com").await?;
api.login("user@example.com", "password").await?;
// Get download URL
let url = api.download_file("/document.pdf").await?;
println!("Download URL: {}", url);
Ok(())
}
use cloudreve_api::{CloudreveAPI, Result};
#[tokio::main]
async fn main() -> Result<()> {
let mut api = CloudreveAPI::new("https://your-cloudreve-instance.com").await?;
api.login("user@example.com", "password").await?;
// List shares
let shares = api.list_shares().await?;
for share in shares {
println!("Share key: {}", share.key);
}
Ok(())
}
Authentication & Session
User Management
File Operations
Sharing
Advanced Features
This library supports both Cloudreve v3 and v4 APIs with automatic version detection:
use cloudreve_api::{CloudreveAPI, ApiVersion, Result};
#[tokio::main]
async fn main() -> Result<()> {
// Auto-detect version
let api = CloudreveAPI::new("https://instance.com").await?;
// Or specify version explicitly
let api = CloudreveAPI::with_version("https://instance.com", ApiVersion::V4)?;
Ok(())
}
All API calls return a Result<T, Error> type:
use cloudreve_api::{CloudreveAPI, Error};
#[tokio::main]
async fn main() {
let mut api = CloudreveAPI::new("https://your-cloudreve-instance.com").await.unwrap();
match api.login("user@example.com", "wrong_password").await {
Ok(_) => println!("Login successful"),
Err(Error::Api { code, message }) => {
eprintln!("API Error {}: {}", code, message);
}
Err(Error::Http(err)) => {
eprintln!("HTTP Error: {}", err);
}
Err(err) => {
eprintln!("Other Error: {}", err);
}
}
}
Error::Http - Network/HTTP related errorsError::Json - Serialization/deserialization errorsError::Api - API error responses with code and messageError::Reqwest - Underlying reqwest errorsError::Url - URL parsing errorsError::InvalidResponse - Invalid API response formatThis project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions, please file an issue.