360 Secure SkillHub
360 安全技能中心

obsidian-rest-api

面向 WSL 或远程环境的 Obsidian 操作技能,借助 Obsidian 的 Local REST API 插件完成端点与密钥配置,支持读取、创建、追加笔记,获取日记与标签,搜索笔记、在界面打开文件以及执行 Obsidian 命令,并附带完整接口文档与常见故障排查说明。

jieszs
jieszs
热度 26.31
最近更新 2026-05-11 19:01:46
分类:知识依赖:代码执行 / 第三方 API / 读写文件应用场景:笔记整理 / 工作流 / API 集成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add obsidian-rest-api
Metadata
name
obsidian-rest-api
description
Operate Obsidian via Local REST API plugin from remote/WSL environments. Use when: (1) user asks to operate Obsidian, read/write notes, or manage vault remotely; (2) working with Obsidian vault files from WSL/remote where direct filesystem access is blocked; (3) creating, editing, or searching notes through API instead of file edits.

Obsidian REST API

Operate Obsidian via Local REST API plugin from WSL or remote environments.

First-Time Setup

On first use, automatically detect and save configuration:

  1. Check TOOLS.md for existing OBSIDIAN_API_URL and OBSIDIAN_API_KEY
  2. If not found:
    • Get Windows host IP: cat /etc/resolv.conf | grep nameserver | awk '{print $2}'
    • Ask user for API Key
    • Save to TOOLS.md:
      ### Obsidian REST API (WSL → Windows)
      **API 端点**: https://<detected-ip>:27124
      **API Key**: <user-provided-key>
      
  3. Test connection with saved config

Configuration Format

Saved in TOOLS.md:

### Obsidian REST API (WSL → Windows)
**API 端点**: https://<windows-host-ip>:27124
**API Key**: <your-api-key>

Quick Start

# Get URL and KEY from TOOLS.md
URL=$(grep 'API 端点' ~/.openclaw/workspace/TOOLS.md | awk -F': ' '{print $2}')
KEY=$(grep 'API Key' ~/.openclaw/workspace/TOOLS.md | awk -F': ' '{print $2}')

# Test connection
curl -k -H "Authorization: Bearer $KEY" "$URL/"

# List vault files
curl -k -H "Authorization: Bearer $KEY" "$URL/vault/"

# Create note
curl -k -X PUT -H "Authorization: Bearer $KEY" -H "Content-Type: text/markdown" \
  -d "# Title\nContent" "$URL/vault/note.md"

Common Tasks

Create/Update Note

curl -k -X PUT -H "Authorization: Bearer $KEY" -H "Content-Type: text/markdown" \
  --data "<content>" "$URL/vault/<filename>.md"

Append to Note

curl -k -X POST -H "Authorization: Bearer $KEY" -H "Content-Type: text/markdown" \
  --data "<content-to-append>" "$URL/vault/<filename>.md"

Get Daily Note

curl -k -H "Authorization: Bearer $KEY" "$URL/periodic/daily/"
# Or specific date:
curl -k -H "Authorization: Bearer $KEY" "$URL/periodic/daily/2026/05/11/"

Search Notes

# Simple text search
curl -k -X POST -H "Authorization: Bearer $KEY" \
  "$URL/search/simple/?query=keyword"

# Advanced search (Dataview-style)
curl -k -X POST -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"query":"tag:#work"}' "$URL/search/"

Get Active File

curl -k -H "Authorization: Bearer $KEY" "$URL/active/"

Open File in UI

curl -k -X POST -H "Authorization: Bearer $KEY" "$URL/open/note.md"

Execute Command

# List available commands
curl -k -H "Authorization: Bearer $KEY" "$URL/commands/"

# Execute command
curl -k -X POST -H "Authorization: Bearer $KEY" "$URL/commands/daily-notes"

Get All Tags

curl -k -H "Authorization: Bearer $KEY" "$URL/tags/"

API Reference

See references/api.md for complete endpoint documentation.

Troubleshooting

Connection refused: Windows firewall blocking port.

# PowerShell (admin)
New-NetFirewallRule -DisplayName "Obsidian REST API" -Direction Inbound -LocalPort 27124 -Protocol TCP -Action Allow

SSL error: Use -k flag (self-signed cert).

Vault not found: Ensure vault is open in Obsidian.

Windows Setup

  1. Install Local REST API plugin in Obsidian
  2. Enable "Bind to all interfaces" in plugin settings
  3. Allow port in Windows firewall
  4. Generate API key