Obsidian Local REST API
Read, write, search, append, patch, and manage notes in any Obsidian vault via the Local REST API on Windows, macOS, or Linux.
Only 1 Naren
@nj070574-gif
Install
$ openclaw skills install @nj070574-gif/obsidian-restObsidian Local REST API Skill
Control any Obsidian vault from OpenClaw using the Local REST API plugin. Works on any OS where Obsidian Desktop runs (Windows, macOS, Linux). No extra CLI tools needed — just curl.
Critical: Known Pitfalls (Read First)
These issues were discovered in real-world use and will cause silent failures if ignored:
1. Trailing slashes are mandatory on directory paths
The API returns {"message":"Not Found","errorCode":40400} if you omit trailing slashes on directory endpoints.
| Path | Result |
|---|---|
$OBSIDIAN_URL/vault/ | ✅ Correct — lists vault root |
$OBSIDIAN_URL/vault | ❌ 40400 error |
$OBSIDIAN_URL/vault/My%20Folder/ | ✅ Correct — lists subfolder |
$OBSIDIAN_URL/vault/My%20Folder | ❌ 40400 error |
2. The root health check endpoint is / — nothing else
There is no /api/, /api/healthz, /healthz, /status, or /health endpoint.
| Path | Result |
|---|---|
$OBSIDIAN_URL/ | ✅ Returns plugin status JSON |
$OBSIDIAN_URL/api/ | ❌ 40400 error |
$OBSIDIAN_URL/api/healthz | ❌ 40400 error |
3. Shell variable expansion may fail in exec contexts
$OBSIDIAN_URL and $OBSIDIAN_API_KEY are available in the gateway process but child shells
spawned by the exec tool may not inherit them depending on your OpenClaw configuration.
Always test variable expansion before using them in curl:
echo "URL=$OBSIDIAN_URL KEY_LEN=${#OBSIDIAN_API_KEY}"
If either is empty, the exec shell isn't inheriting the gateway's environment. Fix the inheritance (confirm the Environment= lines are in the systemd unit and restart the service), or re-export the vars in the shell by sourcing them from the service config. Never paste the literal API key into commands — it lands in shell history and session logs.
4. Never dump raw JSON to the user
Always interpret API responses and reply in plain English. See the Output Formatting section.
Prerequisites
- Obsidian Desktop installed and running with a vault open.
- Local REST API plugin installed and enabled in Obsidian:
- Open Obsidian → Settings → Community plugins → Browse → search "Local REST API" → Install → Enable.
- API Key copied from: Settings → Local REST API → API Key.
- Port noted (default:
27124). HTTPS is strongly recommended. - Env vars set in your OpenClaw service (see Setup below).
Setup
1. Add env vars to your OpenClaw systemd service
sudo nano /etc/systemd/system/openclaw.service
Add these two lines in the [Service] block:
Environment=OBSIDIAN_URL=https://YOUR_OBSIDIAN_HOST:27124
Environment=OBSIDIAN_API_KEY=your_api_key_here
Then reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart openclaw.service
2. Verify the env vars are set (without printing the key)
echo "OBSIDIAN_URL set: ${OBSIDIAN_URL:+yes} | API key length: ${#OBSIDIAN_API_KEY}"
You should see the URL marked set and a non-zero key length. If the key length is 0, the service isn't passing the variables — re-check the Environment= lines in the unit and restart. (Avoid dumping /proc/<pid>/environ or otherwise printing the key — it ends up in shell history and logs.)
3. Test the connection
curl -sk \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
"$OBSIDIAN_URL/" \
| python3 -c "import json,sys; d=json.load(sys.stdin); print('OK — Obsidian', d['versions']['obsidian'], '| Plugin', d['versions']['self'], '| Auth:', d['authenticated'])"
Expected: OK — Obsidian 1.x.x | Plugin 3.x.x | Auth: True
If $OBSIDIAN_URL is empty, fix the env inheritance (see Pitfall 3) rather than inlining secrets. Only as a last resort for a one-off test, you can substitute placeholders locally — never commit or log a real key:
curl -sk \
-H "Authorization: Bearer YOUR_API_KEY_HERE" \
"https://YOUR_OBSIDIAN_HOST:27124/" \
| python3 -c "import json,sys; d=json.load(sys.stdin); print('OK — Obsidian', d['versions']['obsidian'], '| Plugin', d['versions']['self'], '| Auth:', d['authenticated'])"
4. Install the skill
# Via ClawHub (recommended — versioned + checksum-verified)
openclaw skills install obsidian-rest
# Or manually, pinned to a release tag (avoid tracking mutable main)
git clone --branch v1.2.0 --depth 1 https://github.com/nj070574-gif/openclaw-obsidian-vault-skill.git
cp -r openclaw-obsidian-vault-skill/skill ~/.openclaw/workspace/skills/obsidian-rest
Environment Variables
| Variable | Required | Description |
|---|---|---|
OBSIDIAN_URL | ✅ Yes | Full base URL including protocol and port, e.g. https://192.0.2.100:27124 |
OBSIDIAN_API_KEY | ✅ Yes | API key from Obsidian → Settings → Local REST API |
The plugin uses a self-signed certificate by default, so these examples use curl -sk. ⚠️ -k skips TLS certificate verification, so the API key and note contents travel over an unverified connection — only acceptable on a trusted LAN. When the traffic crosses any untrusted network, export the plugin's certificate (Obsidian → Settings → Local REST API → download the certificate) and use curl --cacert /path/to/obsidian-local-rest-api.crt instead of -k, or front the plugin with a reverse proxy holding a properly trusted cert.
API Reference
All requests require the auth header:
Authorization: Bearer $OBSIDIAN_API_KEY
Check API status (root endpoint only)
curl -sk -H "Authorization: Bearer $OBSIDIAN_API_KEY" "$OBSIDIAN_URL/"
Returns: {"status":"OK","authenticated":true,"versions":{"obsidian":"1.x.x","self":"3.x.x"}, ...}
List vault root (trailing slash required)
curl -sk -H "Authorization: Bearer $OBSIDIAN_API_KEY" "$OBSIDIAN_URL/vault/" \
| python3 -c "import json,sys; [print(f) for f in sorted(json.load(sys.stdin)['files'])]"
List a subfolder (trailing slash required)
curl -sk -H "Authorization: Bearer $OBSIDIAN_API_KEY" "$OBSIDIAN_URL/vault/My%20Folder/" \
| python3 -c "import json,sys; [print(f) for f in json.load(sys.stdin)['files']]"
URL encoding: spaces →
%20| forward slash within a path segment →%2F
Encode any path automatically:
python3 -c "import urllib.parse; print(urllib.parse.quote('My Folder/My Note.md', safe=''))"
Read a note
curl -sk -H "Authorization: Bearer $OBSIDIAN_API_KEY" \
"$OBSIDIAN_URL/vault/PATH%2FTO%2FNOTE.md"
Returns raw Markdown content.
Create or overwrite a note (PUT)
curl -sk -X PUT \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
-H "Content-Type: text/markdown" \
--data-binary "# My Note Title
Content goes here." \
"$OBSIDIAN_URL/vault/PATH%2FTO%2FNOTE.md"
Returns HTTP 204 No Content on success.
Warning: PUT replaces the entire file. Use POST to append safely.
Append to an existing note (POST)
curl -sk -X POST \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
-H "Content-Type: text/markdown" \
--data-binary "
## New Section $(date +%Y-%m-%d)
Content to append." \
"$OBSIDIAN_URL/vault/PATH%2FTO%2FNOTE.md"
Returns HTTP 204 No Content on success.
Patch / insert at a heading (PATCH)
curl -sk -X PATCH \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
-H "Content-Type: text/markdown" \
-H "Operation: append" \
-H "Target-Type: heading" \
-H "Target: My Section Heading" \
--data-binary "Content to insert under the heading." \
"$OBSIDIAN_URL/vault/PATH%2FTO%2FNOTE.md"
Valid Operation: append | prepend | replace | delete. Valid Target-Type: heading | block | frontmatter. (Plugin 3.x headers; older <3.x used a single Heading header.)
Delete a note
curl -sk -X DELETE \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
"$OBSIDIAN_URL/vault/PATH%2FTO%2FNOTE.md"
Returns HTTP 204 No Content on success.
Search vault (full-text)
curl -sk -X POST \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
"$OBSIDIAN_URL/search/simple/?query=YOUR+SEARCH+TERM&contextLength=150" \
| python3 -c "
import json, sys
results = json.load(sys.stdin)
if not results:
print('No matches found.')
else:
print(f'Found {len(results)} match(es):')
for r in results[:5]:
print(' -', r['filename'])
for m in r.get('matches', [])[:1]:
ctx = m.get('context', '').strip()
if ctx: print(' ...', ctx[:100])
"
Get currently active file in Obsidian
curl -sk -H "Authorization: Bearer $OBSIDIAN_API_KEY" "$OBSIDIAN_URL/active/"
List available Obsidian commands
curl -sk -H "Authorization: Bearer $OBSIDIAN_API_KEY" "$OBSIDIAN_URL/commands/" \
| python3 -c "import json,sys; [print(c['id'], '|', c['name']) for c in json.load(sys.stdin).get('commands',[])]"
Execute an Obsidian command
curl -sk -X POST \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"commandId": "editor:save-file"}' \
"$OBSIDIAN_URL/commands/execute/"
Output Formatting Rules
Never dump raw JSON to the user. Always interpret results and reply in plain English.
| Situation | What to say |
|---|---|
Status check returns "authenticated": true | "✅ Obsidian vault connected — Obsidian v1.x.x, plugin v3.x.x" |
| Status check fails / 40400 error | "❌ Cannot reach Obsidian vault: [exact error]. Check Obsidian is running." |
| Vault listed | "Your vault contains X items: [list files and folders]" |
| Subfolder listed | "Found X notes in [folder]: [list]" |
| Note read | Return the note content (or a summary if it's long) |
| Note created (HTTP 204) | "✅ Created [path]" |
| Note saved / overwritten (HTTP 204) | "✅ Saved to [path]" |
| Note appended (HTTP 204) | "✅ Appended to [path]" |
| Search returns results | "Found X notes matching '[query]': [list filenames]" |
| Search returns nothing | "No notes found matching '[query]'" |
| 40400 error | "❌ API returned Not Found — check the path and trailing slashes" |
| 401 error | "❌ Unauthorised — check OBSIDIAN_API_KEY is set correctly" |
Workflow Guide
Saving content ("sv" / "save this")
- Check env vars expand:
echo "URL=$OBSIDIAN_URL LEN=${#OBSIDIAN_API_KEY}" - Pick the right folder from context (infrastructure →
Infrastructure/, daily log →Daily/) - Choose a descriptive hyphenated filename, e.g.
Setup-Guide-2026-04-12.md - Check if file exists:
GET /vault/PATH.md— HTTP 404 means safe to create - Use
PUTto create,POSTto append to existing - Confirm with plain English: "✅ Saved to
Infrastructure/Setup-Guide.md"
Finding a note
- Search:
POST /search/simple/?query=TERM - If multiple results, list filenames and ask which to open
GETthe file and return its content or a summary
Updating a note
- Read the file first to understand its structure
POSTto append, orPATCHwithHeadingheader for targeted insertion- Confirm what was added and where
Creating new folders
New folders are created automatically when you PUT a file into a path that doesn't exist yet.
Common Patterns
Save a runbook
NOTE_PATH="Infrastructure%2FRunbook-$(date +%Y-%m-%d).md"
curl -sk -X PUT \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
-H "Content-Type: text/markdown" \
--data-binary "# Runbook — $(date +%Y-%m-%d)
## Steps
1. Step one
2. Step two
" \
"$OBSIDIAN_URL/vault/$NOTE_PATH"
echo "Saved to vault/$NOTE_PATH"
Append a timestamped log entry
curl -sk -X POST \
-H "Authorization: Bearer $OBSIDIAN_API_KEY" \
-H "Content-Type: text/markdown" \
--data-binary "
- $(date '+%Y-%m-%d %H:%M') — Log entry here" \
"$OBSIDIAN_URL/vault/Daily%2FLog.md"
URL Encoding Quick Reference
| Character | Encoded |
|---|---|
Space | %20 |
/ (within a path segment) | %2F |
# | %23 |
& | %26 |
+ | %2B |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
curl: (7) Failed to connect | Obsidian not running or wrong host/port | Check Obsidian is open; verify OBSIDIAN_URL |
{"message":"Not Found","errorCode":40400} | Wrong path — missing trailing slash, or non-existent endpoint | Add / to end of directory paths; use only documented endpoints |
HTTP 401 Unauthorized | Wrong or missing API key | Verify OBSIDIAN_API_KEY matches plugin settings |
| SSL certificate error | Self-signed cert | Always use curl -sk — never curl -s alone (or --cacert with the exported plugin certificate for verified TLS) |
$OBSIDIAN_URL empty in curl | Env var not inherited by exec shell | Confirm the Environment= lines are in the unit and restart; re-source the env in the shell. Don't inline the literal key. |
Skill shows △ needs setup | Env vars not set | Add Environment= lines to openclaw.service, reload, restart |
| Obsidian on Windows, agent on Linux | Firewall blocking port | Allow TCP 27124 inbound in Windows Defender Firewall |
Windows Firewall (Obsidian on Windows, OpenClaw on Linux)
Windows Defender Firewall → Advanced Settings → Inbound Rules → New Rule
→ Port → TCP → 27124 → Allow → All profiles → Name: "Obsidian Local REST API"
Plugin Information
- Plugin: Obsidian Local REST API by Adam Coddington
- Default port:
27124 - Protocol: HTTPS (self-signed cert) or HTTP
- Obsidian minimum version:
0.12.0 - Plugin version tested:
3.2.0
Top skills in this category
Google Docs
@hith3shGoogle Docs API integration with managed OAuth. Search, read, create, and update Google Docs documents. Use this skill when users want to read document text,...
Monday.com
@byungkyuMonday.com API integration with managed OAuth. Manage boards, items, columns, groups, and workspaces using GraphQL, and read account context through the `me` and `users` queries. Use this skill when users want to create, update, or query Monday.com boards and items, manage tasks, or automate workflows. For other third party apps, use the api-gateway skill (https://clawhub.ai/byungkyu/api-gateway). Requires network access and valid Maton API key. Calls run through the `maton` CLI with OAuth login, or over raw HTTP with a Maton API key where the CLI cannot be installed. Every call is authenticated as the user's connection and reaches only what that connection's authorization allows, which the provider enforces on every request; the endpoints documented here are the ones this skill uses, and any other endpoint of this app needs the user to ask for it by name. Default to read and list calls, and confirm every write or new connection with the user. This file also documents the three constructs that turn a Monday.com connection into automation, in the order they are used: the connection (the first step), a hosted function that runs a Monday.com action through the Maton SDK, and a trigger that calls that function on a schedule or on an event. Those sections are the platform's own reference text, shared with the api-gateway skill, with Monday.com examples; they add no Monday.com capability - Monday.com is not an event source, a trigger cannot read Monday.com data, and the files under `references/<source>/triggers.md` are the platform's event catalogues for the sources Maton offers (time, Calendly, GitHub, Gmail, HubSpot, Linear, Notion, Slack, Stripe).
Ollama Local
@timverhoogtManage and use local Ollama models. Use for model management (list/pull/remove), chat/completions, embeddings, and tool-use with local LLMs. Covers OpenClaw sub-agent integration and model selection guidance.
google-docs
@byungkyuGoogle Docs API integration with managed OAuth. Create documents, insert text, apply formatting, and manage content. Use this skill when users want to interact with Google Docs. For other third party apps, use the api-gateway skill (https://clawhub.ai/byungkyu/api-gateway). Calls run through the `maton` CLI with OAuth login, or over raw HTTP with a Maton API key where the CLI cannot be installed. Every call is authenticated as the user's connection and reaches only what that connection's authorization allows, which the provider enforces on every request; the endpoints documented here are the ones this skill uses, and any other endpoint of this app needs the user to ask for it by name. Default to read and list calls, and confirm every write or new connection with the user. This file also documents the three constructs that turn a Google Docs connection into automation, in the order they are used: the connection (the first step), a hosted function that runs a Google Docs action through the Maton SDK, and a trigger that calls that function on a schedule or on an event. Those sections are the platform's own reference text, shared with the api-gateway skill, with Google Docs examples; they add no Google Docs capability - Google Docs is not an event source, a trigger cannot read Google Docs data, and the files under `references/<source>/triggers.md` are the platform's event catalogues for the sources Maton offers (time, Calendly, GitHub, Gmail, HubSpot, Linear, Notion, Slack, Stripe).
Cinematic Script Writer
@praveenspeaksCreate professional cinematic scripts for AI video generation with character consistency and cinematography knowledge. Use when the user wants to write a cinematic script, create story contexts with characters, generate image prompts for AI video tools (Midjourney, Sora, Veo), or needs cinematography guidance (camera angles, lighting, color grading). Also use for character consistency sheets, voice profiles, anachronism detection, and saving scripts to Google Drive.