using-obsidian-api
This rule provides instruction for interacting with the Obsidian API
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Obsidian Bases API
Main types
-
BasesEntry: Represents a note/entry with properties -
BasesViewConfig: View configuration (user options) -
BasesPropertyId: Property identifier (string) -
App: Obsidian application instance -
TFile: Obsidian file
Data access
// Get property value
const value = entry.getValue(propertyId);
// Get property display name
const displayName = config.getDisplayName(propertyId);
// Get image (resolves internal and external paths)
import { getResourcePath } from "@/lib/obsidian/link";
const imageSrc = getResourcePath(app, imageUrl, entry.file.path);
Context
The Obsidian context exposes shared Obsidian variables.
const { app, component, containerEl, isEmbedded } = useObsidian();
Available hooks
Define and use reusable hooks to wrap Obsidian features in src/hooks to simplify the workflow and increase reusability
// Get config value with default
const layout = useConfigValue<"vertical" | "horizontal">("layout", "vertical");
// Get entry data
const entry = useEntry(entryId);
// Get entry property
const property = useEntryProperty(entryId, propertyId);
// Get entry title
const title = useEntryTitle(entryId);
// Handler to open entry
const handleOpen = useEntryOpen(entryId);
// Handler for hover with preview
const handleHover = useEntryHover(entryId, linkRef);
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-03-11
- Index updated
- 2026-03-11
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!