Files
daniel156161 902a3df8b5
Build and Push Docker Container / build-and-push (push) Successful in 4m26s
feat: add Obsidian CLI API service
- Add Docker image for the official Obsidian desktop app and CLI.

- Start Obsidian headlessly with Xvfb and DBus setup.

- Expose a safe structured HTTP command API without shell execution.

- Add JWT-based vault, path, and command authorization.

- Support single-vault and multi-vault container mounts.

- Add TypeScript SDK helpers for Obsidian CLI commands.

- Add n8n community node package with Obsidian operations.

- Add docs, compose config, tests, and production image workflow.
2026-06-24 09:11:13 +02:00

1.5 KiB

@obsidian-api/sdk

TypeScript SDK for this HTTP wrapper around the official Obsidian CLI.

The SDK is built for Node 18+, n8n Code nodes, Prism, and other TypeScript agent harnesses.

Install locally

npm install /path/to/obsidian-api/sdk/typescript

Usage

import { ObsidianCliClient } from '@obsidian-api/sdk';

const obsidian = new ObsidianCliClient({
  baseUrl: 'http://localhost:8080',
  token: 'change-me',
});

await obsidian.create({
  path: 'Inbox/Hello.md',
  content: '# Hello from n8n/Prism',
  overwrite: true,
});

const note = await obsidian.read({ path: 'Inbox/Hello.md' });
console.log(note.stdout);

const results = await obsidian.search('Hello', { format: 'json' });
console.log(JSON.parse(results.stdout));

Multiple vaults

Use the official CLI vault=<name> prefix directly:

await obsidian.runInVault('work', 'create', 'path=Inbox/Task.md', 'content=Hello');

Or create a scoped client:

const workVault = obsidian.inVault('work');
await workVault.create({ path: 'Inbox/Task.md', content: 'Hello', overwrite: true });
await workVault.read({ path: 'Inbox/Task.md' });

You can also set a default vault in the constructor:

const obsidian = new ObsidianCliClient({
  baseUrl: 'http://localhost:8080',
  token: 'change-me',
  vault: 'work',
});

Raw command escape hatch

Still safe: sends an args array, not a shell command string.

await obsidian.runRaw('create', 'name=Scratch', 'content=Test', 'overwrite');