Crates.io | marzban_api |
lib.rs | marzban_api |
version | |
source | src |
created_at | 2024-06-21 14:48:37.575031 |
updated_at | 2024-12-07 11:11:28.953463 |
description | A simple async client which abstracts/simplifies the interactions with the Marzban panel API (https://github.com/Gozargah/Marzban). |
homepage | |
repository | https://github.com/nulluser0/marzban_api |
max_upload_size | |
id | 1279599 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A simple async rust client which simplifies the interactions with the Marzban panel API.
Updated for Marzban v0.7.0
Either add it via Cargo:
cargo add marzban_api
or via Cargo.toml:
[dependencies]
marzban_api = "0.2.6"
Simple example of using 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),
}
}
Contributions are welcome. Please fork the repository and submit a pull request for review.
This project is licensed under the MIT license. See the LICENSE file for more details.
For details on the Marzban API and schema, please refer to the Marzban API Documentation