TypeScript SDK
@dinio/sdk automates Dinio from scripts, integrations and CI. It covers the whole Dinio API
— DNS hosting (zones, zone files, free domains, records, health checks,
geo bans, members, redirects, certificates), DNS filtering (client
identities, sinkhole lists), statistics and the audit log — with typed models and errors.
- Runs anywhere
fetchdoes: Node.js 20+, Deno, Bun, Cloudflare Workers and other edge runtimes. Nonode:*imports. - Zero runtime dependencies. ESM, with
.d.tstypes and source maps. - Plain JavaScript works too — the types are a bonus. Every method has JSDoc with its API route, who may call it and the errors to expect, shown on hover in your editor.
Install
Section titled “Install”@dinio/sdk comes from the Dinio npm registry, not npmjs.com. Point the @dinio scope at it
in your project’s .npmrc, then install:
echo "@dinio:registry=https://git.bitelex.com/api/packages/dinio-public/npm/" >> .npmrcnpm install @dinio/sdkBun, Deno and CI: see Install › TypeScript SDK.
Quick start
Section titled “Quick start”import { DinioClient } from '@dinio/sdk';
const dinio = new DinioClient({ baseUrl: 'https://api-dinio.bitelex.com', apiKey: process.env.DINIO_API_KEY, // Deno: Deno.env.get('DINIO_API_KEY')});
for await (const zone of dinio.zones.iterate()) { console.log(zone.name);}
const zone = await dinio.zones.get('example.com'); // uuid or nameconst values = await dinio.records.listAll(zone.uuid, { type: 'A' }); // RecordValue[]The SDK never reads environment variables or config files: you pass the base URL and the key.
It never logs either, and JSON.stringify(dinio) shows the key redacted.
Two ways to work
Section titled “Two ways to work”By uuid — the resources on the client (dinio.zones, dinio.records, …) map one-to-one
to API routes and return the full objects, uuids included. If your integration keeps its own
state, store the uuids and work with them directly. See Resources.
const value = await dinio.records.create({ zone_id: zone.uuid, name: 'www.example.com', type: 'A', data: '192.0.2.1', ttl: 300,});await dinio.records.update(value.uuid, { data: '192.0.2.2' });By name — functions that look the uuids up for you and work the way you think about DNS: zone, name, type and data. See Working by name.
import { addRecordValue, qualifyName } from '@dinio/sdk';
const www = qualifyName('www', zone.name); // "www.example.com"await addRecordValue(dinio, zone, www, 'A', { data: '192.0.2.1', ttl: 300 });- Client — options, timeouts, cancellation, custom
fetch. - Resources — every method, by resource.
- Working by name — records and geo bans by name and data.
- Errors — the error classes and how to branch on them.