Skip to content

elizonapp/api-client-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elizon-api-client

Official Rust client for the elizon hosting API.

Machine-facing SDK — no localized error messages. API failures return ApiError with a machine-readable code, HTTP status, and raw payload. Map code to your own i18n layer.

Requirements

  • Rust 1.75+
  • Tokio runtime for async examples

Add dependency

From the monorepo:

[dependencies]
elizon-api-client = { path = "../public-api/rust" }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Quick start

use elizon_api_client::{
    ApiError, ClientKind, ElizonClient, ElizonClientConfig, ElizonError, LoginRequest,
};

#[tokio::main]
async fn main() -> Result<(), ElizonError> {
    let client = ElizonClient::new(
        ElizonClientConfig::new("https://www.elizon.app").client_kind(ClientKind::Api),
    )?;

    let login = client.auth.login(LoginRequest {
        email: "you@example.com".into(),
        password: "secret".into(),
        two_factor_code: None,
        remember_me: true,
    }).await?;

    if let Some(token) = login.token {
        client.set_token(Some(token));
    }

    let services = client.services.list(50, None).await?;
    println!("Services: {:?}", services.services);

    Ok(())
}

Configuration

Option Type Default Description
base_url String required elizon API base URL
token Option<String> None Bearer session token or API key
client_kind ClientKind Api Sent as X-Elizon-Client header
headers HashMap<String, String> empty Extra headers on every request

Client kind

Some financially sensitive endpoints (checkout, invoice payment, business fund) require ClientKind::Desktop. The server rejects Mobile clients for these actions.

API keys

Create an API key via client.user.create_api_key("name"), then pass the secret as token:

let client = ElizonClient::new(
    ElizonClientConfig::new("https://www.elizon.app")
        .token(std::env::var("ELIZON_API_KEY").ok()),
)?;

Resources

Namespace Description
auth Login, sessions, 2FA, profile
services VMs, containers, provider actions
billing Invoices, subscriptions, payment methods
checkout Cart validation, calculation, submit
shop Product catalog
dashboard Overview aggregates
domains Domain list, DNS records
subdomains Subdomain management
ip_manager IP manager entries
ssh_keys SSH key management
support Tickets, knowledge base
user Audit log, API keys, support PIN
wallet Auto top-up, vouchers
business Business fund, billing
affiliates Affiliate profile, commissions
family Family groups, invites
byoip BYOIP networks
floating_ips Floating IP management

Error handling

match client.billing.pay_invoice("inv_123", body).await {
    Ok(result) => { /* ... */ }
    Err(ElizonError::Api(err)) => {
        eprintln!("code={} status={}", err.code, err.status);
        // err.payload contains the raw API body
    }
    Err(err) => eprintln!("transport error: {err}"),
}

Examples

cd public-api/rust

# Auth (email/password)
ELIZON_EMAIL=you@example.com ELIZON_PASSWORD=secret cargo run --example auth

# Services (token or API key)
ELIZON_TOKEN=ek_... cargo run --example services

# Checkout flow
ELIZON_TOKEN=... cargo run --example checkout

# Pay invoice
ELIZON_TOKEN=... ELIZON_INVOICE_ID=inv_... cargo run --example pay_invoice

Build & test

cd public-api/rust
cargo build
cargo test

CI & releases

Standalone mirror: elizonapp/api-client-rust.

On every push to main, the Build workflow creates a GitHub Release titled api-client-rust {version} ({sha}) with:

  • elizon-api-client-{version}.crate — Cargo package
  • elizon-api-client-{version}-src.zip — source tree (src/, Cargo.toml, examples)

Bump "version" in Cargo.toml when you want a new major/minor/patch line; each release tag still includes the commit SHA.

Sync error codes

From the repo root:

node scripts/sync-rust-error-codes.mjs

Or:

bun run sync:rust-error-codes

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages