An Obsidian plugin that exposes an HTTP API for the Petra CLI, enabling AI agents and automation tools to interact with your vault.
This plugin is designed to work with the Petra CLI. The CLI provides a convenient command-line interface for all API operations:
petra note list
petra note search "query"
petra note backlinks "path/to/note"
petra graph neighbors "path/to/note"- HTTP API - RESTful endpoints for vault operations
- Note Management - Create, read, update, delete notes
- Search - Full-text search across your vault
- Daily Notes - Create and manage daily notes
- Tags - List and search by tags
- Links - Query backlinks and outlinks
- Graph - Traverse the link graph
- Templates - Execute templates programmatically
- Open Obsidian Settings
- Go to Community Plugins
- Search for "Petra Bridge"
- Click Install, then Enable
- Download the latest release from GitHub Releases
- Extract files to your vault's
.obsidian/plugins/petra-bridge/folder - Enable the plugin in Obsidian Settings > Community Plugins
The plugin starts an HTTP server on localhost:27182 when enabled.
On first run, a token is generated at ~/.petra/token. All API requests (except /health) require this token:
TOKEN=$(cat ~/.petra/token)
curl -H "Authorization: Bearer $TOKEN" http://localhost:27182/vaultGET /health
GET /vault
GET /notes # List notes
POST /notes # Create note
GET /notes/:path # Read note
PUT /notes/:path # Update note
DELETE /notes/:path # Delete note
POST /notes/:path/move # Move/rename note
GET /notes/:path/backlinks # Get backlinks
GET /notes/:path/outlinks # Get outlinks
POST /search
Body: { "query": "keyword", "folder": "optional", "limit": 20, "caseSensitive": false }
GET /tags # List all tags with counts
GET /tags/:tag/notes # Get notes with tag
POST /daily # Create daily note
GET /daily/:date # Get daily note (date: YYYY-MM-DD, "today", "yesterday", "tomorrow")
GET /daily # List recent daily notes
POST /graph/query # Query link graph
GET /graph/neighbors/:path # Get immediate neighbors
GET /templates # List available templates
POST /templates/:name/run # Execute template
Body: { "destination": "path/to/new-note", "variables": { "key": "value" } }
- The server binds to
127.0.0.1only (localhost) - All endpoints (except
/health) require authentication - Token is stored with restrictive permissions (
0600)
# Install dependencies
npm install
# Build
npm run build
# Development mode (watch)
npm run dev
# Type check
npm run typecheckMIT