ObsidianClient (REST)¶
ObsidianClient(api_key, *, host=DEFAULT_HOST, port=DEFAULT_PORT, scheme=DEFAULT_SCHEME, timeout=DEFAULT_TIMEOUT, verify_ssl=False, http_client=None)
¶
Async client for the Obsidian Local REST API.
Provides access to vault files, the active file, periodic notes, commands, search, and system information through resource properties.
Can be used as an async context manager:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
API key from the Local REST API plugin settings. |
required |
host
|
str
|
Hostname of the Obsidian REST API server. |
DEFAULT_HOST
|
port
|
int
|
Port number of the Obsidian REST API server. |
DEFAULT_PORT
|
scheme
|
str
|
URL scheme ( |
DEFAULT_SCHEME
|
timeout
|
float
|
Request timeout in seconds. |
DEFAULT_TIMEOUT
|
verify_ssl
|
bool
|
Whether to verify SSL certificates. Defaults to
|
False
|
http_client
|
AsyncClient | None
|
Optional pre-configured |
None
|
Source code in src/aiobsidian/_client.py
vault
cached
property
¶
Access vault file operations (read, create, append, patch, delete, list).
active
cached
property
¶
Access the currently active file in Obsidian.
periodic
cached
property
¶
Access periodic notes (daily, weekly, monthly, quarterly, yearly).
commands
cached
property
¶
List and execute Obsidian commands.
search
cached
property
¶
Search vault content (simple text, Dataview DQL, JsonLogic).
open
cached
property
¶
Open files in the Obsidian UI.
system
cached
property
¶
Access server status and OpenAPI specification.
request(method, path, *, content=None, json=None, headers=None, params=None)
async
¶
Send an HTTP request to the Obsidian REST API.
This is a low-level method used internally by resource classes.
Prefer using the resource methods (e.g. client.vault.get())
for typical operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
HTTP method (GET, POST, PUT, PATCH, DELETE). |
required |
path
|
str
|
API endpoint path (e.g. |
required |
content
|
str | bytes | None
|
Raw request body. |
None
|
json
|
Any
|
JSON-serializable request body. |
None
|
headers
|
dict[str, Any] | None
|
Additional HTTP headers. |
None
|
params
|
dict[str, Any] | None
|
URL query parameters. |
None
|
Returns:
| Type | Description |
|---|---|
Response
|
The |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If the API key is invalid (HTTP 401). |
NotFoundError
|
If the resource is not found (HTTP 404). |
APIError
|
For any other HTTP error (status >= 400). |
Source code in src/aiobsidian/_client.py
aclose()
async
¶
Close the underlying HTTP client.
If an external httpx.AsyncClient was provided to the
constructor, this method is a no-op — the caller is
responsible for closing it.