client

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client communicates with the Logseq HTTP API.

func New

func New(apiURL, token string) *Client

New creates a new Logseq API client. Reads LOGSEQ_API_URL and LOGSEQ_API_TOKEN from environment if not provided.

func (*Client) AppendBlockInPage

func (c *Client) AppendBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)

AppendBlockInPage adds a block at the end of a page.

func (*Client) CreatePage

func (c *Client) CreatePage(ctx context.Context, name string, properties map[string]any, opts map[string]any) (*types.PageEntity, error)

CreatePage creates a new page with optional properties.

func (*Client) DSLQuery

func (c *Client) DSLQuery(ctx context.Context, dsl string) (json.RawMessage, error)

DSLQuery executes a Logseq DSL query.

func (*Client) DatascriptQuery

func (c *Client) DatascriptQuery(ctx context.Context, query string, inputs ...any) (json.RawMessage, error)

DatascriptQuery executes a Datalog query against the Logseq database.

func (*Client) DeletePage

func (c *Client) DeletePage(ctx context.Context, name string) error

DeletePage removes a page by name.

func (*Client) GetAllPages

func (c *Client) GetAllPages(ctx context.Context) ([]types.PageEntity, error)

GetAllPages returns all pages in the graph.

func (*Client) GetAllTags

func (c *Client) GetAllTags(ctx context.Context) ([]types.PageEntity, error)

GetAllTags returns all tags in the graph.

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, uuid string, opts ...map[string]any) (*types.BlockEntity, error)

GetBlock returns a block by UUID.

func (*Client) GetBlockProperties

func (c *Client) GetBlockProperties(ctx context.Context, uuid string) (map[string]any, error)

GetBlockProperties returns all properties for a block.

func (*Client) GetCurrentGraph

func (c *Client) GetCurrentGraph(ctx context.Context) (*GraphInfo, error)

GetCurrentGraph returns the name and filesystem path of the current graph.

func (*Client) GetPage

func (c *Client) GetPage(ctx context.Context, nameOrID any) (*types.PageEntity, error)

GetPage returns a page by name or ID.

func (*Client) GetPageBlocksTree

func (c *Client) GetPageBlocksTree(ctx context.Context, nameOrID any) ([]types.BlockEntity, error)

GetPageBlocksTree returns the full block tree for a page.

func (*Client) GetPageLinkedReferences

func (c *Client) GetPageLinkedReferences(ctx context.Context, nameOrID any) (json.RawMessage, error)

GetPageLinkedReferences returns pages that link to this page, with the blocks containing the links.

func (*Client) GetPageProperties

func (c *Client) GetPageProperties(ctx context.Context, nameOrID any) (map[string]any, error)

GetPageProperties returns all properties for a page.

func (*Client) GetPagesFromNamespace

func (c *Client) GetPagesFromNamespace(ctx context.Context, namespace string) ([]types.PageEntity, error)

GetPagesFromNamespace returns all pages in a namespace.

func (*Client) HasDataScript added in v0.3.0

func (c *Client) HasDataScript()

HasDataScript marks the Logseq client as supporting DataScript queries. Implements backend.HasDataScript.

func (*Client) InsertBatchBlock

func (c *Client) InsertBatchBlock(ctx context.Context, srcBlock any, batch []map[string]any, opts map[string]any) ([]types.BlockEntity, error)

InsertBatchBlock inserts multiple blocks at once.

func (*Client) InsertBlock

func (c *Client) InsertBlock(ctx context.Context, srcBlock any, content string, opts map[string]any) (*types.BlockEntity, error)

InsertBlock inserts a block relative to another block.

func (*Client) MoveBlock

func (c *Client) MoveBlock(ctx context.Context, uuid string, targetUUID string, opts map[string]any) error

MoveBlock moves a block to a new location.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks if the Logseq API is reachable by attempting to list pages.

func (*Client) PrependBlockInPage

func (c *Client) PrependBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)

PrependBlockInPage adds a block at the start of a page.

func (*Client) RemoveBlock

func (c *Client) RemoveBlock(ctx context.Context, uuid string) error

RemoveBlock deletes a block.

func (*Client) RenamePage added in v0.4.0

func (c *Client) RenamePage(ctx context.Context, oldName, newName string) error

RenamePage renames a page. Logseq handles link updates automatically.

func (*Client) UpdateBlock

func (c *Client) UpdateBlock(ctx context.Context, uuid string, content string, opts ...map[string]any) error

UpdateBlock modifies a block's content.

type GraphInfo

type GraphInfo struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

GraphInfo represents the current graph's metadata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL