JavaScript / TypeScript SDK
JavaScript / TypeScript SDK
@webgune/sdk is the official client for controlling your webgune account from code. It is a typed alternative to raw fetch calls against the REST API.
Installation
npm install @webgune/sdk
Usage
import { createClient } from "@webgune/sdk";
const webgune = createClient({ apiKey: process.env.WEBGUNE_API_KEY! });
const projects = await webgune.projects.list();
await webgune.services.redeploy("svc_123");
The API key is created from Dashboard → Developers → API keys (see API keys). Give the key one scope per resource used (projects, services, domains, billing, dashboard, apikeys, reseller), in the format resource:read or resource:write.
Covered resources
webgune.projects list · get · create · update · remove
webgune.services listByProject · get · create · remove · redeploy
logs · metrics · getEnv · setEnv · scale
deployments · rollback
webgune.domains check · list · register · get · remove
listDns · addDns · removeDns
webgune.billing plans · subscription · invoices
webgune.dashboard stats · deploymentHistory
webgune.apiKeys list · create · revoke · auditLog
webgune.reseller organization · subClients · overview
An endpoint not yet covered by a wrapper remains accessible via webgune.raw, the fully typed underlying openapi-fetch (new window) client:
const { data } = await webgune.raw.GET("/services/{id}/k8s-status", {
params: { path: { id: "svc_123" } },
});
Error handling
Any non-2xx response throws a WebguneApiError (status, code, message) instead of silently returning an incorrect value:
import { WebguneApiError } from "@webgune/sdk";
try {
await webgune.services.redeploy("id-inexistant");
} catch (err) {
if (err instanceof WebguneApiError && err.status === 404) {
console.error("Service not found");
}
}
Generated types
TypeScript types are generated automatically from the API's OpenAPI spec. They always reflect what the API accepts and returns, with no manual maintenance. Without an installed package, the interactive reference shows the same schemas directly in the browser.