Fix docs: correct install URL (M-3), replace false SDK claims with fetch example (M-2)
This commit is contained in:
+51
-38
@@ -12,7 +12,7 @@ export default function DocsApiPage() {
|
|||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
Every action available in the DashCaddy UI is also available through a programmatic surface: a versioned REST
|
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
|
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.
|
for extending the platform. This guide covers each surface with concrete examples.
|
||||||
</p>
|
</p>
|
||||||
@@ -86,46 +86,59 @@ curl -X POST -H "Authorization: Bearer ***" \\
|
|||||||
frequent reads and do not count against the REST rate limit.
|
frequent reads and do not count against the REST rate limit.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2>JavaScript SDK</h2>
|
<h2>JavaScript automation</h2>
|
||||||
<p>
|
<p>
|
||||||
For programmatic automation, DashCaddy ships a typed JavaScript SDK with <strong>39 methods</strong> and full
|
For programmatic automation, use the REST API directly with <code>fetch</code> or any HTTP client. The API is
|
||||||
<strong> TypeScript types</strong>. It mirrors the REST API and handles authentication, retries, and structured
|
JSON-based, uses Bearer token authentication, and returns structured error codes. Here is a minimal helper
|
||||||
error handling for you. Install it from npm and use it in Node.js, Deno, Bun, or the browser.
|
you can drop into any Node.js, Bun, or browser project:
|
||||||
</p>
|
</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
|
<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 {', '',
|
||||||
npm install @dashcaddy/sdk
|
' constructor(opts) {', '',
|
||||||
# or
|
' this.baseUrl = opts.baseUrl;', '',
|
||||||
pnpm add @dashcaddy/sdk`}</code></pre>
|
' this.token = opts.token;', '',
|
||||||
<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({
|
' async request(path, options) {', '',
|
||||||
baseUrl: 'https://dashcaddy-host',
|
' options = options || {};', '',
|
||||||
token: process.env.DC_TOKEN,
|
' var url = this.baseUrl + "/api/v1" + path;', '',
|
||||||
});
|
' var res = await fetch(url, {', '',
|
||||||
|
' method: options.method || "GET",', '',
|
||||||
// List services
|
' body: options.body,', '',
|
||||||
const services = await dc.services.list();
|
' headers: {', '',
|
||||||
|
' "Content-Type": "application/json",', '',
|
||||||
// Deploy a template
|
' "Authorization": "Bearer " + this.token', '',
|
||||||
const svc = await dc.services.deploy({
|
' }', '',
|
||||||
template: 'jellyfin',
|
' });', '',
|
||||||
name: 'media',
|
' var body = await res.json();', '',
|
||||||
hostname: 'media.lab',
|
' if (!res.ok) throw { code: body.error, status: res.status };', '',
|
||||||
});
|
' return body;', '',
|
||||||
|
' }', '',
|
||||||
// Adopt a discovered container
|
'', '',
|
||||||
await dc.services.adopt({ containerId: 'abc123', hostname: 'wiki.lab' });
|
' // List services', '',
|
||||||
|
' services() { return this.request("/services"); }', '',
|
||||||
// Create a DNS record
|
'', '',
|
||||||
await dc.dns.createRecord({ zone: 'lab', name: 'wiki', type: 'A', ip: '192.168.1.55' });
|
' // Deploy from template', '',
|
||||||
|
' deploy(template, name, hostname) {', '',
|
||||||
// Inspect service health
|
' return this.request("/services", {', '',
|
||||||
const health = await dc.services.health('media');`}</code></pre>
|
' 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>
|
<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.
|
code, HTTP status, and message — so your automation can branch on specific failure conditions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h2>AI Intent Router</h2>
|
<h2>AI Intent Router</h2>
|
||||||
<p>
|
<p>
|
||||||
The <strong>AI Intent Router</strong> accepts natural-language commands and translates them into real
|
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>
|
<h2>Structured error codes</h2>
|
||||||
<p>
|
<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
|
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
|
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.
|
machine-readable code, the HTTP status, and a human-readable message.
|
||||||
@@ -316,9 +329,9 @@ GET /readyz`}</code></pre>
|
|||||||
<h2>Why automation matters</h2>
|
<h2>Why automation matters</h2>
|
||||||
<p>
|
<p>
|
||||||
DashCaddy can execute the full infrastructure chain around a service, not just report its state after the fact.
|
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
|
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>
|
||||||
<p>
|
<p>
|
||||||
For the infrastructure that backs all of this, see <a href="/docs/integrations">Integrations</a>. When things go
|
For the infrastructure that backs all of this, see <a href="/docs/integrations">Integrations</a>. When things go
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export default function DocsInstallationPage() {
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Step 1: Clone the repository</h3>
|
<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>
|
cd dashcaddy`}</code></pre>
|
||||||
|
|
||||||
<h3>Step 2: Make the launcher executable</h3>
|
<h3>Step 2: Make the launcher executable</h3>
|
||||||
@@ -287,7 +287,7 @@ networks:
|
|||||||
instead of using <code>start.sh</code>:
|
instead of using <code>start.sh</code>:
|
||||||
</p>
|
</p>
|
||||||
<ol>
|
<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>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 Caddy and confirm the Admin API is reachable on port 2019</li>
|
||||||
<li>Prepare Technitium DNS if you want automatic DNS changes (optional)</li>
|
<li>Prepare Technitium DNS if you want automatic DNS changes (optional)</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user