Skip to content

TypeScript Client

The TypeScript client talks to the API over plain HTTP and JSON. It runs in the browser and in Node.js 18 or later. Source: github.com/enumco/client-ts.

Terminal window
npm install @enumco/client
import { createClient } from "@enumco/client";
const client = createClient({ token: process.env.ENUM_TOKEN });
const { zones } = await client.dns.listZones({
projectId: "proj-01kmyy3t719crcnrrvk1mgyjd0",
});
for (const zone of zones) {
console.log(zone.name);
}

See Authentication for how to get a token.

OptionDescription
tokenAPI token sent with every request
baseUrlAPI endpoint. Default: https://api.enum.co
PropertyService
client.organizationsOrganizationService
client.projectsProjectService
client.usersUserService
client.regionsRegionService
client.dnsDnsService
client.kubernetes.clustersKubernetesClusterService
client.storage.usersObjectStorageUserService
client.storage.accessKeysObjectStorageAccessKeyService
client.storage.bucketsObjectStorageBucketService
client.serviceAccountsServiceAccountService

Method names are camelCase versions of the methods in the API reference, such as listZones for ListZones.

Failed calls throw a ConnectError from @connectrpc/connect:

import { Code, ConnectError } from "@connectrpc/connect";
try {
await client.dns.getZone({ projectId, id });
} catch (err) {
if (ConnectError.from(err).code === Code.NotFound) {
// ...
}
}