xui-rs: 3X-UI Panel API Client
Features
- Login to the 3X-UI panel and manage session cookies automatically.
- Automatic re-login when the session cookie expires (if initial credentials are provided).
- Fetch a list of all inbound configurations.
- Fetch details for a specific inbound configuration by ID.
- Fetch client traffic statistics by email.
- Fetch client traffic statistics by UUID.
- Trigger a panel configuration backup.
- Async API calls using
reqwestandtokio. - Custom error type (
MyError) for easier error handling.
Installation
Add this library to your Cargo.toml:
[]
= { = "[https://github.com/LineGM/xui-rs.git](https://github.com/LineGM/xui-rs.git)" } # Or path = "path/to/xui-rs" if local, or version if published
= { = "1", = ["full"] }
= "1.0"
Usage
You need an async runtime like tokio.
use XUiClient;
use MyError;
async
API Methods
XUiClient::new(panel_url: impl IntoUrl) -> Result<Self, MyError>: Creates a new client. panel_url must end with /.client.login(username: impl Into<String>, password: impl Into<String>) -> Result<(), MyError>: Logs in and stores the session cookie.client.get_inbounds() -> Result<serde_json::Value, MyError>: Gets all inbounds.client.get_inbound(inbound_id: impl Into<u64>) -> Result<serde_json::Value, MyError>: Gets a specific inbound by ID.client.get_client_traffic_by_email(client_email: impl Into<String>) -> Result<serde_json::Value, MyError>: Gets client traffic by email.client.get_client_traffic_by_uuid(uuid: impl Into<String>) -> Result<serde_json::Value, MyError>: Gets client traffic by UUID.client.get_backup() -> Result<u16, MyError>: Triggers a panel backup and returns the HTTP status code.
Error Handling
Most methods return Result<T, MyError>. The MyError enum encapsulates various potential errors, including network errors (reqwest::Error), JSON parsing errors (serde_json::Error), URL parsing errors, and API-specific issues.
Contributing
Contributions are welcome! Please see CONTRIBUTING for details on how to contribute.
License
This project is licensed under the Unlicense - see the LICENSE file for details.