whmcs
Rust client for the WHMCS API (includes/api.php). POSTs form-encoded JSON-shaped fields, parses, and turns result: success | error into Result<T, WhmcsError>.
Installation
[]
= "0.1.0"
Create a client
use WhmcsBuilder;
use WhmcsError;
async
URL: If the path does not end with api.php, the builder adjusts it so requests hit .../includes/api.php.
Environment: Any of .url, .api_identifier, .api_secret can be omitted and filled from env at build() time:
| If unset | build() uses |
|---|---|
| URL | WHMCS_URL |
| Identifier | WHMCS_API_IDENTIFIER |
| Secret | WHMCS_API_SECRET |
| Timeout | WHMCS_TIMEOUT (seconds), else 30 |
Call the API
High-level methods live on WhmcsClient (see whmcs::resources via the same client type). Request types and response structs are under whmcs::models.
Parameters: Endpoints that take params accept None (WHMCS defaults / empty body for that action) or a params value (wrapped as Some automatically on recent Rust).
use ValidateLoginParams;
use ;
// No extra filters (WHMCS defaults)
let all: GetClientsResponse = client.get_clients.await?;
// Filtered list
let filtered = client
.get_clients
.await?;
// Client details by email
let details = client
.get_client_details
.await?;
// ValidateLogin
let session = client
.validate_login
.await?;
Actions without a wrapper yet: use the public generic:
client.request.await?;
your_params_struct must serialize to a JSON object (key/value pairs). The success payload (everything after the result discriminator) must deserialize into T.
Errors
| Type | When |
|---|---|
BuilderError |
build() failed: missing URL or credentials, bad URL |
WhmcsError::ApiError(msg) |
WHMCS returned result: error |
WhmcsError::RequestError |
Network / HTTP |
WhmcsError::SerializationError |
JSON encode/decode mismatch |
Implemented methods
WhmcsClient method |
WHMCS action |
|---|---|
validate_login |
ValidateLogin |
get_client_groups |
GetClientGroups |
get_client_password |
GetClientPassword |
get_clients |
GetClients |
get_client_details |
GetClientsDetails |
Field names and behaviour match the official API reference for each action.
License
Licensed under the MIT License. Copyright (c) 2026 TFDI Design Co.