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.
Install
Section titled “Install”npm install @enumco/clientimport { 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.
Options
Section titled “Options”| Option | Description |
|---|---|
token | API token sent with every request |
baseUrl | API endpoint. Default: https://api.enum.co |
Services
Section titled “Services”| Property | Service |
|---|---|
client.organizations | OrganizationService |
client.projects | ProjectService |
client.users | UserService |
client.regions | RegionService |
client.dns | DnsService |
client.kubernetes.clusters | KubernetesClusterService |
client.storage.users | ObjectStorageUserService |
client.storage.accessKeys | ObjectStorageAccessKeyService |
client.storage.buckets | ObjectStorageBucketService |
client.serviceAccounts | ServiceAccountService |
Method names are camelCase versions of the methods in the API reference, such as listZones for ListZones.
Errors
Section titled “Errors”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) { // ... }}