TypeScript SDK

Drive your hosting from TypeScript

@zinn-digital/sdk is a fully typed client for the Zinn Digital® API. Every path, parameter and response is generated from the same OpenAPI specification the API is built from, so your editor knows the whole API and a typo is a compile error.

All developer docs →

Install

The package is on npm under the @zinn-digital scope. It works in any JavaScript runtime that has fetch.

npm install @zinn-digital/sdk

Quick start

List the public hosting regions without a key, then list your own sites with one.

import { createApiClient } from "@zinn-digital/sdk";

const api = createApiClient({ baseUrl: "https://api.zinndigital.com" });

// Public catalogue endpoints need no key.
const { data: regions } = await api.GET("/v1/catalog/regions");
console.log(regions?.data.map((r) => r.slug));

// Everything else uses a per-organisation API key.
api.use({
  onRequest({ request }) {
    request.headers.set("Authorization", `Bearer ${process.env.ZINN_API_KEY}`);
  },
});

const { data, error } = await api.GET("/v1/sites", { params: { query: { limit: 5 } } });
if (error) throw new Error(error.error.message);
for (const site of data.data) console.log(site.name, site.status);

Authentication

Public catalogue endpoints, such as regions and plans, need no credential. Everything else uses a per-organisation API key sent as a bearer token. A key carries only the permissions you grant it when you create it, and you can revoke it at any time. Keep it in an environment variable or your secret store, never in source code.

Create an API key in your dashboard

What you get

The whole public API, typed

Sites, domains and DNS, billing, support and every other area of the public API. Responses and errors are typed, and the schema types are exported for your own code.

Generated, never hand-written

The client is openapi-fetch over types generated from our OpenAPI specification. A new version is published automatically whenever the specification changes, so a new endpoint reaches the SDK without anyone writing a wrapper.

Small and dependency-light

One runtime dependency and native fetch. It runs in Node.js, in the browser and in edge runtimes, and it is MIT-licensed.

Typed all the way down

Read a domain's DNS records and filter them with the record type the specification defines.

import type { components } from "@zinn-digital/sdk";

type DnsRecord = components["schemas"]["DnsRecord"];

// Paths, parameters and responses are all typed from the OpenAPI spec:
// a misspelt query parameter is a compile error, not a silent no-op.
const { data: records } = await api.GET("/v1/domains/{domainId}/dns/records", {
  params: { path: { domainId: "YOUR_DOMAIN_ID" } },
});
const txt: DnsRecord[] = (records?.data ?? []).filter((r) => r.type === "TXT");
for (const record of txt) console.log(record.name, record.value);

Questions

Do you have a TypeScript or JavaScript SDK?

Yes. Install @zinn-digital/sdk from npm. It is a fully typed client generated from our OpenAPI specification, and it covers the whole public API.

How do I authenticate?

Create an API key on the API keys page of your dashboard and send it as a bearer token in the Authorization header. Public catalogue endpoints need no key.

How is the SDK kept up to date?

It is generated from the same OpenAPI specification the API is built from, and a new version is published automatically whenever that specification changes.

Explore every endpoint

Every operation the SDK can call is described in the API reference, with its parameters, responses and permissions.

API reference