Obsidian SDK

Search

Auto-generated API documentation.

Search Service

Search for notes and content within your Obsidian vault.

Service Overview

The Search service provides full-text search capabilities, context retrieval, and search result navigation. It wraps Obsidian's powerful search functionality.

Base URL

/api/files/search

Endpoints


GET /api/files/search

Perform a text search across all notes in the vault.

CLI Command: obsidian search

Query Parameters:

ParameterTypeRequiredDescription
querystringYesSearch query string
pathstringNoLimit search to specific folder
limitnumberNoMaximum number of results
casebooleanNoEnable case-sensitive search
vaultstringNoTarget vault name

Example Request:

curl "http://localhost:3000/api/files/search?query=project&vault=youtube"

Example Response:

{
  "success": true,
  "data": {
    "type": "list",
    "data": [
      "Projects/TestNote.md",
      "Projects/Notes.md",
      "Archive/ProjectIdeas.md"
    ]
  }
}

With path filter:

curl "http://localhost:3000/api/files/search?query=test&path=Projects&vault=youtube"

Python (with path filter):

response = requests.get("http://localhost:3000/api/files/search", params={
    "query": "test",
    "path": "Projects",
    "vault": "youtube"
})

With limit:

curl "http://localhost:3000/api/files/search?query=notes&limit=10&vault=youtube"

Python (with limit):

response = requests.get("http://localhost:3000/api/files/search", params={
    "query": "notes",
    "limit": 10,
    "vault": "youtube"
})

Case-sensitive search:

curl "http://localhost:3000/api/files/search?query=Test&case=true&vault=youtube"

Python (case-sensitive):

response = requests.get("http://localhost:3000/api/files/search", params={
    "query": "Test",
    "case": "true",
    "vault": "youtube"
})

GET /api/files/search/context

Search with surrounding context lines for each match.

CLI Command: obsidian search:context

Query Parameters:

ParameterTypeRequiredDescription
querystringYesSearch query string
pathstringNoLimit search to specific folder
limitnumberNoMaximum number of results
casebooleanNoEnable case-sensitive search
vaultstringNoTarget vault name

Example Request:

curl "http://localhost:3000/api/files/search/context?query=important&vault=youtube"

Example Response:

{
  "success": true,
  "data": {
    "type": "message",
    "data": "Projects/Notes.md:\n- This is an **important** note about...",
  }
}

POST /api/files/search/open

Open search results in the Obsidian search panel.

CLI Command: obsidian search:open

Request Body:

ParameterTypeRequiredDescription
querystringYesSearch query to display
vaultstringNoTarget vault name

Example Request:

curl -X POST "http://localhost:3000/api/files/search/open" \
  -H "Content-Type: application/json" \
  -d '{"query": "project", "vault": "youtube"}'

Example Response:

{
  "success": true,
  "data": "Opening search for: project"
}

Search Operators

The Obsidian search supports various operators:

OperatorExampleDescription
-tag:-tag:doneExclude tag
file:file:\"*.md\"Search in specific file
path:path:ProjectsSearch in path
line:line:5Match specific line
"quotes""exact phrase"Exact phrase match

Example with operators:

curl "http://localhost:3000/api/files/search?query=project%20tag:daily&vault=youtube"

Error Handling

Empty Query:

{
  "success": false,
  "error": "Query parameter is required"
}

No Results:

{
  "success": true,
  "data": {
    "type": "list",
    "data": []
  }
}

Notes

  • Search is case-insensitive by default
  • Supports full Obsidian search syntax
  • Results are relative file paths from vault root

On this page