Quick Start
Get up and running with the Obsidian SDK in under 5 minutes.
Quick Start
Get the Obsidian SDK set up and running in your local environment.
Prerequisites
- Node.js 18.x or higher
- npm 9.x or higher (or yarn/pnpm)
- Obsidian installed on your system
- Obsidian CLI (
obsidian) available in your PATH
Setup
1. Clone the Repository
git clone https://github.com/MYSELF-SAYAN/obsidian_cli_api.git
cd obsidian-sdk2. Install Dependencies
npm install3. Configure Environment
Create a .env file in the project root:
# Required: Your Obsidian vault name
OBSIDIAN_VAULT=myVault
# Optional: Custom port (default: 3000)
PORT=30004. Start Obsidian CLI Server
Before using the SDK, start the Obsidian CLI server:
npm run server
# or
npx obsidian serverThis starts the local API server on http://localhost:3000.
Installation
As a Project Dependency
npm install obsidian-sdkAs a Global CLI Tool
npm install -g obsidian-sdkBasic Usage
Initialize the SDK
import { Obsidian } from "obsidian-sdk";
// Connect to your vault
const obsidian = new Obsidian({ vault: "myVault" });List Files
// Get all files in the vault
const files = await obsidian.files.list();
console.log(files);Read a File
// Read specific file content
const content = await obsidian.files.read("Notes.md");
console.log(content);Search Notes
// Search for notes
const results = await obsidian.search.query("project");
console.log(results);Running Examples
Run a Single Example
node examples/list-files.jsRun All Examples
npm run examplesInteractive Mode
npm run devThis starts a REPL where you can interact with the SDK methods directly.
Common Setup Issues
Obsidian CLI Not Found
If obsidian command is not found:
- Open Obsidian
- Go to Settings → About
- Enable "Start Obsidian API server"
- Or install CLI:
npm install -g obsidian-cli
Port Already in Use
If port 3000 is occupied:
PORT=3001 npm run serverVault Not Found
Verify your vault name matches exactly:
# List available vaults
curl http://localhost:3000/api/vault/listNext Steps
- Explore the API Reference for all available methods
- Check out Service Groups for categorized endpoints
- Review example code in the
/examplesdirectory