Skip to content

Open Resource

OpenResource(client)

Bases: BaseResource

Open files in the Obsidian UI.

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

open(filename, *, new_leaf=False) async

Open a file in Obsidian.

await client.open.open("Notes/hello.md")

Parameters:

Name Type Description Default
filename str

Path to the file to open, relative to the vault root.

required
new_leaf bool

If True, open the file in a new tab/pane.

False
Source code in src/aiobsidian/rest/open.py
async def open(
    self,
    filename: str,
    *,
    new_leaf: bool = False,
) -> None:
    """Open a file in Obsidian.

    ```python
    await client.open.open("Notes/hello.md")
    ```

    Args:
        filename: Path to the file to open, relative to the vault root.
        new_leaf: If `True`, open the file in a new tab/pane.
    """
    params: dict[str, str] = {}
    if new_leaf:
        params["newLeaf"] = "true"
    await self._client.request(
        "POST",
        f"{self._BASE_URL}/{filename}",
        params=params,
    )