Expand description
§whmcs
Async HTTP client for the WHMCS remote API (includes/api.php).
It sends application/x-www-form-urlencoded bodies, asks WHMCS for JSON
(responsetype=json), and maps the envelope result: success | error to Result<T, WhmcsError>
(WhmcsError).
Typical use looks like this:
- Build a
WhmcsClient(usually withWhmcsBuilderwhen thebuilderfeature is enabled, which is the default). - Call typed helpers such as
WhmcsClient::get_clients, or the genericWhmcsClient::requestfor any WHMCS action. - Use types from
modelsfor request parameters and deserialized responses.
§Quick start
use whmcs::{WhmcsBuilder, WhmcsError};
use whmcs::models::clients::{GetClientParams, GetClientsResponse};
async fn example() -> Result<(), WhmcsError> {
let client = WhmcsBuilder::new()
.url("https://billing.example.com/includes/api.php")
.api_identifier("your-api-identifier")
.api_secret("your-api-secret")
.timeout(30_u64)
.build()?;
let list: GetClientsResponse = client
.get_clients(GetClientParams::default().search("user@example.com"))
.await?;
println!("total matches: {}", list.total_results);
Ok(())
}§Building a client
With the default builder feature, use WhmcsBuilder to set the API URL, credentials,
and optional timeout, then call WhmcsBuilder::build. Any field you omit on the builder is
filled from environment variables when build runs:
| Builder field | Environment variable |
|---|---|
| URL | WHMCS_URL |
| Identifier | WHMCS_API_IDENTIFIER |
| Secret | WHMCS_API_SECRET |
| Timeout (seconds) | WHMCS_TIMEOUT (falls back to 30) |
If the URL path does not end with api.php, the builder normalizes it so requests target
.../includes/api.php under your WHMCS base path.
With default-features = false (disabling builder), construct WhmcsClient with
WhmcsClient::new and supply URL and secrets yourself.
§Requests and responses
- Typed helpers — Methods on
WhmcsClient(implemented in this crate’sresourcesmodules) callWhmcsClient::requestwith the correct WHMCSactionname and serde types. - Generic access —
WhmcsClient::requestaccepts anyPthat implementsserde::Serializeinto a JSON object (flat key/value pairs), and any success body typeTthat implementsserde::de::DeserializeOwnedfor the payload after theresultfield is handled byWhmcsRawResponse.
WHMCS often encodes booleans and nested lists in non-standard ways; this crate uses custom
deserializers in models where needed.
§Errors
See WhmcsError for request, JSON, and WHMCS-level failures. Configuration problems when
using the builder are reported as BuilderError.
§Cargo features
| Feature | Default | Description |
|---|---|---|
builder | yes | WhmcsBuilder, BuilderError, and BuilderError inside WhmcsError. |
§Further reading
- WHMCS API index — official action names, parameters, and behaviour.
Re-exports§
pub use models::WhmcsRawResponse;pub use models::WhmcsSorting;
Modules§
- models
- Serde types and helpers for the WHMCS JSON API.
Structs§
- Whmcs
Builder - A builder for the WHMCS API client.
- Whmcs
Client - HTTP client for the WHMCS remote API.
Enums§
- Builder
Error - Errors that can occur when building a
WhmcsClient. - Whmcs
Error - Errors that can occur when making a request to the WHMCS API.