logseqProvide commands for interacting with a local Logseq instance through its Plugin API. Use for creating pages, inserting blocks, querying the graph database, managing tasks, retrieving content, or automating workflows in Logseq. Only works with a locally running instance with the API enabled; default port or set path expected for [$API accessible skill].
Install via ClawdBot CLI:
clawdbot install juanirm/logseqInteract with your local Logseq instance through its JavaScript Plugin API. This skill enables reading, writing, querying, and automating workflows in your Logseq graph.
Logseq must be running locally with a plugin that exposes the API. The standard way is:
logseq API via HTTP (e.g., via a custom plugin or localhost endpoint)@logseq/libs package to script against the running Logseq instanceThe API is primarily designed for in-browser plugins, so accessing it from external scripts requires a bridge/proxy.
The Logseq Plugin API is organized into these main proxies:
logseq.AppApplication-level operations: getting app info, user configs, current graph, commands, UI state, external links.
Key methods:
getInfo() - Get app version and infogetUserConfigs() - Get user preferences (theme, format, language, etc.)getCurrentGraph() - Get current graph info (name, path, URL)registerCommand(type, opts, action) - Register custom commandspushState(route, params, query) - Navigate to routeslogseq.EditorBlock and page editing operations: creating, updating, moving, querying content.
Key methods:
getBlock(uuid) - Get block by UUIDgetCurrentPage() - Get current page entitygetCurrentPageBlocksTree() - Get all blocks on current pagegetPageBlocksTree(page) - Get all blocks for a specific pageinsertBlock(target, content, opts) - Insert a new blockupdateBlock(uuid, content) - Update block contentcreatePage(pageName, properties, opts) - Create a new pagedeletePage(pageName) - Delete a pagegetPageLinkedReferences(page) - Get backlinks to a pageregisterSlashCommand(tag, action) - Add custom slash commandslogseq.DBDatabase queries using Datalog.
Key methods:
q(query, ...inputs) - Run Datalog querydatascriptQuery(query, ...inputs) - Direct Datascript querylogseq.UIUI operations: messages, dialogs, main UI visibility.
Key methods:
showMsg(content, status) - Show toast notificationqueryElementById(id) - Query DOM elementslogseq.GitGit operations for the current graph.
Key methods:
execCommand(args) - Execute git commandlogseq.AssetsAsset management.
Key methods:
listFilesOfCurrentGraph(path) - List files in graph// Get current page
const page = await logseq.Editor.getCurrentPage();
// Get all blocks on a page
const blocks = await logseq.Editor.getPageBlocksTree('Daily Notes');
// Get a specific block
const block = await logseq.Editor.getBlock('block-uuid-here');
// Query with Datalog
const results = await logseq.DB.q(`
[:find (pull ?b [*])
:where [?b :block/marker "TODO"]]
`);
// Create a new page
await logseq.Editor.createPage('Project Notes', {
tags: 'project',
status: 'active'
}, { redirect: false });
// Insert a block
const block = await logseq.Editor.insertBlock(
'target-block-uuid',
'- New task item',
{ before: false, sibling: true }
);
// Update a block
await logseq.Editor.updateBlock('block-uuid', 'Updated content');
// Batch insert multiple blocks
const blocks = [
{ content: 'First item' },
{ content: 'Second item', children: [
{ content: 'Nested item' }
]}
];
await logseq.Editor.insertBatchBlock('parent-uuid', blocks, { sibling: false });
// Find all TODO items
const todos = await logseq.DB.q(`
[:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[(contains? #{"TODO" "DOING"} ?marker)]]
`);
// Mark task as DONE
await logseq.Editor.updateBlock('task-uuid', 'DONE Task content');
// Get tasks on current page
const page = await logseq.Editor.getCurrentPage();
const blocks = await logseq.Editor.getPageBlocksTree(page.name);
const tasks = blocks.filter(b => b.marker === 'TODO' || b.marker === 'DOING');
// Navigate to a page
logseq.App.pushState('page', { name: 'Project Notes' });
// Show notification
logseq.UI.showMsg('â
Task completed!', 'success');
// Get app config
const configs = await logseq.App.getUserConfigs();
console.log('Theme:', configs.preferredThemeMode);
console.log('Format:', configs.preferredFormat);
Since Logseq's Plugin API is browser-based, you have several options:
Create a minimal Logseq plugin that exposes API calls via HTTP:
// In Logseq plugin (index.js)
logseq.ready(() => {
// Expose API endpoints
logseq.provideModel({
async handleAPICall({ method, args }) {
return await logseq.Editor[method](...args);
}
});
});
// Then call from external script via HTTP POST
For automation scripts, use the @logseq/libs package:
npm install @logseq/libs
Note: This requires a running Logseq instance and proper connection setup.
Develop a full Logseq plugin following the plugin samples at:
https://github.com/logseq/logseq-plugin-samples
For complete API documentation, see:
references/api-types.md (extracted from @logseq/libs){
id: number, // Entity ID
uuid: string, // Block UUID
content: string, // Block content
format: 'markdown' | 'org',
page: { id: number }, // Parent page
parent: { id: number }, // Parent block
left: { id: number }, // Previous sibling
properties: {}, // Block properties
marker?: string, // TODO/DOING/DONE
children?: [] // Child blocks
}
{
id: number,
uuid: string,
name: string, // Page name (lowercase)
originalName: string, // Original case
'journal?': boolean,
properties: {},
journalDay?: number, // YYYYMMDD for journals
}
null if entity doesn't existinsertBatchBlock for multiple insertsblock.properties.propertyNamejournalDay format (YYYYMMDD) not date strings- for bullets, Org uses *prop::) and org (:PROPERTIES:)Generated Mar 1, 2026
Automate daily note creation and task extraction from emails or meeting notes. For example, a script can parse emails for action items, create a Logseq page for each project, and insert TODO blocks with deadlines. This reduces manual entry and ensures tasks are tracked in the knowledge graph.
Collect and organize research data from external sources like APIs or web scraping into Logseq. A researcher can use this to automatically populate pages with citations, summaries, and linked references, enabling quick querying and analysis of literature or experimental results.
Build a custom dashboard within Logseq to track project progress, deadlines, and team tasks. By querying the graph for TODO and DOING markers, it generates reports and sends notifications, helping managers monitor workflows without switching tools.
Streamline content creation by automating outline generation and linking ideas across pages. For instance, a writer can use scripts to pull draft blocks, organize them into structured articles, and export to formats like Markdown, enhancing efficiency in blogging or documentation.
Integrate health data from wearables or apps into Logseq for personalized tracking. A user can automate daily logs of exercise, diet, and mood, with queries to visualize trends and set reminders, supporting wellness goals through data-driven insights.
Offer a basic Logseq plugin for free with core automation features, then charge for advanced integrations like API bridges or premium templates. Revenue comes from subscriptions or one-time purchases, targeting power users who need enhanced workflow automation.
Provide consulting services to businesses or individuals for custom Logseq automation solutions. This includes developing tailored scripts for specific use cases, such as data migration or reporting tools, with revenue from project-based fees or hourly rates.
Create and sell courses, workshops, or detailed guides on using the Logseq API for automation. Revenue is generated through course sales, webinar tickets, or premium documentation access, catering to users looking to upskill in knowledge management.
đŦ Integration Tip
Ensure Logseq is running locally with an API bridge plugin enabled, and test scripts incrementally to avoid data loss by backing up the graph first.
Work with Obsidian vaults (plain Markdown notes) and automate via obsidian-cli.
Create, search, and manage Bear notes via grizzly CLI.
Track water and sleep with JSON file storage
Notion API for creating and managing pages, databases, and blocks.
Smart ClawdBot documentation access with local search index, cached snippets, and on-demand fetch. Token-efficient and freshness-aware.
Work with Obsidian vaults as a knowledge base. Features: fuzzy/phonetic search across all notes, auto-folder detection for new notes, create/read/edit notes with frontmatter, manage tags and wikilinks. Use when: querying knowledge base, saving notes/documents, editing existing notes by user instructions.