10 个版本
0.1.9 | 2024 年 8 月 3 日 |
---|---|
0.1.8 | 2024 年 6 月 22 日 |
#441 in 网页编程
每月下载 153 次
72KB
2K SLoC
marzban_api
一个简单的异步客户端,简化了与 Marzban 控制面板 API 的交互。
[!重要] 需要进行测试!
已更新至 Marzban v0.4.9
使用
可以通过 Cargo 添加
$ cargo add marzban_api
或者通过 Cargo.toml
[dependencies]
marzban_api = "0.1.0"
示例
使用 marzban_api 的简单示例
use marzban_api::client::MarzbanAPIClient;
use marzban_api::models::auth::BodyAdminTokenApiAdminTokenPost;
use tokio;
#[tokio::main]
async fn main() {
// Initialize the API client
let base_url = "https://api.example.com"; // Replace with your actual base URL
let api_client = MarzbanAPIClient::new(base_url);
// Authentication, successful authentication will insert token
// into MarzbanAPIClient, being used for every new API interaction.
let auth = BodyAdminTokenApiAdminTokenPost {
grant_type: Some("password".to_string()),
username: "admin".to_string(), // Replace with your actual admin username
password: "password".to_string(), // Replace with your actual admin password
scope: "".to_string(),
client_id: None,
client_secret: None,
};
match api_client.authenticate(&auth).await {
Ok(_) => println!("Authentication successful"),
Err(e) => eprintln!("Authentication failed: {:?}", e),
}
// Get current admin
match api_client.get_current_admin().await {
Ok(admin) => println!("Current admin: {:?}", admin),
Err(e) => eprintln!("Failed to get current admin: {:?}", e),
}
}
特性
- Reqwest 的异步 API 客户端
- 错误处理
- 全面支持所有 Marzban API 端点
贡献
欢迎贡献。请 Fork 仓库并提交拉取请求以供审查。
许可证
本项目遵循 MIT 许可证。有关详细信息,请参阅 LICENSE 文件。
鸣谢
- Marzban 提供了 API。
更多信息
有关 Marzban API 和架构的详细信息,请参阅 Marzban API 文档
依赖项
~8–20MB
~295K SLoC