@usenubis/sdk
v0.2.0
Published
Official Nubis JavaScript and TypeScript SDK
Readme
Nubis JavaScript / TypeScript SDK
Official JavaScript and TypeScript SDK for Nubis.
Built for production teams that want:
- fast onboarding with clean, resource-based APIs
- broad endpoint coverage generated from Nubis product APIs
- runtime-safe HTTP behavior (timeouts, retries, auth hooks, normalized errors)
Install
npm install @usenubis/sdkQuick Start
import { NubisClient } from "@usenubis/sdk";
const client = new NubisClient({
apiKey: process.env.NUBIS_API_KEY,
baseUrl: "https://nubis-core.onrender.com",
});
const orgs = await client.orgs.list();
console.log(orgs);
const projectId = "proj_123";
const vm = await client.vms.create(projectId, {
name: "api-server",
size: "s-1vcpu-1gb",
region: "nyc1",
image: "ubuntu-24.04-x64",
ssh_keys: [],
});
console.log(vm);Authentication
Use either a static API key or a dynamic token getter.
const client = new NubisClient({
getToken: async () => {
// Example: rotate a short-lived token from your auth layer
return process.env.NUBIS_ACCESS_TOKEN ?? null;
},
});getToken takes precedence over apiKey when both are provided.
High-Level API Surface
NubisClient includes grouped resource APIs for common workflows:
client.orgsclient.projectsclient.vms(alias:client.instances)client.kubernetesclient.databasesclient.networksclient.firewallsclient.billingclient.accountclient.domainsclient.storageclient.supportclient.admin
Example admin calls:
const hasAdminAccess = await client.admin.verifyAccess();
if (hasAdminAccess) {
const taxRates = await client.admin.taxRates();
console.log(taxRates);
}Raw Requests for Edge Cases
If you need a route before an ergonomic wrapper lands, use client.raw directly:
const { data, response } = await client.raw.get("/api/v1/status", {
params: { verbose: true },
});
console.log(response.status, data);Error Handling
The SDK throws HttpError for both HTTP and transport failures:
import { HttpError, isHttpError } from "@usenubis/sdk";
try {
await client.projects.get("org_123", "proj_123");
} catch (error) {
if (isHttpError(error)) {
console.error("status:", error.status);
console.error("message:", error.message);
console.error("body:", error.body);
} else {
console.error(error);
}
}Reliability Defaults
- default timeout:
30s - default retries:
2(idempotent methods only) - automatic bearer auth header when
apiKeyorgetTokenis configured - configurable global
onErrorcallback
Runtime Compatibility
The SDK is ESM-first and works in modern JavaScript runtimes that provide fetch, including:
- Node.js (18+)
- Bun
- browser environments
- edge runtimes
Type Exports
The package exports:
NubisClientHttpClientHttpError- generated API types from
src/generated/types.ts
SDK Generation and Development
Generated files in src/generated are synced from the current frontend API layer:
npm run generate
npm run buildUseful scripts:
npm run generateregeneratessrc/generated/*npm run buildregenerates + TypeScript compile checknpm run checkalias for full build check
Versioning and Release
- bump
versioninpackage.json - run
npm run build - publish with your standard npm release workflow
License
MIT. See LICENSE.md.
Related SDK
Need Rust? See the Nubis Rust SDK README in:
../sdk-rust/README.md
