Client
import { DinioClient } from '@dinio/sdk';
const dinio = new DinioClient({ baseUrl: 'https://api-dinio.bitelex.com', apiKey: process.env.DINIO_API_KEY,});One client is one connection to the API with one key. Create it once and reuse it; two clients in one process never affect each other.
Options
Section titled “Options”| Option | Default | |
|---|---|---|
baseUrl |
— | API endpoint without /api/v1; the SDK adds it. |
apiKey |
— | Personal (du_…) or zone (dz_…) API key, sent as Authorization: Bearer. Without one only health(), freeDomains and plans work. An empty key, or one without either prefix, throws DinioInputError. |
timeoutMs |
30000 |
Limit for the whole request, including reading the full response. 0 disables it. |
fetch |
global fetch |
Your own implementation — for a proxy, tests, or a runtime without a global fetch. |
userAgent |
Prepended to the SDK’s own dinio-sdk-ts/<version>. |
|
headers |
Extra headers on every request. They cannot override Authorization, Accept or Content-Type. |
Resources
Section titled “Resources”The API’s resources are properties of the client.
| Property | |
|---|---|
| DNS hosting | |
dinio.zones |
Zones, zone keys and zone files. |
dinio.freeDomains |
Free domains to lease a zone from. |
dinio.records |
Record sets and values, TTLs. |
dinio.healthChecks |
One health check per record value. |
dinio.geoBans |
Geo bans on record values. |
dinio.geo |
The areas a geo ban can use. |
dinio.zoneMembers |
A zone’s Owner and Administrators. |
dinio.redirects |
HTTP(S) redirects for host names in your zones. |
dinio.certificates |
TLS certificates for names in your zones. |
| DNS filtering — personal key only | |
dinio.clientIdentities |
Clients recognised by IP, DoT hostname or DoH path. |
dinio.sinkholeLists, dinio.sinkholeRoles, dinio.sinkholeLinks |
Blacklists and whitelists, their rules, and where they apply. |
| Other | |
dinio.stats |
Statistics of your zones and clients. |
dinio.auditLogs |
Who did what on your account and zones. |
dinio.users |
Your own account and personal key. |
dinio.plans |
The package price list; needs no key. |
dinio.account |
Your packages, and your usage against their limits. |
Every method is listed in Resources.
Cancellation and timeouts
Section titled “Cancellation and timeouts”Every method takes { signal } as its last argument. Aborting rejects the call with
DinioAbortError; running out of timeoutMs rejects it with DinioTimeoutError.
const dinio = new DinioClient({ baseUrl, apiKey, timeoutMs: 10_000 });
await dinio.zones.listAll({ signal: AbortSignal.timeout(5_000) });zones.discover waits at least 90 s, and sinkhole list import, setSource and refresh at
least 120 s, whatever timeoutMs is (unless it is 0).
There is no automatic retry. Every write is a single request; retry where it is safe for your use.
Health
Section titled “Health”dinio.health() calls the API’s health route. It needs no key
and never sends one.
const { status, version } = await dinio.health(); // "ok" | "degraded"Keys and logging
Section titled “Keys and logging”The key lives in a private field. It does not appear in toString, JSON.stringify,
util.inspect or error messages — they show it as …1234.
The only responses that contain a key are those of zones.createApiKey and
users.createApiKey — { api_key }, shown once. Don’t log them.
Running in a browser
The SDK works in a browser, but an API key in a browser is exposed to anyone who opens the page. Call Dinio from your server, a worker or CI instead.