Skip to content

byrafael/uapi

Repository files navigation

UAPI (@rsrdev/uapi)

Bun-first TypeScript client for the cPanel UAPI.

@rsrdev/uapi uses the standard fetch API, ships modern ESM for Node.js, and exposes a base client plus typed service wrappers for documented UAPI modules.

Install

bun add @rsrdev/uapi
npm install @rsrdev/uapi

Create a client

import { CpanelUapiClient } from "@rsrdev/uapi";

const client = new CpanelUapiClient({
  baseUrl: "https://host.example.com:2083",
  auth: {
    kind: "apiToken",
    username: "cpanel-user",
    token: process.env.CPANEL_UAPI_TOKEN!,
  },
});

Use the email service

const response = await client.email.createAccount({
  email: "support",
  password: "super-secret-password",
  domain: "example.com",
  quota: 1024,
});

console.log(response.result.data);

Use the domains service

const response = await client.domains.addSubdomain({
  domain: "blog",
  rootdomain: "example.com",
  dir: "public_html/blog",
});

console.log(response.result.status);

Use the FTP service

await client.ftp.addFtp({
  user: "deploy",
  pass: "super-secret-password",
  domain: "example.com",
  quota: 1024,
});

Use the MySQL service

await client.mysql.createDatabase({
  name: "appdb",
});

await client.mysql.createUser({
  name: "appuser",
  password: "super-secret-password",
});

Use the SSL service

const certs = await client.ssl.listCerts();
console.log(certs.result.data);

Use the DNS service

const zone = await client.dns.lookup({
  domain: "example.com",
});

console.log(zone.result.data);

Use the DNSSEC service

const records = await client.dnssec.fetchDsRecords({
  domain: "example.com",
});

console.log(records.result.data);

Execute any UAPI call directly

const response = await client.execute<{ user: string }>(
  "Variables",
  "get_user_information",
);

console.log(response.result.data.user);

Runtime notes

Bun applications resolve the source export directly. Node.js applications resolve the built ESM entry from dist.

Development

bun install
bun run check

Local UAPI docs mirror

bun run docs:map:uapi

This command snapshots the cPanel UAPI documentation into docs/cpanel-uapi/, including a local Markdown mirror, the upstream llms.txt, and a generated map.json index.

Domain scope

The domains service intentionally mirrors the documented UAPI surface in docs/. It supports subdomain creation, documented domain information lookups, temporary-domain operations, and domain capability checks.

Addon-domain and alias-domain creation are not included because no corresponding UAPI endpoints are present in the mirrored spec.

About

Typescript wrapper for the cPanel UAPI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors