Fix docs: correct install URL (M-3), replace false SDK claims with fetch example (M-2)

This commit is contained in:
Krystie
2026-08-12 22:35:50 -07:00
parent 15eabc4dc0
commit 8579a29185
2 changed files with 53 additions and 40 deletions
+51 -38
View File
@@ -12,7 +12,7 @@ export default function DocsApiPage() {
>
<p>
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.
</p>
@@ -86,46 +86,59 @@ curl -X POST -H "Authorization: Bearer ***" \\
frequent reads and do not count against the REST rate limit.
</p>
<h2>JavaScript SDK</h2>
<h2>JavaScript automation</h2>
<p>
For programmatic automation, DashCaddy ships a typed JavaScript SDK with <strong>39 methods</strong> and full
<strong> TypeScript types</strong>. 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 <code>fetch</code> 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:
</p>
<pre className="mt-4 overflow-x-auto rounded-lg border border-surface-700/50 bg-surface-950/80 p-4 text-sm"><code>{`# Install
npm install @dashcaddy/sdk
# or
pnpm add @dashcaddy/sdk`}</code></pre>
<pre className="mt-4 overflow-x-auto rounded-lg border border-surface-700/50 bg-surface-950/80 p-4 text-sm"><code>{`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');`}</code></pre>
<pre className="mt-4 overflow-x-auto rounded-lg border border-surface-700/50 bg-surface-950/80 p-4 text-sm"><code>{['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')}</code></pre>
<p>
Every SDK method returns a typed result or throws a structured <code>DashCaddyError</code> 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.
</p>
<h2>AI Intent Router</h2>
<p>
The <strong>AI Intent Router</strong> accepts natural-language commands and translates them into real
@@ -271,7 +284,7 @@ GET /readyz`}</code></pre>
<h2>Structured error codes</h2>
<p>
The API and SDK return <strong>80 structured error codes</strong> across <strong>12 modules</strong> rather
The API returns <strong>80 structured error codes</strong> across <strong>12 modules</strong> 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`}</code></pre>
<h2>Why automation matters</h2>
<p>
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 <code>curl</code> call, graduate to the SDK, and add AI and event-driven flows as your needs grow.
simple <code>curl</code> call, and add AI and event-driven flows as your needs grow.
</p>
<p>
For the infrastructure that backs all of this, see <a href="/docs/integrations">Integrations</a>. When things go
+2 -2
View File
@@ -84,7 +84,7 @@ export default function DocsInstallationPage() {
</p>
<h3>Step 1: Clone the repository</h3>
<pre className="mt-4 overflow-x-auto rounded-lg border border-surface-700/50 bg-surface-950/80 p-4 text-sm"><code>{`git clone https://github.com/samiahmed7777/dashcaddy.git
<pre className="mt-4 overflow-x-auto rounded-lg border border-surface-700/50 bg-surface-950/80 p-4 text-sm"><code>{`curl -fsSL https://get.dashcaddy.net | bash
cd dashcaddy`}</code></pre>
<h3>Step 2: Make the launcher executable</h3>
@@ -287,7 +287,7 @@ networks:
instead of using <code>start.sh</code>:
</p>
<ol>
<li>Clone the repository: <code>git clone https://github.com/samiahmed7777/dashcaddy.git</code></li>
<li>Run the installer: <code>curl -fsSL https://get.dashcaddy.net | bash</code></li>
<li>Install the API dependencies: <code>cd dashcaddy && npm ci</code></li>
<li>Prepare Caddy and confirm the Admin API is reachable on port 2019</li>
<li>Prepare Technitium DNS if you want automatic DNS changes (optional)</li>