Skip to content

Client

use std::time::Duration;
use dinio_sdk::Client;
let client = Client::builder()
.base_url("https://api-dinio.bitelex.com")
.api_key(key)
.timeout(Duration::from_secs(10))
.build()?;

A Client is one connection to the API with one key. It is cheap to clone — the HTTP client underneath is reference-counted — so clone it into tasks instead of building new ones.

Method Default
base_url(url) — API endpoint without /api/v1. Required; an invalid URL fails build().
api_key(key) none Personal (du_…) or zone (dz_…) API key, sent as Authorization: Bearer. Without one only health(), free_domains() and plans() work.
credentials(Credentials) none The same, as Credentials::ApiKey(Secret).
timeout(Duration) 30 s For the whole request: connect and response.
user_agent(text) dinio-sdk/<version> User-Agent header.
build() Result<Client>.
Accessor
DNS hosting
client.zones() Zones, zone keys and zone files.
client.free_domains() Free domains to lease a zone from.
client.records() Record sets and values, TTLs.
client.health_checks() One health check per record value.
client.geo_bans() Geo bans on record values.
client.geo() The areas a geo ban can use.
client.zone_members() A zone’s Owner and Administrators.
client.redirects() HTTP(S) redirects for host names in your zones.
client.certificates() TLS certificates for names in your zones.
DNS filtering — personal key only
client.client_identities() Clients recognised by IP, DoT hostname or DoH path.
client.sinkhole_lists(), client.sinkhole_roles(), client.sinkhole_links() Blacklists and whitelists, their rules, and where they apply.
Other
client.stats() Statistics of your zones and clients.
client.audit_logs() Who did what on your account and zones.
client.users() Your own account and personal key.
client.plans() The package price list; needs no key.
client.account() Your packages, and your usage against their limits.

See Resources.

Methods are async fns returning futures. The SDK starts no runtime and spawns nothing; the futures run in your runtime. reqwest underneath needs Tokio, so call the SDK from a Tokio runtime — #[tokio::main], or current_thread for a short-lived tool.

client.health() calls the API’s health route. It needs no key.

let health = client.health().await?;
println!("{} (version {})", health.status, health.version.as_deref().unwrap_or("?"));

Keys are held as dinio_sdk::Secret: Debug prints <redacted>, and the type does not implement Serialize, so a key can’t end up in JSON output by accident. Read the value with secret.expose() when you really need it. A key Dinio issues — zones().create_api_key and users().create_api_key — comes back as a Secret too.

ApiKeyKind::of(key) tells a zone key from a personal key by its prefix, and returns None for a string that is neither. Dinio reads a bearer token without the prefix as something else and answers ErrorCode::InvalidToken.