SiYuan icon

SiYuan

Interacts with the SiYuan API using selected operations

Overview

The node integrates with the SiYuan API to perform a variety of content and document management operations within the SiYuan note-taking and knowledge management system. Specifically, the "Insert Block" operation allows users to add a new block of content (in Markdown or HTML format) inside a specified parent block, positioning it either before or after an existing sibling block or as the first/last child.

This operation is useful when you want to programmatically insert structured content into documents or blocks in SiYuan, such as adding paragraphs, lists, or other formatted content at precise locations within your notes. For example, you might insert a new paragraph after a specific section or add a list item before another block.

Properties

Name Meaning
Parent Block ID The unique identifier of the parent block (e.g., a document or container block) where the new block will be inserted.
Content (Markdown/HTML) The text content and formatting for the new block, provided in Markdown or HTML.
Previous Block ID (Optional) The ID of an existing block after which the new block should be inserted.
Next Block ID (Optional) The ID of an existing block before which the new block should be inserted; used if Previous Block ID is empty.

Output

The output JSON contains the response from the SiYuan API corresponding to the insertion operation. Typically, this includes metadata about the newly created block, such as its unique ID and any relevant attributes returned by the API.

If the operation succeeds, the output JSON will reflect the details of the inserted block. If no data is returned, a success confirmation object { success: true } is provided instead.

The node does not output binary data.

Dependencies

  • Requires an active connection to the SiYuan API via an API URL and an API authentication token.
  • The user must configure credentials in n8n that provide these two pieces of information.
  • The node depends on the bundled SiYuanClient library to communicate with the SiYuan API.

Troubleshooting

  • Missing Credentials: If the API URL or token is not set, the node will throw a "Credentials missing!" error. Ensure that valid credentials are configured.
  • Invalid Block IDs: Providing incorrect or non-existent parentBlockId, previousBlockId, or nextBlockId may cause the API to reject the request or fail silently. Verify block IDs exist in your SiYuan workspace.
  • Content Format Issues: The blockData must be valid Markdown or HTML. Improperly formatted content could lead to unexpected rendering or errors.
  • Operation Not Supported: If an unsupported operation name is provided, the node throws an error indicating the operation is unsupported.
  • API Errors: Network issues or API-side errors will propagate as exceptions. Check connectivity and API status.

Links and References

Discussion