#
tokens: 32932/50000 8/8 files
lines: on (toggle) GitHub
raw markdown copy reset
# Directory Structure

```
├── .gitignore
├── LICENSE
├── openapi.yaml
├── pyproject.toml
├── README.md
├── src
│   └── mcp_obsidian
│       ├── __init__.py
│       ├── obsidian.py
│       ├── server.py
│       └── tools.py
└── uv.lock
```

# Files

--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------

```
 1 | # Python-generated files
 2 | __pycache__/
 3 | *.py[oc]
 4 | build/
 5 | dist/
 6 | wheels/
 7 | *.egg-info
 8 | 
 9 | # Virtual environments
10 | .venv
11 | .env
12 | 
```

--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------

```markdown
  1 | # MCP server for Obsidian
  2 | 
  3 | MCP server to interact with Obsidian via the Local REST API community plugin.
  4 | 
  5 | <a href="https://glama.ai/mcp/servers/3wko1bhuek"><img width="380" height="200" src="https://glama.ai/mcp/servers/3wko1bhuek/badge" alt="server for Obsidian MCP server" /></a>
  6 | 
  7 | ## Components
  8 | 
  9 | ### Tools
 10 | 
 11 | The server implements multiple tools to interact with Obsidian:
 12 | 
 13 | - list_files_in_vault: Lists all files and directories in the root directory of your Obsidian vault
 14 | - list_files_in_dir: Lists all files and directories in a specific Obsidian directory
 15 | - get_file_contents: Return the content of a single file in your vault.
 16 | - search: Search for documents matching a specified text query across all files in the vault
 17 | - patch_content: Insert content into an existing note relative to a heading, block reference, or frontmatter field.
 18 | - append_content: Append content to a new or existing file in the vault.
 19 | - delete_file: Delete a file or directory from your vault.
 20 | 
 21 | ### Example prompts
 22 | 
 23 | Its good to first instruct Claude to use Obsidian. Then it will always call the tool.
 24 | 
 25 | The use prompts like this:
 26 | - Get the contents of the last architecture call note and summarize them
 27 | - Search for all files where Azure CosmosDb is mentioned and quickly explain to me the context in which it is mentioned
 28 | - Summarize the last meeting notes and put them into a new note 'summary meeting.md'. Add an introduction so that I can send it via email.
 29 | 
 30 | ## Configuration
 31 | 
 32 | ### Obsidian REST API Key
 33 | 
 34 | There are two ways to configure the environment with the Obsidian REST API Key. 
 35 | 
 36 | 1. Add to server config (preferred)
 37 | 
 38 | ```json
 39 | {
 40 |   "mcp-obsidian": {
 41 |     "command": "uvx",
 42 |     "args": [
 43 |       "mcp-obsidian"
 44 |     ],
 45 |     "env": {
 46 |       "OBSIDIAN_API_KEY": "<your_api_key_here>",
 47 |       "OBSIDIAN_HOST": "<your_obsidian_host>",
 48 |       "OBSIDIAN_PORT": "<your_obsidian_port>"
 49 |     }
 50 |   }
 51 | }
 52 | ```
 53 | Sometimes Claude has issues detecting the location of uv / uvx. You can use `which uvx` to find and paste the full path in above config in such cases.
 54 | 
 55 | 2. Create a `.env` file in the working directory with the following required variables:
 56 | 
 57 | ```
 58 | OBSIDIAN_API_KEY=your_api_key_here
 59 | OBSIDIAN_HOST=your_obsidian_host
 60 | OBSIDIAN_PORT=your_obsidian_port
 61 | ```
 62 | 
 63 | Note:
 64 | - You can find the API key in the Obsidian plugin config
 65 | - Default port is 27124 if not specified
 66 | - Default host is 127.0.0.1 if not specified
 67 | 
 68 | ## Quickstart
 69 | 
 70 | ### Install
 71 | 
 72 | #### Obsidian REST API
 73 | 
 74 | You need the Obsidian REST API community plugin running: https://github.com/coddingtonbear/obsidian-local-rest-api
 75 | 
 76 | Install and enable it in the settings and copy the api key.
 77 | 
 78 | #### Claude Desktop
 79 | 
 80 | On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`
 81 | 
 82 | On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
 83 | 
 84 | <details>
 85 |   <summary>Development/Unpublished Servers Configuration</summary>
 86 |   
 87 | ```json
 88 | {
 89 |   "mcpServers": {
 90 |     "mcp-obsidian": {
 91 |       "command": "uv",
 92 |       "args": [
 93 |         "--directory",
 94 |         "<dir_to>/mcp-obsidian",
 95 |         "run",
 96 |         "mcp-obsidian"
 97 |       ],
 98 |       "env": {
 99 |         "OBSIDIAN_API_KEY": "<your_api_key_here>",
100 |         "OBSIDIAN_HOST": "<your_obsidian_host>",
101 |         "OBSIDIAN_PORT": "<your_obsidian_port>"
102 |       }
103 |     }
104 |   }
105 | }
106 | ```
107 | </details>
108 | 
109 | <details>
110 |   <summary>Published Servers Configuration</summary>
111 |   
112 | ```json
113 | {
114 |   "mcpServers": {
115 |     "mcp-obsidian": {
116 |       "command": "uvx",
117 |       "args": [
118 |         "mcp-obsidian"
119 |       ],
120 |       "env": {
121 |         "OBSIDIAN_API_KEY": "<YOUR_OBSIDIAN_API_KEY>",
122 |         "OBSIDIAN_HOST": "<your_obsidian_host>",
123 |         "OBSIDIAN_PORT": "<your_obsidian_port>"
124 |       }
125 |     }
126 |   }
127 | }
128 | ```
129 | </details>
130 | 
131 | ## Development
132 | 
133 | ### Building
134 | 
135 | To prepare the package for distribution:
136 | 
137 | 1. Sync dependencies and update lockfile:
138 | ```bash
139 | uv sync
140 | ```
141 | 
142 | ### Debugging
143 | 
144 | Since MCP servers run over stdio, debugging can be challenging. For the best debugging
145 | experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
146 | 
147 | You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command:
148 | 
149 | ```bash
150 | npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-obsidian run mcp-obsidian
151 | ```
152 | 
153 | Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
154 | 
155 | You can also watch the server logs with this command:
156 | 
157 | ```bash
158 | tail -n 20 -f ~/Library/Logs/Claude/mcp-server-mcp-obsidian.log
159 | ```
160 | 
```

--------------------------------------------------------------------------------
/src/mcp_obsidian/__init__.py:
--------------------------------------------------------------------------------

```python
1 | from . import server
2 | import asyncio
3 | 
4 | def main():
5 |     """Main entry point for the package."""
6 |     asyncio.run(server.main())
7 | 
8 | # Optionally expose other important items at package level
9 | __all__ = ['main', 'server']
```

--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------

```toml
 1 | [project]
 2 | name = "mcp-obsidian"
 3 | version = "0.2.1"
 4 | description = "MCP server to work with Obsidian via the remote REST plugin"
 5 | readme = "README.md"
 6 | requires-python = ">=3.11"
 7 | dependencies = [
 8 |  "mcp>=1.1.0",
 9 |  "python-dotenv>=1.0.1",
10 |  "requests>=2.32.3",
11 | ]
12 | [[project.authors]]
13 | name = "Markus Pfundstein"
14 | email = "[email protected]"
15 | 
16 | [build-system]
17 | requires = [ "hatchling",]
18 | build-backend = "hatchling.build"
19 | 
20 | [dependency-groups]
21 | dev = [
22 |     "pyright>=1.1.389",
23 | ]
24 | 
25 | [project.scripts]
26 | mcp-obsidian = "mcp_obsidian:main"
27 | 
```

--------------------------------------------------------------------------------
/src/mcp_obsidian/server.py:
--------------------------------------------------------------------------------

```python
 1 | import json
 2 | import logging
 3 | from collections.abc import Sequence
 4 | from functools import lru_cache
 5 | from typing import Any
 6 | import os
 7 | from dotenv import load_dotenv
 8 | from mcp.server import Server
 9 | from mcp.types import (
10 |     Tool,
11 |     TextContent,
12 |     ImageContent,
13 |     EmbeddedResource,
14 | )
15 | 
16 | load_dotenv()
17 | 
18 | from . import tools
19 | 
20 | # Load environment variables
21 | 
22 | # Configure logging
23 | logging.basicConfig(level=logging.INFO)
24 | logger = logging.getLogger("mcp-obsidian")
25 | 
26 | api_key = os.getenv("OBSIDIAN_API_KEY")
27 | if not api_key:
28 |     raise ValueError(f"OBSIDIAN_API_KEY environment variable required. Working directory: {os.getcwd()}")
29 | 
30 | app = Server("mcp-obsidian")
31 | 
32 | tool_handlers = {}
33 | def add_tool_handler(tool_class: tools.ToolHandler):
34 |     global tool_handlers
35 | 
36 |     tool_handlers[tool_class.name] = tool_class
37 | 
38 | def get_tool_handler(name: str) -> tools.ToolHandler | None:
39 |     if name not in tool_handlers:
40 |         return None
41 |     
42 |     return tool_handlers[name]
43 | 
44 | add_tool_handler(tools.ListFilesInDirToolHandler())
45 | add_tool_handler(tools.ListFilesInVaultToolHandler())
46 | add_tool_handler(tools.GetFileContentsToolHandler())
47 | add_tool_handler(tools.SearchToolHandler())
48 | add_tool_handler(tools.PatchContentToolHandler())
49 | add_tool_handler(tools.AppendContentToolHandler())
50 | add_tool_handler(tools.PutContentToolHandler())
51 | add_tool_handler(tools.DeleteFileToolHandler())
52 | add_tool_handler(tools.ComplexSearchToolHandler())
53 | add_tool_handler(tools.BatchGetFileContentsToolHandler())
54 | add_tool_handler(tools.PeriodicNotesToolHandler())
55 | add_tool_handler(tools.RecentPeriodicNotesToolHandler())
56 | add_tool_handler(tools.RecentChangesToolHandler())
57 | 
58 | @app.list_tools()
59 | async def list_tools() -> list[Tool]:
60 |     """List available tools."""
61 | 
62 |     return [th.get_tool_description() for th in tool_handlers.values()]
63 | 
64 | @app.call_tool()
65 | async def call_tool(name: str, arguments: Any) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
66 |     """Handle tool calls for command line run."""
67 |     
68 |     if not isinstance(arguments, dict):
69 |         raise RuntimeError("arguments must be dictionary")
70 | 
71 | 
72 |     tool_handler = get_tool_handler(name)
73 |     if not tool_handler:
74 |         raise ValueError(f"Unknown tool: {name}")
75 | 
76 |     try:
77 |         return tool_handler.run_tool(arguments)
78 |     except Exception as e:
79 |         logger.error(str(e))
80 |         raise RuntimeError(f"Caught Exception. Error: {str(e)}")
81 | 
82 | 
83 | async def main():
84 | 
85 |     # Import here to avoid issues with event loops
86 |     from mcp.server.stdio import stdio_server
87 | 
88 |     async with stdio_server() as (read_stream, write_stream):
89 |         await app.run(
90 |             read_stream,
91 |             write_stream,
92 |             app.create_initialization_options()
93 |         )
94 | 
```

--------------------------------------------------------------------------------
/src/mcp_obsidian/obsidian.py:
--------------------------------------------------------------------------------

```python
  1 | import requests
  2 | import urllib.parse
  3 | import os
  4 | from typing import Any
  5 | 
  6 | class Obsidian():
  7 |     def __init__(
  8 |             self, 
  9 |             api_key: str,
 10 |             protocol: str = os.getenv('OBSIDIAN_PROTOCOL', 'https').lower(),
 11 |             host: str = str(os.getenv('OBSIDIAN_HOST', '127.0.0.1')),
 12 |             port: int = int(os.getenv('OBSIDIAN_PORT', '27124')),
 13 |             verify_ssl: bool = False,
 14 |         ):
 15 |         self.api_key = api_key
 16 |         
 17 |         if protocol == 'http':
 18 |             self.protocol = 'http'
 19 |         else:
 20 |             self.protocol = 'https' # Default to https for any other value, including 'https'
 21 | 
 22 |         self.host = host
 23 |         self.port = port
 24 |         self.verify_ssl = verify_ssl
 25 |         self.timeout = (3, 6)
 26 | 
 27 |     def get_base_url(self) -> str:
 28 |         return f'{self.protocol}://{self.host}:{self.port}'
 29 |     
 30 |     def _get_headers(self) -> dict:
 31 |         headers = {
 32 |             'Authorization': f'Bearer {self.api_key}'
 33 |         }
 34 |         return headers
 35 | 
 36 |     def _safe_call(self, f) -> Any:
 37 |         try:
 38 |             return f()
 39 |         except requests.HTTPError as e:
 40 |             error_data = e.response.json() if e.response.content else {}
 41 |             code = error_data.get('errorCode', -1) 
 42 |             message = error_data.get('message', '<unknown>')
 43 |             raise Exception(f"Error {code}: {message}")
 44 |         except requests.exceptions.RequestException as e:
 45 |             raise Exception(f"Request failed: {str(e)}")
 46 | 
 47 |     def list_files_in_vault(self) -> Any:
 48 |         url = f"{self.get_base_url()}/vault/"
 49 |         
 50 |         def call_fn():
 51 |             response = requests.get(url, headers=self._get_headers(), verify=self.verify_ssl, timeout=self.timeout)
 52 |             response.raise_for_status()
 53 |             
 54 |             return response.json()['files']
 55 | 
 56 |         return self._safe_call(call_fn)
 57 | 
 58 |         
 59 |     def list_files_in_dir(self, dirpath: str) -> Any:
 60 |         url = f"{self.get_base_url()}/vault/{dirpath}/"
 61 |         
 62 |         def call_fn():
 63 |             response = requests.get(url, headers=self._get_headers(), verify=self.verify_ssl, timeout=self.timeout)
 64 |             response.raise_for_status()
 65 |             
 66 |             return response.json()['files']
 67 | 
 68 |         return self._safe_call(call_fn)
 69 | 
 70 |     def get_file_contents(self, filepath: str) -> Any:
 71 |         url = f"{self.get_base_url()}/vault/{filepath}"
 72 |     
 73 |         def call_fn():
 74 |             response = requests.get(url, headers=self._get_headers(), verify=self.verify_ssl, timeout=self.timeout)
 75 |             response.raise_for_status()
 76 |             
 77 |             return response.text
 78 | 
 79 |         return self._safe_call(call_fn)
 80 |     
 81 |     def get_batch_file_contents(self, filepaths: list[str]) -> str:
 82 |         """Get contents of multiple files and concatenate them with headers.
 83 |         
 84 |         Args:
 85 |             filepaths: List of file paths to read
 86 |             
 87 |         Returns:
 88 |             String containing all file contents with headers
 89 |         """
 90 |         result = []
 91 |         
 92 |         for filepath in filepaths:
 93 |             try:
 94 |                 content = self.get_file_contents(filepath)
 95 |                 result.append(f"# {filepath}\n\n{content}\n\n---\n\n")
 96 |             except Exception as e:
 97 |                 # Add error message but continue processing other files
 98 |                 result.append(f"# {filepath}\n\nError reading file: {str(e)}\n\n---\n\n")
 99 |                 
100 |         return "".join(result)
101 | 
102 |     def search(self, query: str, context_length: int = 100) -> Any:
103 |         url = f"{self.get_base_url()}/search/simple/"
104 |         params = {
105 |             'query': query,
106 |             'contextLength': context_length
107 |         }
108 |         
109 |         def call_fn():
110 |             response = requests.post(url, headers=self._get_headers(), params=params, verify=self.verify_ssl, timeout=self.timeout)
111 |             response.raise_for_status()
112 |             return response.json()
113 | 
114 |         return self._safe_call(call_fn)
115 |     
116 |     def append_content(self, filepath: str, content: str) -> Any:
117 |         url = f"{self.get_base_url()}/vault/{filepath}"
118 |         
119 |         def call_fn():
120 |             response = requests.post(
121 |                 url, 
122 |                 headers=self._get_headers() | {'Content-Type': 'text/markdown'}, 
123 |                 data=content,
124 |                 verify=self.verify_ssl,
125 |                 timeout=self.timeout
126 |             )
127 |             response.raise_for_status()
128 |             return None
129 | 
130 |         return self._safe_call(call_fn)
131 |     
132 |     def patch_content(self, filepath: str, operation: str, target_type: str, target: str, content: str) -> Any:
133 |         url = f"{self.get_base_url()}/vault/{filepath}"
134 |         
135 |         headers = self._get_headers() | {
136 |             'Content-Type': 'text/markdown',
137 |             'Operation': operation,
138 |             'Target-Type': target_type,
139 |             'Target': urllib.parse.quote(target)
140 |         }
141 |         
142 |         def call_fn():
143 |             response = requests.patch(url, headers=headers, data=content, verify=self.verify_ssl, timeout=self.timeout)
144 |             response.raise_for_status()
145 |             return None
146 | 
147 |         return self._safe_call(call_fn)
148 | 
149 |     def put_content(self, filepath: str, content: str) -> Any:
150 |         url = f"{self.get_base_url()}/vault/{filepath}"
151 |         
152 |         def call_fn():
153 |             response = requests.put(
154 |                 url, 
155 |                 headers=self._get_headers() | {'Content-Type': 'text/markdown'}, 
156 |                 data=content,
157 |                 verify=self.verify_ssl,
158 |                 timeout=self.timeout
159 |             )
160 |             response.raise_for_status()
161 |             return None
162 | 
163 |         return self._safe_call(call_fn)
164 |     
165 |     def delete_file(self, filepath: str) -> Any:
166 |         """Delete a file or directory from the vault.
167 |         
168 |         Args:
169 |             filepath: Path to the file to delete (relative to vault root)
170 |             
171 |         Returns:
172 |             None on success
173 |         """
174 |         url = f"{self.get_base_url()}/vault/{filepath}"
175 |         
176 |         def call_fn():
177 |             response = requests.delete(url, headers=self._get_headers(), verify=self.verify_ssl, timeout=self.timeout)
178 |             response.raise_for_status()
179 |             return None
180 |             
181 |         return self._safe_call(call_fn)
182 |     
183 |     def search_json(self, query: dict) -> Any:
184 |         url = f"{self.get_base_url()}/search/"
185 |         
186 |         headers = self._get_headers() | {
187 |             'Content-Type': 'application/vnd.olrapi.jsonlogic+json'
188 |         }
189 |         
190 |         def call_fn():
191 |             response = requests.post(url, headers=headers, json=query, verify=self.verify_ssl, timeout=self.timeout)
192 |             response.raise_for_status()
193 |             return response.json()
194 | 
195 |         return self._safe_call(call_fn)
196 |     
197 |     def get_periodic_note(self, period: str, type: str = "content") -> Any:
198 |         """Get current periodic note for the specified period.
199 |         
200 |         Args:
201 |             period: The period type (daily, weekly, monthly, quarterly, yearly)
202 |             type: Type of the data to get ('content' or 'metadata'). 
203 |                 'content' returns just the content in Markdown format. 
204 |                 'metadata' includes note metadata (including paths, tags, etc.) and the content.. 
205 |             
206 |         Returns:
207 |             Content of the periodic note
208 |         """
209 |         url = f"{self.get_base_url()}/periodic/{period}/"
210 |         
211 |         def call_fn():
212 |             headers = self._get_headers()
213 |             if type == "metadata":
214 |                 headers['Accept'] = 'application/vnd.olrapi.note+json'
215 |             response = requests.get(url, headers=headers, verify=self.verify_ssl, timeout=self.timeout)
216 |             response.raise_for_status()
217 |             
218 |             return response.text
219 | 
220 |         return self._safe_call(call_fn)
221 |     
222 |     def get_recent_periodic_notes(self, period: str, limit: int = 5, include_content: bool = False) -> Any:
223 |         """Get most recent periodic notes for the specified period type.
224 |         
225 |         Args:
226 |             period: The period type (daily, weekly, monthly, quarterly, yearly)
227 |             limit: Maximum number of notes to return (default: 5)
228 |             include_content: Whether to include note content (default: False)
229 |             
230 |         Returns:
231 |             List of recent periodic notes
232 |         """
233 |         url = f"{self.get_base_url()}/periodic/{period}/recent"
234 |         params = {
235 |             "limit": limit,
236 |             "includeContent": include_content
237 |         }
238 |         
239 |         def call_fn():
240 |             response = requests.get(
241 |                 url, 
242 |                 headers=self._get_headers(), 
243 |                 params=params,
244 |                 verify=self.verify_ssl, 
245 |                 timeout=self.timeout
246 |             )
247 |             response.raise_for_status()
248 |             
249 |             return response.json()
250 | 
251 |         return self._safe_call(call_fn)
252 |     
253 |     def get_recent_changes(self, limit: int = 10, days: int = 90) -> Any:
254 |         """Get recently modified files in the vault.
255 |         
256 |         Args:
257 |             limit: Maximum number of files to return (default: 10)
258 |             days: Only include files modified within this many days (default: 90)
259 |             
260 |         Returns:
261 |             List of recently modified files with metadata
262 |         """
263 |         # Build the DQL query
264 |         query_lines = [
265 |             "TABLE file.mtime",
266 |             f"WHERE file.mtime >= date(today) - dur({days} days)",
267 |             "SORT file.mtime DESC",
268 |             f"LIMIT {limit}"
269 |         ]
270 |         
271 |         # Join with proper DQL line breaks
272 |         dql_query = "\n".join(query_lines)
273 |         
274 |         # Make the request to search endpoint
275 |         url = f"{self.get_base_url()}/search/"
276 |         headers = self._get_headers() | {
277 |             'Content-Type': 'application/vnd.olrapi.dataview.dql+txt'
278 |         }
279 |         
280 |         def call_fn():
281 |             response = requests.post(
282 |                 url,
283 |                 headers=headers,
284 |                 data=dql_query.encode('utf-8'),
285 |                 verify=self.verify_ssl,
286 |                 timeout=self.timeout
287 |             )
288 |             response.raise_for_status()
289 |             return response.json()
290 | 
291 |         return self._safe_call(call_fn)
292 | 
```

--------------------------------------------------------------------------------
/src/mcp_obsidian/tools.py:
--------------------------------------------------------------------------------

```python
  1 | from collections.abc import Sequence
  2 | from mcp.types import (
  3 |     Tool,
  4 |     TextContent,
  5 |     ImageContent,
  6 |     EmbeddedResource,
  7 | )
  8 | import json
  9 | import os
 10 | from . import obsidian
 11 | 
 12 | api_key = os.getenv("OBSIDIAN_API_KEY", "")
 13 | obsidian_host = os.getenv("OBSIDIAN_HOST", "127.0.0.1")
 14 | 
 15 | if api_key == "":
 16 |     raise ValueError(f"OBSIDIAN_API_KEY environment variable required. Working directory: {os.getcwd()}")
 17 | 
 18 | TOOL_LIST_FILES_IN_VAULT = "obsidian_list_files_in_vault"
 19 | TOOL_LIST_FILES_IN_DIR = "obsidian_list_files_in_dir"
 20 | 
 21 | class ToolHandler():
 22 |     def __init__(self, tool_name: str):
 23 |         self.name = tool_name
 24 | 
 25 |     def get_tool_description(self) -> Tool:
 26 |         raise NotImplementedError()
 27 | 
 28 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
 29 |         raise NotImplementedError()
 30 |     
 31 | class ListFilesInVaultToolHandler(ToolHandler):
 32 |     def __init__(self):
 33 |         super().__init__(TOOL_LIST_FILES_IN_VAULT)
 34 | 
 35 |     def get_tool_description(self):
 36 |         return Tool(
 37 |             name=self.name,
 38 |             description="Lists all files and directories in the root directory of your Obsidian vault.",
 39 |             inputSchema={
 40 |                 "type": "object",
 41 |                 "properties": {},
 42 |                 "required": []
 43 |             },
 44 |         )
 45 | 
 46 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
 47 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
 48 | 
 49 |         files = api.list_files_in_vault()
 50 | 
 51 |         return [
 52 |             TextContent(
 53 |                 type="text",
 54 |                 text=json.dumps(files, indent=2)
 55 |             )
 56 |         ]
 57 |     
 58 | class ListFilesInDirToolHandler(ToolHandler):
 59 |     def __init__(self):
 60 |         super().__init__(TOOL_LIST_FILES_IN_DIR)
 61 | 
 62 |     def get_tool_description(self):
 63 |         return Tool(
 64 |             name=self.name,
 65 |             description="Lists all files and directories that exist in a specific Obsidian directory.",
 66 |             inputSchema={
 67 |                 "type": "object",
 68 |                 "properties": {
 69 |                     "dirpath": {
 70 |                         "type": "string",
 71 |                         "description": "Path to list files from (relative to your vault root). Note that empty directories will not be returned."
 72 |                     },
 73 |                 },
 74 |                 "required": ["dirpath"]
 75 |             }
 76 |         )
 77 | 
 78 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
 79 | 
 80 |         if "dirpath" not in args:
 81 |             raise RuntimeError("dirpath argument missing in arguments")
 82 | 
 83 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
 84 | 
 85 |         files = api.list_files_in_dir(args["dirpath"])
 86 | 
 87 |         return [
 88 |             TextContent(
 89 |                 type="text",
 90 |                 text=json.dumps(files, indent=2)
 91 |             )
 92 |         ]
 93 |     
 94 | class GetFileContentsToolHandler(ToolHandler):
 95 |     def __init__(self):
 96 |         super().__init__("obsidian_get_file_contents")
 97 | 
 98 |     def get_tool_description(self):
 99 |         return Tool(
100 |             name=self.name,
101 |             description="Return the content of a single file in your vault.",
102 |             inputSchema={
103 |                 "type": "object",
104 |                 "properties": {
105 |                     "filepath": {
106 |                         "type": "string",
107 |                         "description": "Path to the relevant file (relative to your vault root).",
108 |                         "format": "path"
109 |                     },
110 |                 },
111 |                 "required": ["filepath"]
112 |             }
113 |         )
114 | 
115 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
116 |         if "filepath" not in args:
117 |             raise RuntimeError("filepath argument missing in arguments")
118 | 
119 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
120 | 
121 |         content = api.get_file_contents(args["filepath"])
122 | 
123 |         return [
124 |             TextContent(
125 |                 type="text",
126 |                 text=json.dumps(content, indent=2)
127 |             )
128 |         ]
129 |     
130 | class SearchToolHandler(ToolHandler):
131 |     def __init__(self):
132 |         super().__init__("obsidian_simple_search")
133 | 
134 |     def get_tool_description(self):
135 |         return Tool(
136 |             name=self.name,
137 |             description="""Simple search for documents matching a specified text query across all files in the vault. 
138 |             Use this tool when you want to do a simple text search""",
139 |             inputSchema={
140 |                 "type": "object",
141 |                 "properties": {
142 |                     "query": {
143 |                         "type": "string",
144 |                         "description": "Text to a simple search for in the vault."
145 |                     },
146 |                     "context_length": {
147 |                         "type": "integer",
148 |                         "description": "How much context to return around the matching string (default: 100)",
149 |                         "default": 100
150 |                     }
151 |                 },
152 |                 "required": ["query"]
153 |             }
154 |         )
155 | 
156 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
157 |         if "query" not in args:
158 |             raise RuntimeError("query argument missing in arguments")
159 | 
160 |         context_length = args.get("context_length", 100)
161 |         
162 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
163 |         results = api.search(args["query"], context_length)
164 |         
165 |         formatted_results = []
166 |         for result in results:
167 |             formatted_matches = []
168 |             for match in result.get('matches', []):
169 |                 context = match.get('context', '')
170 |                 match_pos = match.get('match', {})
171 |                 start = match_pos.get('start', 0)
172 |                 end = match_pos.get('end', 0)
173 |                 
174 |                 formatted_matches.append({
175 |                     'context': context,
176 |                     'match_position': {'start': start, 'end': end}
177 |                 })
178 |                 
179 |             formatted_results.append({
180 |                 'filename': result.get('filename', ''),
181 |                 'score': result.get('score', 0),
182 |                 'matches': formatted_matches
183 |             })
184 | 
185 |         return [
186 |             TextContent(
187 |                 type="text",
188 |                 text=json.dumps(formatted_results, indent=2)
189 |             )
190 |         ]
191 |     
192 | class AppendContentToolHandler(ToolHandler):
193 |    def __init__(self):
194 |        super().__init__("obsidian_append_content")
195 | 
196 |    def get_tool_description(self):
197 |        return Tool(
198 |            name=self.name,
199 |            description="Append content to a new or existing file in the vault.",
200 |            inputSchema={
201 |                "type": "object",
202 |                "properties": {
203 |                    "filepath": {
204 |                        "type": "string",
205 |                        "description": "Path to the file (relative to vault root)",
206 |                        "format": "path"
207 |                    },
208 |                    "content": {
209 |                        "type": "string",
210 |                        "description": "Content to append to the file"
211 |                    }
212 |                },
213 |                "required": ["filepath", "content"]
214 |            }
215 |        )
216 | 
217 |    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
218 |        if "filepath" not in args or "content" not in args:
219 |            raise RuntimeError("filepath and content arguments required")
220 | 
221 |        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
222 |        api.append_content(args.get("filepath", ""), args["content"])
223 | 
224 |        return [
225 |            TextContent(
226 |                type="text",
227 |                text=f"Successfully appended content to {args['filepath']}"
228 |            )
229 |        ]
230 |    
231 | class PatchContentToolHandler(ToolHandler):
232 |    def __init__(self):
233 |        super().__init__("obsidian_patch_content")
234 | 
235 |    def get_tool_description(self):
236 |        return Tool(
237 |            name=self.name,
238 |            description="Insert content into an existing note relative to a heading, block reference, or frontmatter field.",
239 |            inputSchema={
240 |                "type": "object",
241 |                "properties": {
242 |                    "filepath": {
243 |                        "type": "string",
244 |                        "description": "Path to the file (relative to vault root)",
245 |                        "format": "path"
246 |                    },
247 |                    "operation": {
248 |                        "type": "string",
249 |                        "description": "Operation to perform (append, prepend, or replace)",
250 |                        "enum": ["append", "prepend", "replace"]
251 |                    },
252 |                    "target_type": {
253 |                        "type": "string",
254 |                        "description": "Type of target to patch",
255 |                        "enum": ["heading", "block", "frontmatter"]
256 |                    },
257 |                    "target": {
258 |                        "type": "string", 
259 |                        "description": "Target identifier (heading path, block reference, or frontmatter field)"
260 |                    },
261 |                    "content": {
262 |                        "type": "string",
263 |                        "description": "Content to insert"
264 |                    }
265 |                },
266 |                "required": ["filepath", "operation", "target_type", "target", "content"]
267 |            }
268 |        )
269 | 
270 |    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
271 |        if not all(k in args for k in ["filepath", "operation", "target_type", "target", "content"]):
272 |            raise RuntimeError("filepath, operation, target_type, target and content arguments required")
273 | 
274 |        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
275 |        api.patch_content(
276 |            args.get("filepath", ""),
277 |            args.get("operation", ""),
278 |            args.get("target_type", ""),
279 |            args.get("target", ""),
280 |            args.get("content", "")
281 |        )
282 | 
283 |        return [
284 |            TextContent(
285 |                type="text",
286 |                text=f"Successfully patched content in {args['filepath']}"
287 |            )
288 |        ]
289 |        
290 | class PutContentToolHandler(ToolHandler):
291 |    def __init__(self):
292 |        super().__init__("obsidian_put_content")
293 | 
294 |    def get_tool_description(self):
295 |        return Tool(
296 |            name=self.name,
297 |            description="Create a new file in your vault or update the content of an existing one in your vault.",
298 |            inputSchema={
299 |                "type": "object",
300 |                "properties": {
301 |                    "filepath": {
302 |                        "type": "string",
303 |                        "description": "Path to the relevant file (relative to your vault root)",
304 |                        "format": "path"
305 |                    },
306 |                    "content": {
307 |                        "type": "string",
308 |                        "description": "Content of the file you would like to upload"
309 |                    }
310 |                },
311 |                "required": ["filepath", "content"]
312 |            }
313 |        )
314 | 
315 |    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
316 |        if "filepath" not in args or "content" not in args:
317 |            raise RuntimeError("filepath and content arguments required")
318 | 
319 |        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
320 |        api.put_content(args.get("filepath", ""), args["content"])
321 | 
322 |        return [
323 |            TextContent(
324 |                type="text",
325 |                text=f"Successfully uploaded content to {args['filepath']}"
326 |            )
327 |        ]
328 |    
329 | 
330 | class DeleteFileToolHandler(ToolHandler):
331 |    def __init__(self):
332 |        super().__init__("obsidian_delete_file")
333 | 
334 |    def get_tool_description(self):
335 |        return Tool(
336 |            name=self.name,
337 |            description="Delete a file or directory from the vault.",
338 |            inputSchema={
339 |                "type": "object",
340 |                "properties": {
341 |                    "filepath": {
342 |                        "type": "string",
343 |                        "description": "Path to the file or directory to delete (relative to vault root)",
344 |                        "format": "path"
345 |                    },
346 |                    "confirm": {
347 |                        "type": "boolean",
348 |                        "description": "Confirmation to delete the file (must be true)",
349 |                        "default": False
350 |                    }
351 |                },
352 |                "required": ["filepath", "confirm"]
353 |            }
354 |        )
355 | 
356 |    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
357 |        if "filepath" not in args:
358 |            raise RuntimeError("filepath argument missing in arguments")
359 |        
360 |        if not args.get("confirm", False):
361 |            raise RuntimeError("confirm must be set to true to delete a file")
362 | 
363 |        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
364 |        api.delete_file(args["filepath"])
365 | 
366 |        return [
367 |            TextContent(
368 |                type="text",
369 |                text=f"Successfully deleted {args['filepath']}"
370 |            )
371 |        ]
372 |    
373 | class ComplexSearchToolHandler(ToolHandler):
374 |    def __init__(self):
375 |        super().__init__("obsidian_complex_search")
376 | 
377 |    def get_tool_description(self):
378 |        return Tool(
379 |            name=self.name,
380 |            description="""Complex search for documents using a JsonLogic query. 
381 |            Supports standard JsonLogic operators plus 'glob' and 'regexp' for pattern matching. Results must be non-falsy.
382 | 
383 |            Use this tool when you want to do a complex search, e.g. for all documents with certain tags etc.
384 |            ALWAYS follow query syntax in examples.
385 | 
386 |            Examples
387 |             1. Match all markdown files
388 |             {"glob": ["*.md", {"var": "path"}]}
389 | 
390 |             2. Match all markdown files with 1221 substring inside them
391 |             {
392 |               "and": [
393 |                 { "glob": ["*.md", {"var": "path"}] },
394 |                 { "regexp": [".*1221.*", {"var": "content"}] }
395 |               ]
396 |             }
397 | 
398 |             3. Match all markdown files in Work folder containing name Keaton
399 |             {
400 |               "and": [
401 |                 { "glob": ["*.md", {"var": "path"}] },
402 |                 { "regexp": [".*Work.*", {"var": "path"}] },
403 |                 { "regexp": ["Keaton", {"var": "content"}] }
404 |               ]
405 |             }
406 |            """,
407 |            inputSchema={
408 |                "type": "object",
409 |                "properties": {
410 |                    "query": {
411 |                        "type": "object",
412 |                        "description": "JsonLogic query object. ALWAYS follow query syntax in examples. \
413 |                             Example 1: {\"glob\": [\"*.md\", {\"var\": \"path\"}]} matches all markdown files \
414 |                             Example 2: {\"and\": [{\"glob\": [\"*.md\", {\"var\": \"path\"}]}, {\"regexp\": [\".*1221.*\", {\"var\": \"content\"}]}]} matches all markdown files with 1221 substring inside them \
415 |                             Example 3: {\"and\": [{\"glob\": [\"*.md\", {\"var\": \"path\"}]}, {\"regexp\": [\".*Work.*\", {\"var\": \"path\"}]}, {\"regexp\": [\"Keaton\", {\"var\": \"content\"}]}]} matches all markdown files in Work folder containing name Keaton \
416 |                         "
417 |                    }
418 |                },
419 |                "required": ["query"]
420 |            }
421 |        )
422 | 
423 |    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
424 |        if "query" not in args:
425 |            raise RuntimeError("query argument missing in arguments")
426 | 
427 |        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
428 |        results = api.search_json(args.get("query", ""))
429 | 
430 |        return [
431 |            TextContent(
432 |                type="text",
433 |                text=json.dumps(results, indent=2)
434 |            )
435 |        ]
436 | 
437 | class BatchGetFileContentsToolHandler(ToolHandler):
438 |     def __init__(self):
439 |         super().__init__("obsidian_batch_get_file_contents")
440 | 
441 |     def get_tool_description(self):
442 |         return Tool(
443 |             name=self.name,
444 |             description="Return the contents of multiple files in your vault, concatenated with headers.",
445 |             inputSchema={
446 |                 "type": "object",
447 |                 "properties": {
448 |                     "filepaths": {
449 |                         "type": "array",
450 |                         "items": {
451 |                             "type": "string",
452 |                             "description": "Path to a file (relative to your vault root)",
453 |                             "format": "path"
454 |                         },
455 |                         "description": "List of file paths to read"
456 |                     },
457 |                 },
458 |                 "required": ["filepaths"]
459 |             }
460 |         )
461 | 
462 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
463 |         if "filepaths" not in args:
464 |             raise RuntimeError("filepaths argument missing in arguments")
465 | 
466 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
467 |         content = api.get_batch_file_contents(args["filepaths"])
468 | 
469 |         return [
470 |             TextContent(
471 |                 type="text",
472 |                 text=content
473 |             )
474 |         ]
475 | 
476 | class PeriodicNotesToolHandler(ToolHandler):
477 |     def __init__(self):
478 |         super().__init__("obsidian_get_periodic_note")
479 | 
480 |     def get_tool_description(self):
481 |         return Tool(
482 |             name=self.name,
483 |             description="Get current periodic note for the specified period.",
484 |             inputSchema={
485 |                 "type": "object",
486 |                 "properties": {
487 |                     "period": {
488 |                         "type": "string",
489 |                         "description": "The period type (daily, weekly, monthly, quarterly, yearly)",
490 |                         "enum": ["daily", "weekly", "monthly", "quarterly", "yearly"]
491 |                     },
492 |                     "type": {
493 |                         "type": "string",
494 |                         "description": "The type of data to get ('content' or 'metadata'). 'content' returns just the content in Markdown format. 'metadata' includes note metadata (including paths, tags, etc.) and the content.",
495 |                         "default": "content",
496 |                         "enum": ["content", "metadata"]
497 |                     }
498 |                 },
499 |                 "required": ["period"]
500 |             }
501 |         )
502 | 
503 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
504 |         if "period" not in args:
505 |             raise RuntimeError("period argument missing in arguments")
506 | 
507 |         period = args["period"]
508 |         valid_periods = ["daily", "weekly", "monthly", "quarterly", "yearly"]
509 |         if period not in valid_periods:
510 |             raise RuntimeError(f"Invalid period: {period}. Must be one of: {', '.join(valid_periods)}")
511 |         
512 |         type = args["type"] if "type" in args else "content"
513 |         valid_types = ["content", "metadata"]
514 |         if type not in valid_types:
515 |             raise RuntimeError(f"Invalid type: {type}. Must be one of: {', '.join(valid_types)}")
516 | 
517 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
518 |         content = api.get_periodic_note(period,type)
519 | 
520 |         return [
521 |             TextContent(
522 |                 type="text",
523 |                 text=content
524 |             )
525 |         ]
526 |         
527 | class RecentPeriodicNotesToolHandler(ToolHandler):
528 |     def __init__(self):
529 |         super().__init__("obsidian_get_recent_periodic_notes")
530 | 
531 |     def get_tool_description(self):
532 |         return Tool(
533 |             name=self.name,
534 |             description="Get most recent periodic notes for the specified period type.",
535 |             inputSchema={
536 |                 "type": "object",
537 |                 "properties": {
538 |                     "period": {
539 |                         "type": "string",
540 |                         "description": "The period type (daily, weekly, monthly, quarterly, yearly)",
541 |                         "enum": ["daily", "weekly", "monthly", "quarterly", "yearly"]
542 |                     },
543 |                     "limit": {
544 |                         "type": "integer",
545 |                         "description": "Maximum number of notes to return (default: 5)",
546 |                         "default": 5,
547 |                         "minimum": 1,
548 |                         "maximum": 50
549 |                     },
550 |                     "include_content": {
551 |                         "type": "boolean",
552 |                         "description": "Whether to include note content (default: false)",
553 |                         "default": False
554 |                     }
555 |                 },
556 |                 "required": ["period"]
557 |             }
558 |         )
559 | 
560 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
561 |         if "period" not in args:
562 |             raise RuntimeError("period argument missing in arguments")
563 | 
564 |         period = args["period"]
565 |         valid_periods = ["daily", "weekly", "monthly", "quarterly", "yearly"]
566 |         if period not in valid_periods:
567 |             raise RuntimeError(f"Invalid period: {period}. Must be one of: {', '.join(valid_periods)}")
568 | 
569 |         limit = args.get("limit", 5)
570 |         if not isinstance(limit, int) or limit < 1:
571 |             raise RuntimeError(f"Invalid limit: {limit}. Must be a positive integer")
572 |             
573 |         include_content = args.get("include_content", False)
574 |         if not isinstance(include_content, bool):
575 |             raise RuntimeError(f"Invalid include_content: {include_content}. Must be a boolean")
576 | 
577 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
578 |         results = api.get_recent_periodic_notes(period, limit, include_content)
579 | 
580 |         return [
581 |             TextContent(
582 |                 type="text",
583 |                 text=json.dumps(results, indent=2)
584 |             )
585 |         ]
586 |         
587 | class RecentChangesToolHandler(ToolHandler):
588 |     def __init__(self):
589 |         super().__init__("obsidian_get_recent_changes")
590 | 
591 |     def get_tool_description(self):
592 |         return Tool(
593 |             name=self.name,
594 |             description="Get recently modified files in the vault.",
595 |             inputSchema={
596 |                 "type": "object",
597 |                 "properties": {
598 |                     "limit": {
599 |                         "type": "integer",
600 |                         "description": "Maximum number of files to return (default: 10)",
601 |                         "default": 10,
602 |                         "minimum": 1,
603 |                         "maximum": 100
604 |                     },
605 |                     "days": {
606 |                         "type": "integer",
607 |                         "description": "Only include files modified within this many days (default: 90)",
608 |                         "minimum": 1,
609 |                         "default": 90
610 |                     }
611 |                 }
612 |             }
613 |         )
614 | 
615 |     def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
616 |         limit = args.get("limit", 10)
617 |         if not isinstance(limit, int) or limit < 1:
618 |             raise RuntimeError(f"Invalid limit: {limit}. Must be a positive integer")
619 |             
620 |         days = args.get("days", 90)
621 |         if not isinstance(days, int) or days < 1:
622 |             raise RuntimeError(f"Invalid days: {days}. Must be a positive integer")
623 | 
624 |         api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
625 |         results = api.get_recent_changes(limit, days)
626 | 
627 |         return [
628 |             TextContent(
629 |                 type="text",
630 |                 text=json.dumps(results, indent=2)
631 |             )
632 |         ]
633 | 
```

--------------------------------------------------------------------------------
/openapi.yaml:
--------------------------------------------------------------------------------

```yaml
   1 | components:
   2 |   schemas:
   3 |     Error:
   4 |       properties:
   5 |         errorCode:
   6 |           description: |
   7 |             A 5-digit error code uniquely identifying this particular type of error.
   8 |           example: 40149
   9 |           type: "number"
  10 |         message:
  11 |           description: "Message describing the error."
  12 |           example: "A brief description of the error."
  13 |           type: "string"
  14 |       type: "object"
  15 |     NoteJson:
  16 |       properties:
  17 |         content:
  18 |           type: "string"
  19 |         frontmatter:
  20 |           type: "object"
  21 |         path:
  22 |           type: "string"
  23 |         stat:
  24 |           properties:
  25 |             ctime:
  26 |               type: "number"
  27 |             mtime:
  28 |               type: "number"
  29 |             size:
  30 |               type: "number"
  31 |           required:
  32 |             - "ctime"
  33 |             - "mtime"
  34 |             - "size"
  35 |           type: "object"
  36 |         tags:
  37 |           items:
  38 |             type: "string"
  39 |           type: "array"
  40 |       required:
  41 |         - "tags"
  42 |         - "frontmatter"
  43 |         - "stat"
  44 |         - "path"
  45 |         - "content"
  46 |       type: "object"
  47 |   securitySchemes:
  48 |     apiKeyAuth:
  49 |       description: |
  50 |         Find your API Key in your Obsidian settings
  51 |         in the "Local REST API" section under "Plugins".
  52 |       scheme: "bearer"
  53 |       type: "http"
  54 | info:
  55 |   description: |
  56 |     You can use this interface for trying out your Local REST API in Obsidian.
  57 |     
  58 |     Before trying the below tools, you will want to make sure you press the "Authorize" button below and provide the API Key you are shown when you open the "Local REST API" section of your Obsidian settings.  All requests to the API require a valid API Key; so you won't get very far without doing that.
  59 |     
  60 |     When using this tool you may see browser security warnings due to your browser not trusting the self-signed certificate the plugin will generate on its first run.  If you do, you can make those errors disappear by adding the certificate as a "Trusted Certificate" in your browser or operating system's settings.
  61 |   title: "Local REST API for Obsidian"
  62 |   version: "1.0"
  63 | openapi: "3.0.2"
  64 | paths:
  65 |   /:
  66 |     get:
  67 |       description: |
  68 |         Returns basic details about the server as well as your authentication status.
  69 |         
  70 |         This is the only API request that does *not* require authentication.
  71 |       responses:
  72 |         "200":
  73 |           content:
  74 |             application/json:
  75 |               schema:
  76 |                 properties:
  77 |                   authenticated:
  78 |                     description: "Is your current request authenticated?"
  79 |                     type: "boolean"
  80 |                   ok:
  81 |                     description: "'OK'"
  82 |                     type: "string"
  83 |                   service:
  84 |                     description: "'Obsidian Local REST API'"
  85 |                     type: "string"
  86 |                   versions:
  87 |                     properties:
  88 |                       obsidian:
  89 |                         description: "Obsidian plugin API version"
  90 |                         type: "string"
  91 |                       self:
  92 |                         description: "Plugin version."
  93 |                         type: "string"
  94 |                     type: "object"
  95 |                 type: "object"
  96 |           description: "Success"
  97 |       summary: |
  98 |         Returns basic details about the server.
  99 |       tags:
 100 |         - "Status"
 101 |   /active/:
 102 |     delete:
 103 |       parameters: []
 104 |       responses:
 105 |         "204":
 106 |           description: "Success"
 107 |         "404":
 108 |           content:
 109 |             application/json:
 110 |               schema:
 111 |                 "$ref": "#/components/schemas/Error"
 112 |           description: "File does not exist."
 113 |         "405":
 114 |           content:
 115 |             application/json:
 116 |               schema:
 117 |                 "$ref": "#/components/schemas/Error"
 118 |           description: |
 119 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 120 |       summary: |
 121 |         Deletes the currently-active file in Obsidian.
 122 |       tags:
 123 |         - "Active File"
 124 |     get:
 125 |       description: |
 126 |         Returns the content of the currently active file in Obsidian.
 127 |         
 128 |         If you specify the header `Accept: application/vnd.olrapi.note+json`, will return a JSON representation of your note including parsed tag and frontmatter data as well as filesystem metadata.  See "responses" below for details.
 129 |       parameters: []
 130 |       responses:
 131 |         "200":
 132 |           content:
 133 |             "application/vnd.olrapi.note+json":
 134 |               schema:
 135 |                 "$ref": "#/components/schemas/NoteJson"
 136 |             text/markdown:
 137 |               schema:
 138 |                 example: |
 139 |                   # This is my document
 140 |                   
 141 |                   something else here
 142 |                 type: "string"
 143 |           description: "Success"
 144 |         "404":
 145 |           description: "File does not exist"
 146 |       summary: |
 147 |         Return the content of the active file open in Obsidian.
 148 |       tags:
 149 |         - "Active File"
 150 |     patch:
 151 |       description: |
 152 |         Inserts content into the currently-open note relative to a heading, block refeerence, or frontmatter field within that document.
 153 |         
 154 |         Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
 155 |         
 156 |         Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released.  See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
 157 |         
 158 |         # Examples
 159 |         
 160 |         All of the below examples assume you have a document that looks like
 161 |         this:
 162 |         
 163 |         ```markdown
 164 |         ---
 165 |         alpha: 1
 166 |         beta: test
 167 |         delta:
 168 |         zeta: 1
 169 |         yotta: 1
 170 |         gamma:
 171 |         - one
 172 |         - two
 173 |         ---
 174 |         
 175 |         # Heading 1
 176 |         
 177 |         This is the content for heading one
 178 |         
 179 |         Also references some [[#^484ef2]]
 180 |         
 181 |         ## Subheading 1:1
 182 |         Content for Subheading 1:1
 183 |         
 184 |         ### Subsubheading 1:1:1
 185 |         
 186 |         ### Subsubheading 1:1:2
 187 |         
 188 |         Testing how block references work for a table.[[#^2c7cfa]]
 189 |         Some content for Subsubheading 1:1:2
 190 |         
 191 |         More random text.
 192 |         
 193 |         ^2d9b4a
 194 |         
 195 |         ## Subheading 1:2
 196 |         
 197 |         Content for Subheading 1:2.
 198 |         
 199 |         some content with a block reference ^484ef2
 200 |         
 201 |         ## Subheading 1:3
 202 |         | City         | Population |
 203 |         | ------------ | ---------- |
 204 |         | Seattle, WA  | 8          |
 205 |         | Portland, OR | 4          |
 206 |         
 207 |         ^2c7cfa
 208 |         ```
 209 |         
 210 |         ## Append Content Below a Heading
 211 |         
 212 |         If you wanted to append the content "Hello" below "Subheading 1:1:1" under "Heading 1",
 213 |         you could send a request with the following headers:
 214 |         
 215 |         - `Operation`: `append`
 216 |         - `Target-Type`: `heading`
 217 |         - `Target`: `Heading 1::Subheading 1:1:1`
 218 |         - with the request body: `Hello`
 219 |         
 220 |         The above would work just fine for `prepend` or `replace`, too, of course,
 221 |         but with different results.
 222 |         
 223 |         ## Append Content to a Block Reference
 224 |         
 225 |         If you wanted to append the content "Hello" below the block referenced by
 226 |         "2d9b4a" above ("More random text."), you could send the following headers:
 227 |         
 228 |         - `Operation`: `append`
 229 |         - `Target-Type`: `block`
 230 |         - `Target`: `2d9b4a`
 231 |         - with the request body: `Hello`
 232 |         
 233 |         The above would work just fine for `prepend` or `replace`, too, of course,
 234 |         but with different results.
 235 |         
 236 |         ## Add a Row to a Table Referenced by a Block Reference
 237 |         
 238 |         If you wanted to add a new city ("Chicago, IL") and population ("16") pair to the table above
 239 |         referenced by the block reference `2c7cfa`, you could send the following
 240 |         headers:
 241 |         
 242 |         - `Operation`: `append`
 243 |         - `TargetType`: `block`
 244 |         - `Target`: `2c7cfa`
 245 |         - `Content-Type`: `application/json`
 246 |         - with the request body: `[["Chicago, IL", "16"]]`
 247 |         
 248 |         The use of a `Content-Type` of `application/json` allows the API
 249 |         to infer that member of your array represents rows and columns of your
 250 |         to append to the referenced table.  You can of course just use a
 251 |         `Content-Type` of `text/markdown`, but in such a case you'll have to
 252 |         format your table row manually instead of letting the library figure
 253 |         it out for you.
 254 |         
 255 |         You also have the option of using `prepend` (in which case, your new
 256 |         row would be the first -- right below the table heading) or `replace` (in which
 257 |         case all rows except the table heading would be replaced by the new row(s)
 258 |         you supplied).
 259 |         
 260 |         ## Setting a Frontmatter Field
 261 |         
 262 |         If you wanted to set the frontmatter field `alpha` to `2`, you could
 263 |         send the following headers:
 264 |         
 265 |         - `Operation`: `replace`
 266 |         - `TargetType`: `frontmatter`
 267 |         - `Target`: `beep`
 268 |         - with the request body `2`
 269 |         
 270 |         If you're setting a frontmatter field that might not already exist
 271 |         you may want to use the `Create-Target-If-Missing` header so the
 272 |         new frontmatter field is created and set to your specified value
 273 |         if it doesn't already exist.
 274 |         
 275 |         You may find using a `Content-Type` of `application/json` to be
 276 |         particularly useful in the case of frontmatter since frontmatter
 277 |         fields' values are JSON data, and the API can be smarter about
 278 |         interpreting yoru `prepend` or `append` requests if you specify
 279 |         your data as JSON (particularly when appending, for example,
 280 |         list items).
 281 |       parameters:
 282 |         - description: "Patch operation to perform"
 283 |           in: "header"
 284 |           name: "Operation"
 285 |           required: true
 286 |           schema:
 287 |             enum:
 288 |               - "append"
 289 |               - "prepend"
 290 |               - "replace"
 291 |             type: "string"
 292 |         - description: "Type of target to patch"
 293 |           in: "header"
 294 |           name: "Target-Type"
 295 |           required: true
 296 |           schema:
 297 |             enum:
 298 |               - "heading"
 299 |               - "block"
 300 |               - "frontmatter"
 301 |             type: "string"
 302 |         - description: "Delimiter to use for nested targets (i.e. Headings)"
 303 |           in: "header"
 304 |           name: "Target-Delimiter"
 305 |           required: false
 306 |           schema:
 307 |             default: "::"
 308 |             type: "string"
 309 |         - description: |
 310 |             Target to patch; this value can be URL-Encoded and *must*
 311 |             be URL-Encoded if it includes non-ASCII characters.
 312 |           in: "header"
 313 |           name: "Target"
 314 |           required: true
 315 |           schema:
 316 |             type: "string"
 317 |         - description: "Trim whitespace from Target before applying patch?"
 318 |           in: "header"
 319 |           name: "Trim-Target-Whitespace"
 320 |           required: false
 321 |           schema:
 322 |             default: "false"
 323 |             enum:
 324 |               - "true"
 325 |               - "false"
 326 |             type: "string"
 327 |       requestBody:
 328 |         content:
 329 |           application/json:
 330 |             schema:
 331 |               example: "['one', 'two']"
 332 |               type: "string"
 333 |           text/markdown:
 334 |             schema:
 335 |               example: |
 336 |                 # This is my document
 337 |                 
 338 |                 something else here
 339 |               type: "string"
 340 |         description: "Content you would like to insert."
 341 |         required: true
 342 |       responses:
 343 |         "200":
 344 |           description: "Success"
 345 |         "400":
 346 |           content:
 347 |             application/json:
 348 |               schema:
 349 |                 "$ref": "#/components/schemas/Error"
 350 |           description: "Bad Request; see response message for details."
 351 |         "404":
 352 |           content:
 353 |             application/json:
 354 |               schema:
 355 |                 "$ref": "#/components/schemas/Error"
 356 |           description: "Does not exist"
 357 |         "405":
 358 |           content:
 359 |             application/json:
 360 |               schema:
 361 |                 "$ref": "#/components/schemas/Error"
 362 |           description: |
 363 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 364 |       summary: |
 365 |         Insert content into the currently open note in Obsidian relative to a heading, block reference, or frontmatter field within that document.
 366 |       tags:
 367 |         - "Active File"
 368 |     post:
 369 |       description: |
 370 |         Appends content to the end of the currently-open note.
 371 |         
 372 |         If you would like to insert text relative to a particular heading instead of appending to the end of the file, see 'patch'.
 373 |       parameters: []
 374 |       requestBody:
 375 |         content:
 376 |           text/markdown:
 377 |             schema:
 378 |               example: |
 379 |                 # This is my document
 380 |                 
 381 |                 something else here
 382 |               type: "string"
 383 |         description: "Content you would like to append."
 384 |         required: true
 385 |       responses:
 386 |         "204":
 387 |           description: "Success"
 388 |         "400":
 389 |           content:
 390 |             application/json:
 391 |               schema:
 392 |                 "$ref": "#/components/schemas/Error"
 393 |           description: "Bad Request"
 394 |         "405":
 395 |           content:
 396 |             application/json:
 397 |               schema:
 398 |                 "$ref": "#/components/schemas/Error"
 399 |           description: |
 400 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 401 |       summary: |
 402 |         Append content to the active file open in Obsidian.
 403 |       tags:
 404 |         - "Active File"
 405 |     put:
 406 |       parameters: []
 407 |       requestBody:
 408 |         content:
 409 |           "*/*":
 410 |             schema:
 411 |               type: "string"
 412 |           text/markdown:
 413 |             schema:
 414 |               example: |
 415 |                 # This is my document
 416 |                 
 417 |                 something else here
 418 |               type: "string"
 419 |         description: "Content of the file you would like to upload."
 420 |         required: true
 421 |       responses:
 422 |         "204":
 423 |           description: "Success"
 424 |         "400":
 425 |           content:
 426 |             application/json:
 427 |               schema:
 428 |                 "$ref": "#/components/schemas/Error"
 429 |           description: |
 430 |             Incoming file could not be processed.  Make sure you have specified a reasonable file name, and make sure you have set a reasonable 'Content-Type' header; if you are uploading a note, 'text/markdown' is likely the right choice.
 431 |         "405":
 432 |           content:
 433 |             application/json:
 434 |               schema:
 435 |                 "$ref": "#/components/schemas/Error"
 436 |           description: |
 437 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 438 |       summary: |
 439 |         Update the content of the active file open in Obsidian.
 440 |       tags:
 441 |         - "Active File"
 442 |   /commands/:
 443 |     get:
 444 |       responses:
 445 |         "200":
 446 |           content:
 447 |             application/json:
 448 |               example:
 449 |                 commands:
 450 |                   - id: "global-search:open"
 451 |                     name: "Search: Search in all files"
 452 |                   - id: "graph:open"
 453 |                     name: "Graph view: Open graph view"
 454 |               schema:
 455 |                 properties:
 456 |                   commands:
 457 |                     items:
 458 |                       properties:
 459 |                         id:
 460 |                           type: "string"
 461 |                         name:
 462 |                           type: "string"
 463 |                       type: "object"
 464 |                     type: "array"
 465 |                 type: "object"
 466 |           description: "A list of available commands."
 467 |       summary: |
 468 |         Get a list of available commands.
 469 |       tags:
 470 |         - "Commands"
 471 |   "/commands/{commandId}/":
 472 |     post:
 473 |       parameters:
 474 |         - description: "The id of the command to execute"
 475 |           in: "path"
 476 |           name: "commandId"
 477 |           required: true
 478 |           schema:
 479 |             type: "string"
 480 |       responses:
 481 |         "204":
 482 |           description: "Success"
 483 |         "404":
 484 |           content:
 485 |             application/json:
 486 |               schema:
 487 |                 "$ref": "#/components/schemas/Error"
 488 |           description: "The command you specified does not exist."
 489 |       summary: |
 490 |         Execute a command.
 491 |       tags:
 492 |         - "Commands"
 493 |   "/open/{filename}":
 494 |     post:
 495 |       description: |
 496 |         Opens the specified document in Obsidian.
 497 |         
 498 |         Note: Obsidian will create a new document at the path you have
 499 |         specified if such a document did not already exist.
 500 |       parameters:
 501 |         - description: |
 502 |             Path to the file to return (relative to your vault root).
 503 |           in: "path"
 504 |           name: "filename"
 505 |           required: true
 506 |           schema:
 507 |             format: "path"
 508 |             type: "string"
 509 |         - description: "Open this as a new leaf?"
 510 |           in: "query"
 511 |           name: "newLeaf"
 512 |           required: false
 513 |           schema:
 514 |             type: "boolean"
 515 |       responses:
 516 |         "200":
 517 |           description: "Success"
 518 |       summary: |
 519 |         Open the specified document in Obsidian
 520 |       tags:
 521 |         - "Open"
 522 |   "/periodic/{period}/":
 523 |     delete:
 524 |       description: |
 525 |         Deletes the periodic note for the specified period.
 526 |       parameters:
 527 |         - description: "The name of the period for which you would like to grab the current note."
 528 |           in: "path"
 529 |           name: "period"
 530 |           required: true
 531 |           schema:
 532 |             default: "daily"
 533 |             enum:
 534 |               - "daily"
 535 |               - "weekly"
 536 |               - "monthly"
 537 |               - "quarterly"
 538 |               - "yearly"
 539 |             type: "string"
 540 |       responses:
 541 |         "204":
 542 |           description: "Success"
 543 |         "404":
 544 |           content:
 545 |             application/json:
 546 |               schema:
 547 |                 "$ref": "#/components/schemas/Error"
 548 |           description: "File does not exist."
 549 |         "405":
 550 |           content:
 551 |             application/json:
 552 |               schema:
 553 |                 "$ref": "#/components/schemas/Error"
 554 |           description: |
 555 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 556 |       summary: |
 557 |         Delete a periodic note.
 558 |       tags:
 559 |         - "Periodic Notes"
 560 |     get:
 561 |       parameters:
 562 |         - description: "The name of the period for which you would like to grab the current note."
 563 |           in: "path"
 564 |           name: "period"
 565 |           required: true
 566 |           schema:
 567 |             default: "daily"
 568 |             enum:
 569 |               - "daily"
 570 |               - "weekly"
 571 |               - "monthly"
 572 |               - "quarterly"
 573 |               - "yearly"
 574 |             type: "string"
 575 |       responses:
 576 |         "200":
 577 |           content:
 578 |             "application/vnd.olrapi.note+json":
 579 |               schema:
 580 |                 "$ref": "#/components/schemas/NoteJson"
 581 |             text/markdown:
 582 |               schema:
 583 |                 example: |
 584 |                   # This is my document
 585 |                   
 586 |                   something else here
 587 |                 type: "string"
 588 |           description: "Success"
 589 |         "404":
 590 |           description: "File does not exist"
 591 |       summary: |
 592 |         Get current periodic note for the specified period.
 593 |       tags:
 594 |         - "Periodic Notes"
 595 |     patch:
 596 |       description: |
 597 |         Inserts content into a periodic note relative to a heading, block refeerence, or frontmatter field within that document.
 598 |         
 599 |         Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
 600 |         
 601 |         Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released.  See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
 602 |         
 603 |         # Examples
 604 |         
 605 |         All of the below examples assume you have a document that looks like
 606 |         this:
 607 |         
 608 |         ```markdown
 609 |         ---
 610 |         alpha: 1
 611 |         beta: test
 612 |         delta:
 613 |         zeta: 1
 614 |         yotta: 1
 615 |         gamma:
 616 |         - one
 617 |         - two
 618 |         ---
 619 |         
 620 |         # Heading 1
 621 |         
 622 |         This is the content for heading one
 623 |         
 624 |         Also references some [[#^484ef2]]
 625 |         
 626 |         ## Subheading 1:1
 627 |         Content for Subheading 1:1
 628 |         
 629 |         ### Subsubheading 1:1:1
 630 |         
 631 |         ### Subsubheading 1:1:2
 632 |         
 633 |         Testing how block references work for a table.[[#^2c7cfa]]
 634 |         Some content for Subsubheading 1:1:2
 635 |         
 636 |         More random text.
 637 |         
 638 |         ^2d9b4a
 639 |         
 640 |         ## Subheading 1:2
 641 |         
 642 |         Content for Subheading 1:2.
 643 |         
 644 |         some content with a block reference ^484ef2
 645 |         
 646 |         ## Subheading 1:3
 647 |         | City         | Population |
 648 |         | ------------ | ---------- |
 649 |         | Seattle, WA  | 8          |
 650 |         | Portland, OR | 4          |
 651 |         
 652 |         ^2c7cfa
 653 |         ```
 654 |         
 655 |         ## Append Content Below a Heading
 656 |         
 657 |         If you wanted to append the content "Hello" below "Subheading 1:1:1" under "Heading 1",
 658 |         you could send a request with the following headers:
 659 |         
 660 |         - `Operation`: `append`
 661 |         - `Target-Type`: `heading`
 662 |         - `Target`: `Heading 1::Subheading 1:1:1`
 663 |         - with the request body: `Hello`
 664 |         
 665 |         The above would work just fine for `prepend` or `replace`, too, of course,
 666 |         but with different results.
 667 |         
 668 |         ## Append Content to a Block Reference
 669 |         
 670 |         If you wanted to append the content "Hello" below the block referenced by
 671 |         "2d9b4a" above ("More random text."), you could send the following headers:
 672 |         
 673 |         - `Operation`: `append`
 674 |         - `Target-Type`: `block`
 675 |         - `Target`: `2d9b4a`
 676 |         - with the request body: `Hello`
 677 |         
 678 |         The above would work just fine for `prepend` or `replace`, too, of course,
 679 |         but with different results.
 680 |         
 681 |         ## Add a Row to a Table Referenced by a Block Reference
 682 |         
 683 |         If you wanted to add a new city ("Chicago, IL") and population ("16") pair to the table above
 684 |         referenced by the block reference `2c7cfa`, you could send the following
 685 |         headers:
 686 |         
 687 |         - `Operation`: `append`
 688 |         - `TargetType`: `block`
 689 |         - `Target`: `2c7cfa`
 690 |         - `Content-Type`: `application/json`
 691 |         - with the request body: `[["Chicago, IL", "16"]]`
 692 |         
 693 |         The use of a `Content-Type` of `application/json` allows the API
 694 |         to infer that member of your array represents rows and columns of your
 695 |         to append to the referenced table.  You can of course just use a
 696 |         `Content-Type` of `text/markdown`, but in such a case you'll have to
 697 |         format your table row manually instead of letting the library figure
 698 |         it out for you.
 699 |         
 700 |         You also have the option of using `prepend` (in which case, your new
 701 |         row would be the first -- right below the table heading) or `replace` (in which
 702 |         case all rows except the table heading would be replaced by the new row(s)
 703 |         you supplied).
 704 |         
 705 |         ## Setting a Frontmatter Field
 706 |         
 707 |         If you wanted to set the frontmatter field `alpha` to `2`, you could
 708 |         send the following headers:
 709 |         
 710 |         - `Operation`: `replace`
 711 |         - `TargetType`: `frontmatter`
 712 |         - `Target`: `beep`
 713 |         - with the request body `2`
 714 |         
 715 |         If you're setting a frontmatter field that might not already exist
 716 |         you may want to use the `Create-Target-If-Missing` header so the
 717 |         new frontmatter field is created and set to your specified value
 718 |         if it doesn't already exist.
 719 |         
 720 |         You may find using a `Content-Type` of `application/json` to be
 721 |         particularly useful in the case of frontmatter since frontmatter
 722 |         fields' values are JSON data, and the API can be smarter about
 723 |         interpreting yoru `prepend` or `append` requests if you specify
 724 |         your data as JSON (particularly when appending, for example,
 725 |         list items).
 726 |       parameters:
 727 |         - description: "Patch operation to perform"
 728 |           in: "header"
 729 |           name: "Operation"
 730 |           required: true
 731 |           schema:
 732 |             enum:
 733 |               - "append"
 734 |               - "prepend"
 735 |               - "replace"
 736 |             type: "string"
 737 |         - description: "Type of target to patch"
 738 |           in: "header"
 739 |           name: "Target-Type"
 740 |           required: true
 741 |           schema:
 742 |             enum:
 743 |               - "heading"
 744 |               - "block"
 745 |               - "frontmatter"
 746 |             type: "string"
 747 |         - description: "Delimiter to use for nested targets (i.e. Headings)"
 748 |           in: "header"
 749 |           name: "Target-Delimiter"
 750 |           required: false
 751 |           schema:
 752 |             default: "::"
 753 |             type: "string"
 754 |         - description: |
 755 |             Target to patch; this value can be URL-Encoded and *must*
 756 |             be URL-Encoded if it includes non-ASCII characters.
 757 |           in: "header"
 758 |           name: "Target"
 759 |           required: true
 760 |           schema:
 761 |             type: "string"
 762 |         - description: "Trim whitespace from Target before applying patch?"
 763 |           in: "header"
 764 |           name: "Trim-Target-Whitespace"
 765 |           required: false
 766 |           schema:
 767 |             default: "false"
 768 |             enum:
 769 |               - "true"
 770 |               - "false"
 771 |             type: "string"
 772 |         - description: "The name of the period for which you would like to grab the current note."
 773 |           in: "path"
 774 |           name: "period"
 775 |           required: true
 776 |           schema:
 777 |             default: "daily"
 778 |             enum:
 779 |               - "daily"
 780 |               - "weekly"
 781 |               - "monthly"
 782 |               - "quarterly"
 783 |               - "yearly"
 784 |             type: "string"
 785 |       requestBody:
 786 |         content:
 787 |           application/json:
 788 |             schema:
 789 |               example: "['one', 'two']"
 790 |               type: "string"
 791 |           text/markdown:
 792 |             schema:
 793 |               example: |
 794 |                 # This is my document
 795 |                 
 796 |                 something else here
 797 |               type: "string"
 798 |         description: "Content you would like to insert."
 799 |         required: true
 800 |       responses:
 801 |         "200":
 802 |           description: "Success"
 803 |         "400":
 804 |           content:
 805 |             application/json:
 806 |               schema:
 807 |                 "$ref": "#/components/schemas/Error"
 808 |           description: "Bad Request; see response message for details."
 809 |         "404":
 810 |           content:
 811 |             application/json:
 812 |               schema:
 813 |                 "$ref": "#/components/schemas/Error"
 814 |           description: "Does not exist"
 815 |         "405":
 816 |           content:
 817 |             application/json:
 818 |               schema:
 819 |                 "$ref": "#/components/schemas/Error"
 820 |           description: |
 821 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 822 |       summary: |
 823 |         Insert content into a periodic note in Obsidian relative to a heading, block reference, or frontmatter field within that document.
 824 |       tags:
 825 |         - "Periodic Notes"
 826 |     post:
 827 |       description: |
 828 |         Appends content to the periodic note for the specified period.  This will create the relevant periodic note if necessary.
 829 |       parameters:
 830 |         - description: "The name of the period for which you would like to grab the current note."
 831 |           in: "path"
 832 |           name: "period"
 833 |           required: true
 834 |           schema:
 835 |             default: "daily"
 836 |             enum:
 837 |               - "daily"
 838 |               - "weekly"
 839 |               - "monthly"
 840 |               - "quarterly"
 841 |               - "yearly"
 842 |             type: "string"
 843 |       requestBody:
 844 |         content:
 845 |           text/markdown:
 846 |             schema:
 847 |               example: |
 848 |                 # This is my document
 849 |                 
 850 |                 something else here
 851 |               type: "string"
 852 |         description: "Content you would like to append."
 853 |         required: true
 854 |       responses:
 855 |         "204":
 856 |           description: "Success"
 857 |         "400":
 858 |           content:
 859 |             application/json:
 860 |               schema:
 861 |                 "$ref": "#/components/schemas/Error"
 862 |           description: "Bad Request"
 863 |         "405":
 864 |           content:
 865 |             application/json:
 866 |               schema:
 867 |                 "$ref": "#/components/schemas/Error"
 868 |           description: |
 869 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 870 |       summary: |
 871 |         Append content to a periodic note.
 872 |       tags:
 873 |         - "Periodic Notes"
 874 |     put:
 875 |       parameters:
 876 |         - description: "The name of the period for which you would like to grab the current note."
 877 |           in: "path"
 878 |           name: "period"
 879 |           required: true
 880 |           schema:
 881 |             default: "daily"
 882 |             enum:
 883 |               - "daily"
 884 |               - "weekly"
 885 |               - "monthly"
 886 |               - "quarterly"
 887 |               - "yearly"
 888 |             type: "string"
 889 |       requestBody:
 890 |         content:
 891 |           "*/*":
 892 |             schema:
 893 |               type: "string"
 894 |           text/markdown:
 895 |             schema:
 896 |               example: |
 897 |                 # This is my document
 898 |                 
 899 |                 something else here
 900 |               type: "string"
 901 |         description: "Content of the file you would like to upload."
 902 |         required: true
 903 |       responses:
 904 |         "204":
 905 |           description: "Success"
 906 |         "400":
 907 |           content:
 908 |             application/json:
 909 |               schema:
 910 |                 "$ref": "#/components/schemas/Error"
 911 |           description: |
 912 |             Incoming file could not be processed.  Make sure you have specified a reasonable file name, and make sure you have set a reasonable 'Content-Type' header; if you are uploading a note, 'text/markdown' is likely the right choice.
 913 |         "405":
 914 |           content:
 915 |             application/json:
 916 |               schema:
 917 |                 "$ref": "#/components/schemas/Error"
 918 |           description: |
 919 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 920 |       summary: |
 921 |         Update the content of a periodic note.
 922 |       tags:
 923 |         - "Periodic Notes"
 924 |   "/periodic/{year}/{month}/{day}/{period}/":
 925 |     delete:
 926 |       description: |
 927 |         Deletes the periodic note for the specified period.
 928 |       parameters:
 929 |         - description: "The year of the date for which you would like to grab a periodic note."
 930 |           in: "path"
 931 |           name: "year"
 932 |           required: true
 933 |           schema:
 934 |             type: "number"
 935 |         - description: "The month (1-12) of the date for which you would like to grab a periodic note."
 936 |           in: "path"
 937 |           name: "month"
 938 |           required: true
 939 |           schema:
 940 |             type: "number"
 941 |         - description: "The day (1-31) of the date for which you would like to grab a periodic note."
 942 |           in: "path"
 943 |           name: "day"
 944 |           required: true
 945 |           schema:
 946 |             type: "number"
 947 |         - description: "The name of the period for which you would like to grab the current note."
 948 |           in: "path"
 949 |           name: "period"
 950 |           required: true
 951 |           schema:
 952 |             default: "daily"
 953 |             enum:
 954 |               - "daily"
 955 |               - "weekly"
 956 |               - "monthly"
 957 |               - "quarterly"
 958 |               - "yearly"
 959 |             type: "string"
 960 |       responses:
 961 |         "204":
 962 |           description: "Success"
 963 |         "404":
 964 |           content:
 965 |             application/json:
 966 |               schema:
 967 |                 "$ref": "#/components/schemas/Error"
 968 |           description: "File does not exist."
 969 |         "405":
 970 |           content:
 971 |             application/json:
 972 |               schema:
 973 |                 "$ref": "#/components/schemas/Error"
 974 |           description: |
 975 |             Your path references a directory instead of a file; this request method is valid only for updating files.
 976 |       summary: |
 977 |         Delete a periodic note.
 978 |       tags:
 979 |         - "Periodic Notes"
 980 |     get:
 981 |       parameters:
 982 |         - description: "The year of the date for which you would like to grab a periodic note."
 983 |           in: "path"
 984 |           name: "year"
 985 |           required: true
 986 |           schema:
 987 |             type: "number"
 988 |         - description: "The month (1-12) of the date for which you would like to grab a periodic note."
 989 |           in: "path"
 990 |           name: "month"
 991 |           required: true
 992 |           schema:
 993 |             type: "number"
 994 |         - description: "The day (1-31) of the date for which you would like to grab a periodic note."
 995 |           in: "path"
 996 |           name: "day"
 997 |           required: true
 998 |           schema:
 999 |             type: "number"
1000 |         - description: "The name of the period for which you would like to grab the current note."
1001 |           in: "path"
1002 |           name: "period"
1003 |           required: true
1004 |           schema:
1005 |             default: "daily"
1006 |             enum:
1007 |               - "daily"
1008 |               - "weekly"
1009 |               - "monthly"
1010 |               - "quarterly"
1011 |               - "yearly"
1012 |             type: "string"
1013 |       responses:
1014 |         "200":
1015 |           content:
1016 |             "application/vnd.olrapi.note+json":
1017 |               schema:
1018 |                 "$ref": "#/components/schemas/NoteJson"
1019 |             text/markdown:
1020 |               schema:
1021 |                 example: |
1022 |                   # This is my document
1023 |                   
1024 |                   something else here
1025 |                 type: "string"
1026 |           description: "Success"
1027 |         "404":
1028 |           description: "File does not exist"
1029 |       summary: |
1030 |         Get current periodic note for the specified period.
1031 |       tags:
1032 |         - "Periodic Notes"
1033 |     patch:
1034 |       description: |
1035 |         Inserts content into a periodic note relative to a heading, block refeerence, or frontmatter field within that document.
1036 |         
1037 |         Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
1038 |         
1039 |         Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released.  See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
1040 |         
1041 |         # Examples
1042 |         
1043 |         All of the below examples assume you have a document that looks like
1044 |         this:
1045 |         
1046 |         ```markdown
1047 |         ---
1048 |         alpha: 1
1049 |         beta: test
1050 |         delta:
1051 |         zeta: 1
1052 |         yotta: 1
1053 |         gamma:
1054 |         - one
1055 |         - two
1056 |         ---
1057 |         
1058 |         # Heading 1
1059 |         
1060 |         This is the content for heading one
1061 |         
1062 |         Also references some [[#^484ef2]]
1063 |         
1064 |         ## Subheading 1:1
1065 |         Content for Subheading 1:1
1066 |         
1067 |         ### Subsubheading 1:1:1
1068 |         
1069 |         ### Subsubheading 1:1:2
1070 |         
1071 |         Testing how block references work for a table.[[#^2c7cfa]]
1072 |         Some content for Subsubheading 1:1:2
1073 |         
1074 |         More random text.
1075 |         
1076 |         ^2d9b4a
1077 |         
1078 |         ## Subheading 1:2
1079 |         
1080 |         Content for Subheading 1:2.
1081 |         
1082 |         some content with a block reference ^484ef2
1083 |         
1084 |         ## Subheading 1:3
1085 |         | City         | Population |
1086 |         | ------------ | ---------- |
1087 |         | Seattle, WA  | 8          |
1088 |         | Portland, OR | 4          |
1089 |         
1090 |         ^2c7cfa
1091 |         ```
1092 |         
1093 |         ## Append Content Below a Heading
1094 |         
1095 |         If you wanted to append the content "Hello" below "Subheading 1:1:1" under "Heading 1",
1096 |         you could send a request with the following headers:
1097 |         
1098 |         - `Operation`: `append`
1099 |         - `Target-Type`: `heading`
1100 |         - `Target`: `Heading 1::Subheading 1:1:1`
1101 |         - with the request body: `Hello`
1102 |         
1103 |         The above would work just fine for `prepend` or `replace`, too, of course,
1104 |         but with different results.
1105 |         
1106 |         ## Append Content to a Block Reference
1107 |         
1108 |         If you wanted to append the content "Hello" below the block referenced by
1109 |         "2d9b4a" above ("More random text."), you could send the following headers:
1110 |         
1111 |         - `Operation`: `append`
1112 |         - `Target-Type`: `block`
1113 |         - `Target`: `2d9b4a`
1114 |         - with the request body: `Hello`
1115 |         
1116 |         The above would work just fine for `prepend` or `replace`, too, of course,
1117 |         but with different results.
1118 |         
1119 |         ## Add a Row to a Table Referenced by a Block Reference
1120 |         
1121 |         If you wanted to add a new city ("Chicago, IL") and population ("16") pair to the table above
1122 |         referenced by the block reference `2c7cfa`, you could send the following
1123 |         headers:
1124 |         
1125 |         - `Operation`: `append`
1126 |         - `TargetType`: `block`
1127 |         - `Target`: `2c7cfa`
1128 |         - `Content-Type`: `application/json`
1129 |         - with the request body: `[["Chicago, IL", "16"]]`
1130 |         
1131 |         The use of a `Content-Type` of `application/json` allows the API
1132 |         to infer that member of your array represents rows and columns of your
1133 |         to append to the referenced table.  You can of course just use a
1134 |         `Content-Type` of `text/markdown`, but in such a case you'll have to
1135 |         format your table row manually instead of letting the library figure
1136 |         it out for you.
1137 |         
1138 |         You also have the option of using `prepend` (in which case, your new
1139 |         row would be the first -- right below the table heading) or `replace` (in which
1140 |         case all rows except the table heading would be replaced by the new row(s)
1141 |         you supplied).
1142 |         
1143 |         ## Setting a Frontmatter Field
1144 |         
1145 |         If you wanted to set the frontmatter field `alpha` to `2`, you could
1146 |         send the following headers:
1147 |         
1148 |         - `Operation`: `replace`
1149 |         - `TargetType`: `frontmatter`
1150 |         - `Target`: `beep`
1151 |         - with the request body `2`
1152 |         
1153 |         If you're setting a frontmatter field that might not already exist
1154 |         you may want to use the `Create-Target-If-Missing` header so the
1155 |         new frontmatter field is created and set to your specified value
1156 |         if it doesn't already exist.
1157 |         
1158 |         You may find using a `Content-Type` of `application/json` to be
1159 |         particularly useful in the case of frontmatter since frontmatter
1160 |         fields' values are JSON data, and the API can be smarter about
1161 |         interpreting yoru `prepend` or `append` requests if you specify
1162 |         your data as JSON (particularly when appending, for example,
1163 |         list items).
1164 |       parameters:
1165 |         - description: "Patch operation to perform"
1166 |           in: "header"
1167 |           name: "Operation"
1168 |           required: true
1169 |           schema:
1170 |             enum:
1171 |               - "append"
1172 |               - "prepend"
1173 |               - "replace"
1174 |             type: "string"
1175 |         - description: "Type of target to patch"
1176 |           in: "header"
1177 |           name: "Target-Type"
1178 |           required: true
1179 |           schema:
1180 |             enum:
1181 |               - "heading"
1182 |               - "block"
1183 |               - "frontmatter"
1184 |             type: "string"
1185 |         - description: "Delimiter to use for nested targets (i.e. Headings)"
1186 |           in: "header"
1187 |           name: "Target-Delimiter"
1188 |           required: false
1189 |           schema:
1190 |             default: "::"
1191 |             type: "string"
1192 |         - description: |
1193 |             Target to patch; this value can be URL-Encoded and *must*
1194 |             be URL-Encoded if it includes non-ASCII characters.
1195 |           in: "header"
1196 |           name: "Target"
1197 |           required: true
1198 |           schema:
1199 |             type: "string"
1200 |         - description: "Trim whitespace from Target before applying patch?"
1201 |           in: "header"
1202 |           name: "Trim-Target-Whitespace"
1203 |           required: false
1204 |           schema:
1205 |             default: "false"
1206 |             enum:
1207 |               - "true"
1208 |               - "false"
1209 |             type: "string"
1210 |         - description: "The year of the date for which you would like to grab a periodic note."
1211 |           in: "path"
1212 |           name: "year"
1213 |           required: true
1214 |           schema:
1215 |             type: "number"
1216 |         - description: "The month (1-12) of the date for which you would like to grab a periodic note."
1217 |           in: "path"
1218 |           name: "month"
1219 |           required: true
1220 |           schema:
1221 |             type: "number"
1222 |         - description: "The day (1-31) of the date for which you would like to grab a periodic note."
1223 |           in: "path"
1224 |           name: "day"
1225 |           required: true
1226 |           schema:
1227 |             type: "number"
1228 |         - description: "The name of the period for which you would like to grab the current note."
1229 |           in: "path"
1230 |           name: "period"
1231 |           required: true
1232 |           schema:
1233 |             default: "daily"
1234 |             enum:
1235 |               - "daily"
1236 |               - "weekly"
1237 |               - "monthly"
1238 |               - "quarterly"
1239 |               - "yearly"
1240 |             type: "string"
1241 |       requestBody:
1242 |         content:
1243 |           application/json:
1244 |             schema:
1245 |               example: "['one', 'two']"
1246 |               type: "string"
1247 |           text/markdown:
1248 |             schema:
1249 |               example: |
1250 |                 # This is my document
1251 |                 
1252 |                 something else here
1253 |               type: "string"
1254 |         description: "Content you would like to insert."
1255 |         required: true
1256 |       responses:
1257 |         "200":
1258 |           description: "Success"
1259 |         "400":
1260 |           content:
1261 |             application/json:
1262 |               schema:
1263 |                 "$ref": "#/components/schemas/Error"
1264 |           description: "Bad Request; see response message for details."
1265 |         "404":
1266 |           content:
1267 |             application/json:
1268 |               schema:
1269 |                 "$ref": "#/components/schemas/Error"
1270 |           description: "Does not exist"
1271 |         "405":
1272 |           content:
1273 |             application/json:
1274 |               schema:
1275 |                 "$ref": "#/components/schemas/Error"
1276 |           description: |
1277 |             Your path references a directory instead of a file; this request method is valid only for updating files.
1278 |       summary: |
1279 |         Insert content into a periodic note in Obsidian relative to a heading, block reference, or frontmatter field within that document.
1280 |       tags:
1281 |         - "Periodic Notes"
1282 |     post:
1283 |       description: |
1284 |         Appends content to the periodic note for the specified period.  This will create the relevant periodic note if necessary.
1285 |       parameters:
1286 |         - description: "The year of the date for which you would like to grab a periodic note."
1287 |           in: "path"
1288 |           name: "year"
1289 |           required: true
1290 |           schema:
1291 |             type: "number"
1292 |         - description: "The month (1-12) of the date for which you would like to grab a periodic note."
1293 |           in: "path"
1294 |           name: "month"
1295 |           required: true
1296 |           schema:
1297 |             type: "number"
1298 |         - description: "The day (1-31) of the date for which you would like to grab a periodic note."
1299 |           in: "path"
1300 |           name: "day"
1301 |           required: true
1302 |           schema:
1303 |             type: "number"
1304 |         - description: "The name of the period for which you would like to grab the current note."
1305 |           in: "path"
1306 |           name: "period"
1307 |           required: true
1308 |           schema:
1309 |             default: "daily"
1310 |             enum:
1311 |               - "daily"
1312 |               - "weekly"
1313 |               - "monthly"
1314 |               - "quarterly"
1315 |               - "yearly"
1316 |             type: "string"
1317 |       requestBody:
1318 |         content:
1319 |           text/markdown:
1320 |             schema:
1321 |               example: |
1322 |                 # This is my document
1323 |                 
1324 |                 something else here
1325 |               type: "string"
1326 |         description: "Content you would like to append."
1327 |         required: true
1328 |       responses:
1329 |         "204":
1330 |           description: "Success"
1331 |         "400":
1332 |           content:
1333 |             application/json:
1334 |               schema:
1335 |                 "$ref": "#/components/schemas/Error"
1336 |           description: "Bad Request"
1337 |         "405":
1338 |           content:
1339 |             application/json:
1340 |               schema:
1341 |                 "$ref": "#/components/schemas/Error"
1342 |           description: |
1343 |             Your path references a directory instead of a file; this request method is valid only for updating files.
1344 |       summary: |
1345 |         Append content to a periodic note.
1346 |       tags:
1347 |         - "Periodic Notes"
1348 |     put:
1349 |       parameters:
1350 |         - description: "The year of the date for which you would like to grab a periodic note."
1351 |           in: "path"
1352 |           name: "year"
1353 |           required: true
1354 |           schema:
1355 |             type: "number"
1356 |         - description: "The month (1-12) of the date for which you would like to grab a periodic note."
1357 |           in: "path"
1358 |           name: "month"
1359 |           required: true
1360 |           schema:
1361 |             type: "number"
1362 |         - description: "The day (1-31) of the date for which you would like to grab a periodic note."
1363 |           in: "path"
1364 |           name: "day"
1365 |           required: true
1366 |           schema:
1367 |             type: "number"
1368 |         - description: "The name of the period for which you would like to grab the current note."
1369 |           in: "path"
1370 |           name: "period"
1371 |           required: true
1372 |           schema:
1373 |             default: "daily"
1374 |             enum:
1375 |               - "daily"
1376 |               - "weekly"
1377 |               - "monthly"
1378 |               - "quarterly"
1379 |               - "yearly"
1380 |             type: "string"
1381 |       requestBody:
1382 |         content:
1383 |           "*/*":
1384 |             schema:
1385 |               type: "string"
1386 |           text/markdown:
1387 |             schema:
1388 |               example: |
1389 |                 # This is my document
1390 |                 
1391 |                 something else here
1392 |               type: "string"
1393 |         description: "Content of the file you would like to upload."
1394 |         required: true
1395 |       responses:
1396 |         "204":
1397 |           description: "Success"
1398 |         "400":
1399 |           content:
1400 |             application/json:
1401 |               schema:
1402 |                 "$ref": "#/components/schemas/Error"
1403 |           description: |
1404 |             Incoming file could not be processed.  Make sure you have specified a reasonable file name, and make sure you have set a reasonable 'Content-Type' header; if you are uploading a note, 'text/markdown' is likely the right choice.
1405 |         "405":
1406 |           content:
1407 |             application/json:
1408 |               schema:
1409 |                 "$ref": "#/components/schemas/Error"
1410 |           description: |
1411 |             Your path references a directory instead of a file; this request method is valid only for updating files.
1412 |       summary: |
1413 |         Update the content of a periodic note.
1414 |       tags:
1415 |         - "Periodic Notes"
1416 |   /search/:
1417 |     post:
1418 |       description: |
1419 |         Evaluates a provided query against each file in your vault.
1420 |         
1421 |         This endpoint supports multiple query formats.  Your query should be specified in your request's body, and will be interpreted according to the `Content-type` header you specify from the below options.Additional query formats may be added in the future.
1422 |         
1423 |         # Dataview DQL (`application/vnd.olrapi.dataview.dql+txt`)
1424 |         
1425 |         Accepts a `TABLE`-type Dataview query as a text string.  See [Dataview](https://blacksmithgu.github.io/obsidian-dataview/query/queries/)'s query documentation for information on how to construct a query.
1426 |         
1427 |         # JsonLogic (`application/vnd.olrapi.jsonlogic+json`)
1428 |         
1429 |         Accepts a JsonLogic query specified as JSON.  See [JsonLogic](https://jsonlogic.com/operations.html)'s documentation for information about the base set of operators available, but in addition to those operators the following operators are available:
1430 |         
1431 |         - `glob: [PATTERN, VALUE]`: Returns `true` if a string matches a glob pattern.  E.g.: `{"glob": ["*.foo", "bar.foo"]}` is `true` and `{"glob": ["*.bar", "bar.foo"]}` is `false`.
1432 |         - `regexp: [PATTERN, VALUE]`: Returns `true` if a string matches a regular expression.  E.g.: `{"regexp": [".*\.foo", "bar.foo"]` is `true` and `{"regexp": [".*\.bar", "bar.foo"]}` is `false`.
1433 |         
1434 |         Returns only non-falsy results.  "Non-falsy" here treats the following values as "falsy":
1435 |         
1436 |         - `false`
1437 |         - `null` or `undefined`
1438 |         - `0`
1439 |         - `[]`
1440 |         - `{}`
1441 |         
1442 |         Files are represented as an object having the schema described
1443 |         in the Schema named 'NoteJson' at the bottom of this page.
1444 |         Understanding the shape of a JSON object from a schema can be
1445 |         tricky; so you may find it helpful to examine the generated metadata
1446 |         for individual files in your vault to understand exactly what values
1447 |         are returned.  To see that, access the `GET` `/vault/{filePath}`
1448 |         route setting the header:
1449 |         `Accept: application/vnd.olrapi.note+json`.  See examples below
1450 |         for working examples of queries performing common search operations.
1451 |       requestBody:
1452 |         content:
1453 |           "application/vnd.olrapi.dataview.dql+txt":
1454 |             examples:
1455 |               find_fields_by_tag:
1456 |                 summary: "List data from files having the #game tag."
1457 |                 value: |
1458 |                   TABLE
1459 |                     time-played AS "Time Played",
1460 |                     length AS "Length",
1461 |                     rating AS "Rating"
1462 |                   FROM #game
1463 |                   SORT rating DESC
1464 |             schema:
1465 |               externalDocs:
1466 |                 url: "https://blacksmithgu.github.io/obsidian-dataview/query/queries/"
1467 |               type: "object"
1468 |           "application/vnd.olrapi.jsonlogic+json":
1469 |             examples:
1470 |               find_by_frontmatter_url_glob:
1471 |                 summary: "Find notes having URL or a matching URL glob frontmatter field."
1472 |                 value: |
1473 |                   {
1474 |                     "or": [
1475 |                       {"===": [{"var": "frontmatter.url"}, "https://myurl.com/some/path/"]},
1476 |                       {"glob": [{"var": "frontmatter.url-glob"}, "https://myurl.com/some/path/"]}
1477 |                     ]
1478 |                   }
1479 |               find_by_frontmatter_value:
1480 |                 summary: "Find notes having a certain frontmatter field value."
1481 |                 value: |
1482 |                   {
1483 |                     "==": [
1484 |                       {"var": "frontmatter.myField"},
1485 |                       "myValue"
1486 |                     ]
1487 |                   }
1488 |               find_by_tag:
1489 |                 summary: "Find notes having a certain tag"
1490 |                 value: |
1491 |                   {
1492 |                     "in": [
1493 |                       "myTag",
1494 |                       {"var": "tags"}
1495 |                     ]
1496 |                   }
1497 |             schema:
1498 |               externalDocs:
1499 |                 url: "https://jsonlogic.com/operations.html"
1500 |               type: "object"
1501 |         required: true
1502 |       responses:
1503 |         "200":
1504 |           content:
1505 |             application/json:
1506 |               schema:
1507 |                 items:
1508 |                   properties:
1509 |                     filename:
1510 |                       description: "Path to the matching file"
1511 |                       type: "string"
1512 |                     result:
1513 |                       oneOf:
1514 |                         - type: "string"
1515 |                         - type: "number"
1516 |                         - type: "array"
1517 |                         - type: "object"
1518 |                         - type: "boolean"
1519 |                   required:
1520 |                     - "filename"
1521 |                     - "result"
1522 |                   type: "object"
1523 |                 type: "array"
1524 |           description: "Success"
1525 |         "400":
1526 |           content:
1527 |             application/json:
1528 |               schema:
1529 |                 "$ref": "#/components/schemas/Error"
1530 |           description: |
1531 |             Bad request.  Make sure you have specified an acceptable
1532 |             Content-Type for your search query.
1533 |       summary: |
1534 |         Search for documents matching a specified search query
1535 |       tags:
1536 |         - "Search"
1537 |   /search/simple/:
1538 |     post:
1539 |       parameters:
1540 |         - description: "Your search query"
1541 |           in: "query"
1542 |           name: "query"
1543 |           required: true
1544 |           schema:
1545 |             type: "string"
1546 |         - description: "How much context to return around the matching string"
1547 |           in: "query"
1548 |           name: "contextLength"
1549 |           required: false
1550 |           schema:
1551 |             default: 100
1552 |             type: "number"
1553 |       responses:
1554 |         "200":
1555 |           content:
1556 |             application/json:
1557 |               schema:
1558 |                 items:
1559 |                   properties:
1560 |                     filename:
1561 |                       description: "Path to the matching file"
1562 |                       type: "string"
1563 |                     matches:
1564 |                       items:
1565 |                         properties:
1566 |                           context:
1567 |                             type: "string"
1568 |                           match:
1569 |                             properties:
1570 |                               end:
1571 |                                 type: "number"
1572 |                               start:
1573 |                                 type: "number"
1574 |                             required:
1575 |                               - "start"
1576 |                               - "end"
1577 |                             type: "object"
1578 |                         required:
1579 |                           - "match"
1580 |                           - "context"
1581 |                         type: "object"
1582 |                       type: "array"
1583 |                     score:
1584 |                       type: "number"
1585 |                   type: "object"
1586 |                 type: "array"
1587 |           description: "Success"
1588 |       summary: |
1589 |         Search for documents matching a specified text query
1590 |       tags:
1591 |         - "Search"
1592 |   /vault/:
1593 |     get:
1594 |       description: |
1595 |         Lists files in the root directory of your vault.
1596 |         
1597 |         Note: that this is exactly the same API endpoint as the below "List files that exist in the specified directory." and exists here only due to a quirk of this particular interactive tool.
1598 |       responses:
1599 |         "200":
1600 |           content:
1601 |             application/json:
1602 |               example:
1603 |                 files:
1604 |                   - "mydocument.md"
1605 |                   - "somedirectory/"
1606 |               schema:
1607 |                 properties:
1608 |                   files:
1609 |                     items:
1610 |                       type: "string"
1611 |                     type: "array"
1612 |                 type: "object"
1613 |           description: "Success"
1614 |         "404":
1615 |           content:
1616 |             application/json:
1617 |               schema:
1618 |                 "$ref": "#/components/schemas/Error"
1619 |           description: "Directory does not exist"
1620 |       summary: |
1621 |         List files that exist in the root of your vault.
1622 |       tags:
1623 |         - "Vault Directories"
1624 |   "/vault/{filename}":
1625 |     delete:
1626 |       parameters:
1627 |         - description: |
1628 |             Path to the relevant file (relative to your vault root).
1629 |           in: "path"
1630 |           name: "filename"
1631 |           required: true
1632 |           schema:
1633 |             format: "path"
1634 |             type: "string"
1635 |       responses:
1636 |         "204":
1637 |           description: "Success"
1638 |         "404":
1639 |           content:
1640 |             application/json:
1641 |               schema:
1642 |                 "$ref": "#/components/schemas/Error"
1643 |           description: "File does not exist."
1644 |         "405":
1645 |           content:
1646 |             application/json:
1647 |               schema:
1648 |                 "$ref": "#/components/schemas/Error"
1649 |           description: |
1650 |             Your path references a directory instead of a file; this request method is valid only for updating files.
1651 |       summary: |
1652 |         Delete a particular file in your vault.
1653 |       tags:
1654 |         - "Vault Files"
1655 |     get:
1656 |       description: |
1657 |         Returns the content of the file at the specified path in your vault should the file exist.
1658 |         
1659 |         If you specify the header `Accept: application/vnd.olrapi.note+json`, will return a JSON representation of your note including parsed tag and frontmatter data as well as filesystem metadata.  See "responses" below for details.
1660 |       parameters:
1661 |         - description: |
1662 |             Path to the relevant file (relative to your vault root).
1663 |           in: "path"
1664 |           name: "filename"
1665 |           required: true
1666 |           schema:
1667 |             format: "path"
1668 |             type: "string"
1669 |       responses:
1670 |         "200":
1671 |           content:
1672 |             "application/vnd.olrapi.note+json":
1673 |               schema:
1674 |                 "$ref": "#/components/schemas/NoteJson"
1675 |             text/markdown:
1676 |               schema:
1677 |                 example: |
1678 |                   # This is my document
1679 |                   
1680 |                   something else here
1681 |                 type: "string"
1682 |           description: "Success"
1683 |         "404":
1684 |           description: "File does not exist"
1685 |       summary: |
1686 |         Return the content of a single file in your vault.
1687 |       tags:
1688 |         - "Vault Files"
1689 |     patch:
1690 |       description: |
1691 |         Inserts content into an existing note relative to a heading, block refeerence, or frontmatter field within that document.
1692 |         
1693 |         Allows you to modify the content relative to a heading, block reference, or frontmatter field in your document.
1694 |         
1695 |         Note that this API was changed in Version 3.0 of this extension and the earlier PATCH API is now deprecated. Requests made using the previous version of this API will continue to work until Version 4.0 is released.  See https://github.com/coddingtonbear/obsidian-local-rest-api/wiki/Changes-to-PATCH-requests-between-versions-2.0-and-3.0 for more details and migration instructions.
1696 |         
1697 |         # Examples
1698 |         
1699 |         All of the below examples assume you have a document that looks like
1700 |         this:
1701 |         
1702 |         ```markdown
1703 |         ---
1704 |         alpha: 1
1705 |         beta: test
1706 |         delta:
1707 |         zeta: 1
1708 |         yotta: 1
1709 |         gamma:
1710 |         - one
1711 |         - two
1712 |         ---
1713 |         
1714 |         # Heading 1
1715 |         
1716 |         This is the content for heading one
1717 |         
1718 |         Also references some [[#^484ef2]]
1719 |         
1720 |         ## Subheading 1:1
1721 |         Content for Subheading 1:1
1722 |         
1723 |         ### Subsubheading 1:1:1
1724 |         
1725 |         ### Subsubheading 1:1:2
1726 |         
1727 |         Testing how block references work for a table.[[#^2c7cfa]]
1728 |         Some content for Subsubheading 1:1:2
1729 |         
1730 |         More random text.
1731 |         
1732 |         ^2d9b4a
1733 |         
1734 |         ## Subheading 1:2
1735 |         
1736 |         Content for Subheading 1:2.
1737 |         
1738 |         some content with a block reference ^484ef2
1739 |         
1740 |         ## Subheading 1:3
1741 |         | City         | Population |
1742 |         | ------------ | ---------- |
1743 |         | Seattle, WA  | 8          |
1744 |         | Portland, OR | 4          |
1745 |         
1746 |         ^2c7cfa
1747 |         ```
1748 |         
1749 |         ## Append Content Below a Heading
1750 |         
1751 |         If you wanted to append the content "Hello" below "Subheading 1:1:1" under "Heading 1",
1752 |         you could send a request with the following headers:
1753 |         
1754 |         - `Operation`: `append`
1755 |         - `Target-Type`: `heading`
1756 |         - `Target`: `Heading 1::Subheading 1:1:1`
1757 |         - with the request body: `Hello`
1758 |         
1759 |         The above would work just fine for `prepend` or `replace`, too, of course,
1760 |         but with different results.
1761 |         
1762 |         ## Append Content to a Block Reference
1763 |         
1764 |         If you wanted to append the content "Hello" below the block referenced by
1765 |         "2d9b4a" above ("More random text."), you could send the following headers:
1766 |         
1767 |         - `Operation`: `append`
1768 |         - `Target-Type`: `block`
1769 |         - `Target`: `2d9b4a`
1770 |         - with the request body: `Hello`
1771 |         
1772 |         The above would work just fine for `prepend` or `replace`, too, of course,
1773 |         but with different results.
1774 |         
1775 |         ## Add a Row to a Table Referenced by a Block Reference
1776 |         
1777 |         If you wanted to add a new city ("Chicago, IL") and population ("16") pair to the table above
1778 |         referenced by the block reference `2c7cfa`, you could send the following
1779 |         headers:
1780 |         
1781 |         - `Operation`: `append`
1782 |         - `TargetType`: `block`
1783 |         - `Target`: `2c7cfa`
1784 |         - `Content-Type`: `application/json`
1785 |         - with the request body: `[["Chicago, IL", "16"]]`
1786 |         
1787 |         The use of a `Content-Type` of `application/json` allows the API
1788 |         to infer that member of your array represents rows and columns of your
1789 |         to append to the referenced table.  You can of course just use a
1790 |         `Content-Type` of `text/markdown`, but in such a case you'll have to
1791 |         format your table row manually instead of letting the library figure
1792 |         it out for you.
1793 |         
1794 |         You also have the option of using `prepend` (in which case, your new
1795 |         row would be the first -- right below the table heading) or `replace` (in which
1796 |         case all rows except the table heading would be replaced by the new row(s)
1797 |         you supplied).
1798 |         
1799 |         ## Setting a Frontmatter Field
1800 |         
1801 |         If you wanted to set the frontmatter field `alpha` to `2`, you could
1802 |         send the following headers:
1803 |         
1804 |         - `Operation`: `replace`
1805 |         - `TargetType`: `frontmatter`
1806 |         - `Target`: `beep`
1807 |         - with the request body `2`
1808 |         
1809 |         If you're setting a frontmatter field that might not already exist
1810 |         you may want to use the `Create-Target-If-Missing` header so the
1811 |         new frontmatter field is created and set to your specified value
1812 |         if it doesn't already exist.
1813 |         
1814 |         You may find using a `Content-Type` of `application/json` to be
1815 |         particularly useful in the case of frontmatter since frontmatter
1816 |         fields' values are JSON data, and the API can be smarter about
1817 |         interpreting yoru `prepend` or `append` requests if you specify
1818 |         your data as JSON (particularly when appending, for example,
1819 |         list items).
1820 |       parameters:
1821 |         - description: "Patch operation to perform"
1822 |           in: "header"
1823 |           name: "Operation"
1824 |           required: true
1825 |           schema:
1826 |             enum:
1827 |               - "append"
1828 |               - "prepend"
1829 |               - "replace"
1830 |             type: "string"
1831 |         - description: "Type of target to patch"
1832 |           in: "header"
1833 |           name: "Target-Type"
1834 |           required: true
1835 |           schema:
1836 |             enum:
1837 |               - "heading"
1838 |               - "block"
1839 |               - "frontmatter"
1840 |             type: "string"
1841 |         - description: "Delimiter to use for nested targets (i.e. Headings)"
1842 |           in: "header"
1843 |           name: "Target-Delimiter"
1844 |           required: false
1845 |           schema:
1846 |             default: "::"
1847 |             type: "string"
1848 |         - description: |
1849 |             Target to patch; this value can be URL-Encoded and *must*
1850 |             be URL-Encoded if it includes non-ASCII characters.
1851 |           in: "header"
1852 |           name: "Target"
1853 |           required: true
1854 |           schema:
1855 |             type: "string"
1856 |         - description: "Trim whitespace from Target before applying patch?"
1857 |           in: "header"
1858 |           name: "Trim-Target-Whitespace"
1859 |           required: false
1860 |           schema:
1861 |             default: "false"
1862 |             enum:
1863 |               - "true"
1864 |               - "false"
1865 |             type: "string"
1866 |         - description: |
1867 |             Path to the relevant file (relative to your vault root).
1868 |           in: "path"
1869 |           name: "filename"
1870 |           required: true
1871 |           schema:
1872 |             format: "path"
1873 |             type: "string"
1874 |       requestBody:
1875 |         content:
1876 |           application/json:
1877 |             schema:
1878 |               example: "['one', 'two']"
1879 |               type: "string"
1880 |           text/markdown:
1881 |             schema:
1882 |               example: |
1883 |                 # This is my document
1884 |                 
1885 |                 something else here
1886 |               type: "string"
1887 |         description: "Content you would like to insert."
1888 |         required: true
1889 |       responses:
1890 |         "200":
1891 |           description: "Success"
1892 |         "400":
1893 |           content:
1894 |             application/json:
1895 |               schema:
1896 |                 "$ref": "#/components/schemas/Error"
1897 |           description: "Bad Request; see response message for details."
1898 |         "404":
1899 |           content:
1900 |             application/json:
1901 |               schema:
1902 |                 "$ref": "#/components/schemas/Error"
1903 |           description: "Does not exist"
1904 |         "405":
1905 |           content:
1906 |             application/json:
1907 |               schema:
1908 |                 "$ref": "#/components/schemas/Error"
1909 |           description: |
1910 |             Your path references a directory instead of a file; this request method is valid only for updating files.
1911 |       summary: |
1912 |         Insert content into an existing note in Obsidian relative to a heading, block reference, or frontmatter field within that document.
1913 |       tags:
1914 |         - "Vault Files"
1915 |     post:
1916 |       description: |
1917 |         Appends content to the end of an existing note. If the specified file does not yet exist, it will be created as an empty file.
1918 |         
1919 |         If you would like to insert text relative to a particular heading, block reference, or frontmatter field instead of appending to the end of the file, see 'patch'.
1920 |       parameters:
1921 |         - description: |
1922 |             Path to the relevant file (relative to your vault root).
1923 |           in: "path"
1924 |           name: "filename"
1925 |           required: true
1926 |           schema:
1927 |             format: "path"
1928 |             type: "string"
1929 |       requestBody:
1930 |         content:
1931 |           text/markdown:
1932 |             schema:
1933 |               example: |
1934 |                 # This is my document
1935 |                 
1936 |                 something else here
1937 |               type: "string"
1938 |         description: "Content you would like to append."
1939 |         required: true
1940 |       responses:
1941 |         "204":
1942 |           description: "Success"
1943 |         "400":
1944 |           content:
1945 |             application/json:
1946 |               schema:
1947 |                 "$ref": "#/components/schemas/Error"
1948 |           description: "Bad Request"
1949 |         "405":
1950 |           content:
1951 |             application/json:
1952 |               schema:
1953 |                 "$ref": "#/components/schemas/Error"
1954 |           description: |
1955 |             Your path references a directory instead of a file; this request method is valid only for updating files.
1956 |       summary: |
1957 |         Append content to a new or existing file.
1958 |       tags:
1959 |         - "Vault Files"
1960 |     put:
1961 |       description: |
1962 |         Creates a new file in your vault or updates the content of an existing one if the specified file already exists.
1963 |       parameters:
1964 |         - description: |
1965 |             Path to the relevant file (relative to your vault root).
1966 |           in: "path"
1967 |           name: "filename"
1968 |           required: true
1969 |           schema:
1970 |             format: "path"
1971 |             type: "string"
1972 |       requestBody:
1973 |         content:
1974 |           "*/*":
1975 |             schema:
1976 |               type: "string"
1977 |           text/markdown:
1978 |             schema:
1979 |               example: |
1980 |                 # This is my document
1981 |                 
1982 |                 something else here
1983 |               type: "string"
1984 |         description: "Content of the file you would like to upload."
1985 |         required: true
1986 |       responses:
1987 |         "204":
1988 |           description: "Success"
1989 |         "400":
1990 |           content:
1991 |             application/json:
1992 |               schema:
1993 |                 "$ref": "#/components/schemas/Error"
1994 |           description: |
1995 |             Incoming file could not be processed.  Make sure you have specified a reasonable file name, and make sure you have set a reasonable 'Content-Type' header; if you are uploading a note, 'text/markdown' is likely the right choice.
1996 |         "405":
1997 |           content:
1998 |             application/json:
1999 |               schema:
2000 |                 "$ref": "#/components/schemas/Error"
2001 |           description: |
2002 |             Your path references a directory instead of a file; this request method is valid only for updating files.
2003 |       summary: |
2004 |         Create a new file in your vault or update the content of an existing one.
2005 |       tags:
2006 |         - "Vault Files"
2007 |   "/vault/{pathToDirectory}/":
2008 |     get:
2009 |       parameters:
2010 |         - description: |
2011 |             Path to list files from (relative to your vault root).  Note that empty directories will not be returned.
2012 |             
2013 |             Note: this particular interactive tool requires that you provide an argument for this field, but the API itself will allow you to list the root folder of your vault. If you would like to try listing content in the root of your vault using this interactive tool, use the above "List files that exist in the root of your vault" form above.
2014 |           in: "path"
2015 |           name: "pathToDirectory"
2016 |           required: true
2017 |           schema:
2018 |             format: "path"
2019 |             type: "string"
2020 |       responses:
2021 |         "200":
2022 |           content:
2023 |             application/json:
2024 |               example:
2025 |                 files:
2026 |                   - "mydocument.md"
2027 |                   - "somedirectory/"
2028 |               schema:
2029 |                 properties:
2030 |                   files:
2031 |                     items:
2032 |                       type: "string"
2033 |                     type: "array"
2034 |                 type: "object"
2035 |           description: "Success"
2036 |         "404":
2037 |           content:
2038 |             application/json:
2039 |               schema:
2040 |                 "$ref": "#/components/schemas/Error"
2041 |           description: "Directory does not exist"
2042 |       summary: |
2043 |         List files that exist in the specified directory.
2044 |       tags:
2045 |         - "Vault Directories"
2046 | security:
2047 |   - apiKeyAuth: []
2048 | servers:
2049 |   - description: "HTTPS (Secure Mode)"
2050 |     url: "https://{host}:{port}"
2051 |     variables:
2052 |       host:
2053 |         default: "127.0.0.1"
2054 |         description: "Binding host"
2055 |       port:
2056 |         default: "27124"
2057 |         description: "HTTPS port"
2058 |   - description: "HTTP (Insecure Mode)"
2059 |     url: "http://{host}:{port}"
2060 |     variables:
2061 |       host:
2062 |         default: "127.0.0.1"
2063 |         description: "Binding host"
2064 |       port:
2065 |         default: "27123"
2066 |         description: "HTTP port"
2067 | 
```