diff --git a/src/app/docs/api/page.tsx b/src/app/docs/api/page.tsx index a93891f..cdee44b 100644 --- a/src/app/docs/api/page.tsx +++ b/src/app/docs/api/page.tsx @@ -12,7 +12,7 @@ export default function DocsApiPage() { >

Every action available in the DashCaddy UI is also available through a programmatic surface: a versioned REST - API, a typed JavaScript SDK, an AI Intent Router for natural-language commands, an MCP Server for AI assistant + API, a JavaScript automation layer, an AI Intent Router for natural-language commands, an MCP Server for AI assistant integration, a WebSocket channel for real-time events, a Prometheus endpoint for metrics, and a plugin system for extending the platform. This guide covers each surface with concrete examples.

@@ -86,46 +86,59 @@ curl -X POST -H "Authorization: Bearer ***" \\ frequent reads and do not count against the REST rate limit.

-

JavaScript SDK

+

JavaScript automation

- For programmatic automation, DashCaddy ships a typed JavaScript SDK with 39 methods and full - TypeScript types. It mirrors the REST API and handles authentication, retries, and structured - error handling for you. Install it from npm and use it in Node.js, Deno, Bun, or the browser. + For programmatic automation, use the REST API directly with fetch or any HTTP client. The API is + JSON-based, uses Bearer token authentication, and returns structured error codes. Here is a minimal helper + you can drop into any Node.js, Bun, or browser project:

-
{`# Install
-npm install @dashcaddy/sdk
-# or
-pnpm add @dashcaddy/sdk`}
-
{`import { DashCaddy } from '@dashcaddy/sdk';
-
-const dc = new DashCaddy({
-  baseUrl: 'https://dashcaddy-host',
-  token: process.env.DC_TOKEN,
-});
-
-// List services
-const services = await dc.services.list();
-
-// Deploy a template
-const svc = await dc.services.deploy({
-  template: 'jellyfin',
-  name: 'media',
-  hostname: 'media.lab',
-});
-
-// Adopt a discovered container
-await dc.services.adopt({ containerId: 'abc123', hostname: 'wiki.lab' });
-
-// Create a DNS record
-await dc.dns.createRecord({ zone: 'lab', name: 'wiki', type: 'A', ip: '192.168.1.55' });
-
-// Inspect service health
-const health = await dc.services.health('media');`}
+
{['class DashCaddy {', '',
+'  constructor(opts) {', '',
+'    this.baseUrl = opts.baseUrl;', '',
+'    this.token = opts.token;', '',
+'  }', '',
+'', '',
+'  async request(path, options) {', '',
+'    options = options || {};', '',
+'    var url = this.baseUrl + "/api/v1" + path;', '',
+'    var res = await fetch(url, {', '',
+'      method: options.method || "GET",', '',
+'      body: options.body,', '',
+'      headers: {', '',
+'        "Content-Type": "application/json",', '',
+'        "Authorization": "Bearer " + this.token', '',
+'      }', '',
+'    });', '',
+'    var body = await res.json();', '',
+'    if (!res.ok) throw { code: body.error, status: res.status };', '',
+'    return body;', '',
+'  }', '',
+'', '',
+'  // List services', '',
+'  services() { return this.request("/services"); }', '',
+'', '',
+'  // Deploy from template', '',
+'  deploy(template, name, hostname) {', '',
+'    return this.request("/services", {', '',
+'      method: "POST",', '',
+'      body: JSON.stringify({ template, name, hostname })', '',
+'    });', '',
+'  }', '',
+'', '',
+'  // Restart a service', '',
+'  restart(id) {', '',
+'    return this.request("/services/" + id + "/restart", { method: "POST" });', '',
+'  }', '',
+'}'].join('\n')}

- Every SDK method returns a typed result or throws a structured DashCaddyError carrying the error + Every request returns a structured JSON response or throws an error object carrying the error code, HTTP status, and message — so your automation can branch on specific failure conditions.

+ + + +

AI Intent Router

The AI Intent Router accepts natural-language commands and translates them into real @@ -271,7 +284,7 @@ GET /readyz`}

Structured error codes

- The API and SDK return 80 structured error codes across 12 modules rather + The API returns 80 structured error codes across 12 modules rather than opaque messages, so your automation can branch on specific failure conditions — DNS token invalid, Caddy unreachable, license expired, rate limited — instead of parsing strings. Every error response includes the machine-readable code, the HTTP status, and a human-readable message. @@ -316,9 +329,9 @@ GET /readyz`}

Why automation matters

DashCaddy can execute the full infrastructure chain around a service, not just report its state after the fact. - Between the REST API, the JS SDK, the AI Intent Router, MCP, WebSockets, Prometheus, and the plugin system, you + Between the REST API, the AI Intent Router, MCP, WebSockets, Prometheus, and the plugin system, you have every surface you need to make DashCaddy a first-class citizen of your automation stack. Start with a - simple curl call, graduate to the SDK, and add AI and event-driven flows as your needs grow. + simple curl call, and add AI and event-driven flows as your needs grow.

For the infrastructure that backs all of this, see Integrations. When things go diff --git a/src/app/docs/installation/page.tsx b/src/app/docs/installation/page.tsx index d5aee9b..af730a6 100644 --- a/src/app/docs/installation/page.tsx +++ b/src/app/docs/installation/page.tsx @@ -84,7 +84,7 @@ export default function DocsInstallationPage() {

Step 1: Clone the repository

-
{`git clone https://github.com/samiahmed7777/dashcaddy.git
+        
{`curl -fsSL https://get.dashcaddy.net | bash
 cd dashcaddy`}

Step 2: Make the launcher executable

@@ -287,7 +287,7 @@ networks: instead of using start.sh:

    -
  1. Clone the repository: git clone https://github.com/samiahmed7777/dashcaddy.git
  2. +
  3. Run the installer: curl -fsSL https://get.dashcaddy.net | bash
  4. Install the API dependencies: cd dashcaddy && npm ci
  5. Prepare Caddy and confirm the Admin API is reachable on port 2019
  6. Prepare Technitium DNS if you want automatic DNS changes (optional)