Skip to content

CLI Links Resource

CLILinksResource(cli)

Bases: BaseCLIResource

CLI resource for link and backlink operations.

Attributes:

Name Type Description
_cli

Reference to the parent ObsidianCLI instance.

Source code in src/aiobsidian/cli/_base.py
def __init__(self, cli: ObsidianCLI) -> None:
    self._cli = cli

outgoing(path) async

Get outgoing links from a note.

Parameters:

Name Type Description Default
path str

Path or name of the note.

required

Returns:

Type Description
list[dict[str, Any]]

List of outgoing link objects.

Source code in src/aiobsidian/cli/links.py
async def outgoing(self, path: str) -> list[dict[str, Any]]:
    """Get outgoing links from a note.

    Args:
        path: Path or name of the note.

    Returns:
        List of outgoing link objects.
    """
    output = await self._cli._execute("links", params={"file": path})
    result: list[dict[str, Any]] = json.loads(output)
    return result

incoming(path, *, counts=False) async

Get backlinks (incoming links) to a note.

Parameters:

Name Type Description Default
path str

Path or name of the note.

required
counts bool

If True, include reference counts.

False

Returns:

Type Description
list[dict[str, Any]]

List of backlink objects.

Source code in src/aiobsidian/cli/links.py
async def incoming(
    self, path: str, *, counts: bool = False
) -> list[dict[str, Any]]:
    """Get backlinks (incoming links) to a note.

    Args:
        path: Path or name of the note.
        counts: If ``True``, include reference counts.

    Returns:
        List of backlink objects.
    """
    flags = ["--counts"] if counts else None
    output = await self._cli._execute(
        "backlinks", params={"file": path}, flags=flags
    )
    result: list[dict[str, Any]] = json.loads(output)
    return result

unresolved() async

Get all unresolved (broken) links in the vault.

Returns:

Type Description
list[dict[str, Any]]

List of unresolved link objects.

Source code in src/aiobsidian/cli/links.py
async def unresolved(self) -> list[dict[str, Any]]:
    """Get all unresolved (broken) links in the vault.

    Returns:
        List of unresolved link objects.
    """
    output = await self._cli._execute("unresolved")
    result: list[dict[str, Any]] = json.loads(output)
    return result

orphans() async

Get orphan notes (notes with no incoming or outgoing links).

Returns:

Type Description
list[dict[str, Any]]

List of orphan note objects.

Source code in src/aiobsidian/cli/links.py
async def orphans(self) -> list[dict[str, Any]]:
    """Get orphan notes (notes with no incoming or outgoing links).

    Returns:
        List of orphan note objects.
    """
    output = await self._cli._execute("orphans")
    result: list[dict[str, Any]] = json.loads(output)
    return result

deadends() async

Get notes with no outgoing links (dead ends).

Returns:

Type Description
list[dict[str, Any]]

List of dead-end note objects.

Source code in src/aiobsidian/cli/links.py
async def deadends(self) -> list[dict[str, Any]]:
    """Get notes with no outgoing links (dead ends).

    Returns:
        List of dead-end note objects.
    """
    output = await self._cli._execute("deadends")
    result: list[dict[str, Any]] = json.loads(output)
    return result