Skip to content

Commands Resource

CommandsResource(client)

Bases: BaseResource

List and execute Obsidian commands.

Source code in src/aiobsidian/rest/_base.py
def __init__(self, client: ObsidianClient) -> None:
    self._client = client

list() async

List all available Obsidian commands.

Returns:

Type Description
list[Command]

A list of Command objects with id and name fields.

Source code in src/aiobsidian/rest/commands.py
async def list(self) -> list[Command]:
    """List all available Obsidian commands.

    Returns:
        A list of `Command` objects with `id` and `name` fields.
    """
    response = await self._client.request("GET", f"{self._BASE_URL}/")
    data = response.json()
    return [Command.model_validate(c) for c in data["commands"]]

execute(command_id) async

Execute an Obsidian command by its ID.

Parameters:

Name Type Description Default
command_id str

The unique identifier of the command (e.g. "editor:toggle-bold").

required
Source code in src/aiobsidian/rest/commands.py
async def execute(self, command_id: str) -> None:
    """Execute an Obsidian command by its ID.

    Args:
        command_id: The unique identifier of the command
            (e.g. `"editor:toggle-bold"`).
    """
    await self._client.request("POST", f"{self._BASE_URL}/{command_id}/")