Skip to content

/api/filetree

createDailyNote

  • 🛠 创建每日笔记 (Daily Note)
  • /api/filetree/createDailyNote

请求

ts
/**
 * Create daily note document
 */
export interface IPayload {
    /**
     * App ID
     */
    readonly app?: string;
    /**
     * notebook ID
     */
    readonly notebook: string;
}
json5
/**
 * schemas/kernel/api/filetree/createDailyNote/payload.schema.json5
 * 创建每日笔记 (Daily Note)
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.11.3/kernel/api/filetree.go#L443-L501
 * @pathname: /api/filetree/createDailyNote
 * @version: 2.11.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDailyNote/payload.schema.json5',
    $comment: 'v2.11.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Create daily note document',

            type: 'object',
            additionalProperties: false,
            required: [
                'notebook',
            ],
            properties: {
                app: {
                    // Web 页面应用的 ID
                    // globalThis.siyuan.ws.app.appId
                    type: 'string',
                    description: 'App ID',
                    pattern: '^[0-9a-z]{5}$',
                },
                notebook: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDailyNote/payload.schema.json",
    "$comment": "v2.11.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Create daily note document",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "notebook"
            ],
            "properties": {
                "app": {
                    "type": "string",
                    "description": "App ID",
                    "pattern": "^[0-9a-z]{5}$"
                },
                "notebook": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                }
            }
        }
    }
}

响应

ts
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: IData;
    /**
     * status message
     */
    readonly msg: string;
}

/**
 * Response information
 */
export interface IData {
    /**
     * The block ID of the document block where Today's Daily Note is located
     */
    readonly id: string;
}
json5
/**
 * schemas/kernel/api/filetree/createDailyNote/response.schema.json5
 * 创建每日笔记 (Daily Note)
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.11.3/kernel/api/filetree.go#L443-L501
 * @pathname: /api/filetree/createDailyNote
 * @version: 2.11.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDailyNote/response.schema.json5',
    $comment: 'v2.11.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: '',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    $ref: '#/$defs/data',
                },
            },
        },
        data: {
            title: 'IData',
            description: 'Response information',

            type: 'object',
            additionalProperties: false,
            required: [
                'id',
            ],
            properties: {
                id: {
                    // 今日笔记所在文档块的块 ID
                    type: 'string',
                    description: "The block ID of the document block where Today's Daily Note is located",
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDailyNote/response.schema.json",
    "$comment": "v2.11.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "$ref": "#/$defs/data"
                }
            }
        },
        "data": {
            "title": "IData",
            "description": "Response information",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "id"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "description": "The block ID of the document block where Today's Daily Note is located",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                }
            }
        }
    }
}

createDocWithMd

  • 🔥 通过 Markdown 创建文档
  • /api/filetree/createDocWithMd

请求

ts
/**
 * Create a document with Markdown
 */
export interface IPayload {
    /**
     * Markdown text (GitLab Flavored Markdown, GFM)
     * REF: https://github.github.com/gfm/
     */
    readonly markdown: string;
    /**
     * notebook ID
     */
    readonly notebook: string;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database hpath field
     */
    readonly path: string;
}
json5
/**
 * schemas/kernel/api/filetree/createDocWithMd/payload.schema.json5
 * 通过 Markdown 创建文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#create-a-document-with-markdown
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L464-L511
 * @pathname: /api/filetree/createDocWithMd
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDocWithMd/payload.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Create a document with Markdown',

            type: 'object',
            additionalProperties: false,
            required: [
                'notebook',
                'path',
                'markdown',
            ],
            properties: {
                notebook: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 想要新建文档的人类可读路径, 以 / 开始, 使用 / 分割层级
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field',
                    pattern: '^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$',
                    examples: [
                        '/doc-name',
                        '/parent-doc-name/doc-name',
                    ],
                },
                markdown: {
                    // Markdown (GitLab Flavored Markdown, GFM) 文本
                    // REF: https://github.github.com/gfm/
                    type: 'string',
                    description: 'Markdown text (GitLab Flavored Markdown, GFM)\nREF: https://github.github.com/gfm/',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDocWithMd/payload.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Create a document with Markdown",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "notebook",
                "path",
                "markdown"
            ],
            "properties": {
                "notebook": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field",
                    "pattern": "^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$",
                    "examples": [
                        "/doc-name",
                        "/parent-doc-name/doc-name"
                    ]
                },
                "markdown": {
                    "type": "string",
                    "description": "Markdown text (GitLab Flavored Markdown, GFM)\nREF: https://github.github.com/gfm/"
                }
            }
        }
    }
}

响应

ts
/**
 * Create a document with Markdown
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    /**
     * document ID
     */
    readonly data: string;
    /**
     * status message
     */
    readonly msg: string;
}
json5
/**
 * schemas/kernel/api/filetree/createDocWithMd/response.schema.json5
 * 通过 Markdown 创建文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#create-a-document-with-markdown
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L464-L511
 * @pathname: /api/filetree/createDocWithMd
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDocWithMd/response.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Create a document with Markdown',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    // 新建文档的文档块 ID
                    type: 'string',
                    description: 'document ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/createDocWithMd/response.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Create a document with Markdown",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "string",
                    "description": "document ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                }
            }
        }
    }
}

getDoc

  • 🛠 获取文档内容
  • /api/filetree/getDoc

请求

ts
/**
 * Get block HTML DOM and other information
 */
export interface IPayload {
    /**
     * The end block ID
     */
    readonly endID?: string;
    /**
     * Block ID
     */
    readonly id: string;
    /**
     * Block index
     */
    readonly index?: number;
    /**
     * Whether it is a reverse link
     */
    readonly isBacklink?: boolean;
    /**
     * Load mode
     */
    readonly mode?: number;
    /**
     * Query statements
     */
    readonly query?: string;
    /**
     * Query method
     */
    readonly queryMethod?: number;
    readonly queryTypes?: IQueryTypes;
    /**
     * Maximum number of loaded blocks
     */
    readonly size?: number;
    /**
     * The starting block ID
     */
    readonly startID?: string;
}

/**
 * Query the specified block type (block type filter)
 */
export interface IQueryTypes {
    /**
     * Quote block
     */
    readonly blockquote?: boolean;
    /**
     * Code block
     */
    readonly codeBlock?: boolean;
    /**
     * Document block
     */
    readonly document?: boolean;
    /**
     * Embed block
     */
    readonly embedBlock?: boolean;
    /**
     * Heading block
     */
    readonly heading?: boolean;
    /**
     * HTML block
     */
    readonly htmlBlock?: boolean;
    /**
     * List block
     */
    readonly list?: boolean;
    /**
     * List item block
     */
    readonly listItem?: boolean;
    /**
     * Math formula block
     */
    readonly mathBlock?: boolean;
    /**
     * Paragraph block
     */
    readonly paragraph?: boolean;
    /**
     * Super blok
     */
    readonly superBlock?: boolean;
    /**
     * Table block
     */
    readonly table?: boolean;
}
json5
/**
 * schemas/kernel/api/filetree/getDoc/payload.schema.json5
 * 获取块 DOM 与相关信息
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.5/kernel/api/filetree.go#L663-L752
 * @pathname: /api/filetree/getDoc
 * @version: 2.9.5
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getDoc/payload.schema.json5',
    $comment: 'v2.9.5',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Get block HTML DOM and other information',

            type: 'object',
            additionalProperties: false,
            required: [
                'id',
            ],
            dependentRequired: {
                /**
                 * 属性相互依赖
                 * REF: https://ajv.js.org/json-schema.html#dependentrequired
                 */
                startID: [
                    'endID',
                    'scroll',
                ],
                endID: [
                    'startID',
                    'scroll',
                ],
            },
            properties: {
                id: {
                    // 块 ID
                    type: 'string',
                    description: 'Block ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                index: {
                    // 块索引序号
                    type: 'integer',
                    description: 'Block index',
                    minimum: 0,
                    default: 0,
                },
                query: {
                    // 查询语句
                    type: 'string',
                    description: 'Query statements',
                    default: '',
                },
                queryMethod: {
                    // 查询方案
                    type: 'integer',
                    description: 'Query method',
                    enum: [
                        0, // 关键字
                        1, // 查询语法
                        2, // SQL
                        3, // 正则表达式
                    ],
                    default: 0,
                },
                queryTypes: {
                    // 块类型过滤
                    $ref: '#/$defs/queryTypes',
                },
                mode: {
                    // 加载模式
                    type: 'integer',
                    description: 'Load mode',
                    enum: [
                        0, // 仅加载 ID 指定的块
                        1, // 加载上方内容
                        2, // 加载下方内容
                        3, // 加载上下方内容
                        4, // 加载末尾内容
                    ],
                    default: 0,
                },
                size: {
                    // 最大加载块数
                    type: 'integer',
                    description: 'Maximum number of loaded blocks',
                    default: 102400,
                    minimum: 1,
                },
                startID: {
                    // 起始块 ID
                    type: 'string',
                    description: 'The starting block ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                    default: '',
                },
                endID: {
                    // 终止块 ID
                    type: 'string',
                    description: 'The end block ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                    default: '',
                },
                isBacklink: {
                    // 是否为反向链接
                    type: 'boolean',
                    description: 'Whether it is a reverse link',
                    default: false,
                },
            },
        },
        queryTypes: {
            title: 'IQueryTypes',
            description: 'Query the specified block type (block type filter)',

            type: 'object',
            additionalProperties: false,
            required: [],
            properties: {
                document: {
                    // 文档块
                    description: 'Document block',
                    type: 'boolean',
                    default: false,
                },
                heading: {
                    // 标题块
                    description: 'Heading block',
                    type: 'boolean',
                    default: false,
                },
                list: {
                    // 列表块
                    description: 'List block',
                    type: 'boolean',
                    default: false,
                },
                listItem: {
                    // 列表项
                    description: 'List item block',
                    type: 'boolean',
                    default: false,
                },
                codeBlock: {
                    // 代码块
                    description: 'Code block',
                    type: 'boolean',
                    default: false,
                },
                mathBlock: {
                    // 公式块
                    description: 'Math formula block',
                    type: 'boolean',
                    default: false,
                },
                table: {
                    // 表格块
                    description: 'Table block',
                    type: 'boolean',
                    default: false,
                },
                blockquote: {
                    // 引述块
                    description: 'Quote block',
                    type: 'boolean',
                    default: false,
                },
                superBlock: {
                    // 超级块
                    description: 'Super blok',
                    type: 'boolean',
                    default: false,
                },
                paragraph: {
                    // 段落块
                    description: 'Paragraph block',
                    type: 'boolean',
                    default: false,
                },
                htmlBlock: {
                    // HTML 块
                    description: 'HTML block',
                    type: 'boolean',
                    default: false,
                },
                embedBlock: {
                    // 嵌入块
                    description: 'Embed block',
                    type: 'boolean',
                    default: false,
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getDoc/payload.schema.json",
    "$comment": "v2.9.5",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Get block HTML DOM and other information",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "id"
            ],
            "dependentRequired": {
                "startID": [
                    "endID",
                    "scroll"
                ],
                "endID": [
                    "startID",
                    "scroll"
                ]
            },
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Block ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "index": {
                    "type": "integer",
                    "description": "Block index",
                    "minimum": 0,
                    "default": 0
                },
                "query": {
                    "type": "string",
                    "description": "Query statements",
                    "default": ""
                },
                "queryMethod": {
                    "type": "integer",
                    "description": "Query method",
                    "enum": [
                        0,
                        1,
                        2,
                        3
                    ],
                    "default": 0
                },
                "queryTypes": {
                    "$ref": "#/$defs/queryTypes"
                },
                "mode": {
                    "type": "integer",
                    "description": "Load mode",
                    "enum": [
                        0,
                        1,
                        2,
                        3,
                        4
                    ],
                    "default": 0
                },
                "size": {
                    "type": "integer",
                    "description": "Maximum number of loaded blocks",
                    "default": 102400,
                    "minimum": 1
                },
                "startID": {
                    "type": "string",
                    "description": "The starting block ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$",
                    "default": ""
                },
                "endID": {
                    "type": "string",
                    "description": "The end block ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$",
                    "default": ""
                },
                "isBacklink": {
                    "type": "boolean",
                    "description": "Whether it is a reverse link",
                    "default": false
                }
            }
        },
        "queryTypes": {
            "title": "IQueryTypes",
            "description": "Query the specified block type (block type filter)",
            "type": "object",
            "additionalProperties": false,
            "required": [],
            "properties": {
                "document": {
                    "description": "Document block",
                    "type": "boolean",
                    "default": false
                },
                "heading": {
                    "description": "Heading block",
                    "type": "boolean",
                    "default": false
                },
                "list": {
                    "description": "List block",
                    "type": "boolean",
                    "default": false
                },
                "listItem": {
                    "description": "List item block",
                    "type": "boolean",
                    "default": false
                },
                "codeBlock": {
                    "description": "Code block",
                    "type": "boolean",
                    "default": false
                },
                "mathBlock": {
                    "description": "Math formula block",
                    "type": "boolean",
                    "default": false
                },
                "table": {
                    "description": "Table block",
                    "type": "boolean",
                    "default": false
                },
                "blockquote": {
                    "description": "Quote block",
                    "type": "boolean",
                    "default": false
                },
                "superBlock": {
                    "description": "Super blok",
                    "type": "boolean",
                    "default": false
                },
                "paragraph": {
                    "description": "Paragraph block",
                    "type": "boolean",
                    "default": false
                },
                "htmlBlock": {
                    "description": "HTML block",
                    "type": "boolean",
                    "default": false
                },
                "embedBlock": {
                    "description": "Embed block",
                    "type": "boolean",
                    "default": false
                }
            }
        }
    }
}

响应

ts
/**
 * Get block HTML DOM and other information
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: IData;
    /**
     * status message
     */
    readonly msg: string;
}

/**
 * Response information
 */
export interface IData {
    /**
     * Block count
     */
    readonly blockCount: number;
    /**
     * Notebook ID
     */
    readonly box: string;
    /**
     * HTML DOM string
     */
    readonly content: string;
    /**
     * End Of File
     */
    readonly eof: boolean;
    /**
     * Block ID
     */
    readonly id: string;
    /**
     * is backlink detail?
     */
    readonly isBacklinkExpand: boolean;
    /**
     * is syncing?
     */
    readonly isSyncing: boolean;
    /**
     * Load mode
     */
    readonly mode: number;
    /**
     * Logic parent block ID
     * if heading exists, it is heading block ID
     * else equal parentID
     */
    readonly parent2ID: string;
    /**
     * Parent block ID
     */
    readonly parentID: string;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database path field
     */
    readonly path: string;
    /**
     * Document block ID
     */
    readonly rootID: string;
    /**
     * is dynamic loading?
     */
    readonly scroll: boolean;
    /**
     * Block type
     */
    readonly type: TBlockType;
}

/**
 * Block type
 */
export type TBlockType = "NodeAttributeView" | "NodeAudio" | "NodeBlockQueryEmbed" | "NodeBlockquote" | "NodeCodeBlock" | "NodeDocument" | "NodeHeading" | "NodeHTMLBlock" | "NodeIFrame" | "NodeList" | "NodeListItem" | "NodeMathBlock" | "NodeParagraph" | "NodeSuperBlock" | "NodeTable" | "NodeThematicBreak" | "NodeVideo" | "NodeWidget";
json5
/**
 * schemas/kernel/api/filetree/getDoc/response.schema.json5
 * 获取块 DOM 与相关信息
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.5/kernel/api/filetree.go#L663-L752
 * @pathname: /api/filetree/getDoc
 * @version: 2.9.5
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getDoc/response.schema.json5',
    $comment: 'v2.9.5',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Get block HTML DOM and other information',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    $ref: '#/$defs/data',
                },
            },
        },
        data: {
            title: 'IData',
            description: 'Response information',

            type: 'object',
            additionalProperties: false,
            required: [
                'blockCount',
                'box',
                'content',
                'eof',
                'id',
                'isBacklinkExpand',
                'isSyncing',
                'mode',
                'parent2ID',
                'parentID',
                'path',
                'rootID',
                'scroll',
                'type',
            ],
            properties: {
                blockCount: {
                    // 块数量
                    type: 'integer',
                    description: 'Block count',
                },
                box: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'Notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                content: {
                    // HTML DOM 字符串
                    type: 'string',
                    description: 'HTML DOM string',
                },
                eof: {
                    // 是否为文件末尾
                    type: 'boolean',
                    description: 'End Of File',
                },
                id: {
                    // 块 ID
                    type: 'string',
                    description: 'Block ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                isBacklinkExpand: {
                    // 是否为反链详情
                    type: 'boolean',
                    description: 'is backlink detail?',
                },
                isSyncing: {
                    // 是否正在同步
                    type: 'boolean',
                    description: 'is syncing?',
                },
                mode: {
                    // 加载模式
                    type: 'integer',
                    description: 'Load mode',
                },
                parent2ID: {
                    /**
                     * 逻辑上级块 ID
                     * 若其上方存在同级的子标题, 则为子标题块 ID
                     * 否则与 parentID 一致
                     */
                    type: 'string',
                    description: 'Logic parent block ID\nif heading exists, it is heading block ID\nelse equal parentID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                parentID: {
                    // 上级块 ID
                    type: 'string',
                    description: 'Parent block ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 相对于笔记本目录的文档文件目录
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field',
                    pattern: '^(/\\d{14}-[0-9a-z]{7})+\\.sy$',
                    examples: [
                        '/20200812220555-lj3enxa.sy',
                        '/20200812220555-lj3enxa/20210808180320-fqgskfj.sy',
                    ],
                },
                rootID: {
                    // 文档块 ID
                    type: 'string',
                    description: 'Document block ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                scroll: {
                    // 是否为动态加载
                    type: 'boolean',
                    description: 'is dynamic loading?',
                },
                type: {
                    // 目标对应的块类型
                    title: 'TBlockType',
                    type: 'string',
                    description: 'Block type',
                    enum: [
                        'NodeDocument', // 文档块
                        'NodeSuperBlock', // 超级块
                        'NodeBlockquote', // 引述块
                        'NodeList', // 列表块
                        'NodeListItem', // 列表项
                        'NodeHeading', // 标题块
                        'NodeParagraph', // 段落块
                        'NodeMathBlock', // 公式块
                        'NodeTable', // 表格块
                        'NodeCodeBlock', // 代码块
                        'NodeHTMLBlock', // HTML 块
                        'NodeThematicBreak', // 分割线
                        'NodeAudio', // 音频快
                        'NodeVideo', // 视频块
                        'NodeIFrame', // iframe 块
                        'NodeWidget', // 挂件块
                        'NodeBlockQueryEmbed', // 嵌入块
                        'NodeAttributeView', // 属性表
                    ],
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getDoc/response.schema.json",
    "$comment": "v2.9.5",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Get block HTML DOM and other information",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "$ref": "#/$defs/data"
                }
            }
        },
        "data": {
            "title": "IData",
            "description": "Response information",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "blockCount",
                "box",
                "content",
                "eof",
                "id",
                "isBacklinkExpand",
                "isSyncing",
                "mode",
                "parent2ID",
                "parentID",
                "path",
                "rootID",
                "scroll",
                "type"
            ],
            "properties": {
                "blockCount": {
                    "type": "integer",
                    "description": "Block count"
                },
                "box": {
                    "type": "string",
                    "description": "Notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "content": {
                    "type": "string",
                    "description": "HTML DOM string"
                },
                "eof": {
                    "type": "boolean",
                    "description": "End Of File"
                },
                "id": {
                    "type": "string",
                    "description": "Block ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "isBacklinkExpand": {
                    "type": "boolean",
                    "description": "is backlink detail?"
                },
                "isSyncing": {
                    "type": "boolean",
                    "description": "is syncing?"
                },
                "mode": {
                    "type": "integer",
                    "description": "Load mode"
                },
                "parent2ID": {
                    "type": "string",
                    "description": "Logic parent block ID\nif heading exists, it is heading block ID\nelse equal parentID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "parentID": {
                    "type": "string",
                    "description": "Parent block ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field",
                    "pattern": "^(/\\d{14}-[0-9a-z]{7})+\\.sy$",
                    "examples": [
                        "/20200812220555-lj3enxa.sy",
                        "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
                    ]
                },
                "rootID": {
                    "type": "string",
                    "description": "Document block ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "scroll": {
                    "type": "boolean",
                    "description": "is dynamic loading?"
                },
                "type": {
                    "title": "TBlockType",
                    "type": "string",
                    "description": "Block type",
                    "enum": [
                        "NodeDocument",
                        "NodeSuperBlock",
                        "NodeBlockquote",
                        "NodeList",
                        "NodeListItem",
                        "NodeHeading",
                        "NodeParagraph",
                        "NodeMathBlock",
                        "NodeTable",
                        "NodeCodeBlock",
                        "NodeHTMLBlock",
                        "NodeThematicBreak",
                        "NodeAudio",
                        "NodeVideo",
                        "NodeIFrame",
                        "NodeWidget",
                        "NodeBlockQueryEmbed",
                        "NodeAttributeView"
                    ]
                }
            }
        }
    }
}

getHPathByID

  • 🔥 通过块 ID 获取文档的可读路径
  • /api/filetree/getHPathByID

请求

ts
/**
 * Get human readable path based on ID
 */
export interface IPayload {
    /**
     * document ID
     */
    readonly id: string;
}
json5
/**
 * schemas/kernel/api/filetree/getHPathByID/payload.schema.json5
 * 根据 ID 获取人类可读路径
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-human-readable-path-based-on-id
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L206-L227
 * @pathname: /api/filetree/getHPathByID
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByID/payload.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Get human readable path based on ID',
            type: 'object',

            additionalProperties: false,
            required: [
                'id',
            ],
            properties: {
                id: {
                    type: 'string',
                    description: 'document ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByID/payload.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Get human readable path based on ID",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "id"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "description": "document ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                }
            }
        }
    }
}

响应

ts
/**
 * Get human readable path based on ID
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database hpath field
     */
    readonly data: string;
    /**
     * status message
     */
    readonly msg: string;
}
json5
/**
 * schemas/kernel/api/filetree/getHPathByID/response.schema.json5
 * 根据 ID 获取人类可读路径
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-human-readable-path-based-on-id
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L206-L227
 * @pathname: /api/filetree/getHPathByID
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByID/response.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Get human readable path based on ID',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    // 文档的人类可读路径, 以 / 开始, 使用 / 分割层级
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field',
                    pattern: '^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$',
                    examples: [
                        '/doc-name',
                        '/parent-doc-name/doc-name',
                    ],
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByID/response.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Get human readable path based on ID",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field",
                    "pattern": "^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$",
                    "examples": [
                        "/doc-name",
                        "/parent-doc-name/doc-name"
                    ]
                }
            }
        }
    }
}

getHPathByPath

  • 🔥 通过文档路径获取文档的可读路径
  • /api/filetree/getHPathByPath

请求

ts
/**
 * Get human readable path based on path
 */
export interface IPayload {
    /**
     * notebook ID
     */
    readonly notebook: string;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database path field
     */
    readonly path: string;
}
json5
/**
 * schemas/kernel/api/filetree/getHPathByPath/payload.schema.json5
 * 根据路径获取人类可读路径
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-human-readable-path-based-on-path
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L158-L181
 * @pathname: /api/filetree/getHPathByPath
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByPath/payload.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Get human readable path based on path',

            type: 'object',
            additionalProperties: false,
            required: [
                'notebook',
                'path',
            ],
            properties: {
                notebook: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 相对于笔记本目录的文档文件目录
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field',
                    pattern: '^(/\\d{14}-[0-9a-z]{7})+\\.sy$',
                    examples: [
                        '/20200812220555-lj3enxa.sy',
                        '/20200812220555-lj3enxa/20210808180320-fqgskfj.sy',
                    ],
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByPath/payload.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Get human readable path based on path",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "notebook",
                "path"
            ],
            "properties": {
                "notebook": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field",
                    "pattern": "^(/\\d{14}-[0-9a-z]{7})+\\.sy$",
                    "examples": [
                        "/20200812220555-lj3enxa.sy",
                        "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
                    ]
                }
            }
        }
    }
}

响应

ts
/**
 * Get human readable path based on path
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database hpath field
     */
    readonly data: string;
    /**
     * status message
     */
    readonly msg: string;
}
json5
/**
 * schemas/kernel/api/filetree/getHPathByPath/response.schema.json5
 * 根据路径获取人类可读路径
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-human-readable-path-based-on-path
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L158-L181
 * @pathname: /api/filetree/getHPathByPath
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByPath/response.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Get human readable path based on path',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    // 文档的人类可读路径, 以 / 开始, 使用 / 分割层级
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field',
                    pattern: '^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$',
                    examples: [
                        '/doc-name',
                        '/parent-doc-name/doc-name',
                    ],
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getHPathByPath/response.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Get human readable path based on path",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field",
                    "pattern": "^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$",
                    "examples": [
                        "/doc-name",
                        "/parent-doc-name/doc-name"
                    ]
                }
            }
        }
    }
}

listDocsByPath

  • 🛠 通过文档路径获取下级文档列表
  • /api/filetree/listDocsByPath

请求

ts
/**
 * List sub docs by path
 */
export interface IPayload {
    /**
     * whether to list flashcard count
     */
    readonly flashcard?: boolean;
    /**
     * max list count of docs
     * `<= 0`: unlimited
     */
    readonly maxListCount?: number;
    /**
     * notebook ID
     */
    readonly notebook: string;
    /**
     * document file/folder path
     */
    readonly path: string;
    /**
     * document sort rule
     * 0: Name Alphabet ASC
     * 1: Name Alphabet DESC
     * 2: Modified Time ASC
     * 3: Modified Time DESC
     * 4: Name Natural ASC
     * 5: Name Natural DESC
     * 6: Custom Sorting
     * 7: Ref Count ASC
     * 8: Ref Count DESC
     * 9: Created Time ASC
     * 10: Created Time DESC
     * 11: Document Size ASC
     * 12: Document Size DESC
     * 13: Sub-docs Count ASC
     * 14: Sub-docs Count DESC
     * 15: Use doc tree sorting rule
     * 256: (default) Use notebook sorting rule
     */
    readonly sort?: number;
}
json5
/**
 * schemas/kernel/api/filetree/listDocsByPath/payload.schema.json5
 * 根据文档文件路径列出文档
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.8/kernel/api/filetree.go#L617-L661
 * @pathname: /api/filetree/listDocsByPath
 * @version: 2.9.8
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/listDocsByPath/payload.schema.json5',
    $comment: 'v2.9.8',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'List sub docs by path',

            type: 'object',
            additionalProperties: false,
            required: [
                'notebook',
                'path',
            ],
            properties: {
                notebook: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 文档文件/文件夹路径
                    type: 'string',
                    description: 'document file/folder path',
                    examples: [
                        '',
                        '/',
                        '.',
                        './',
                        '20210117215840-jcl17fx',
                        '/20210117215840-jcl17fx',
                        './20210117215840-jcl17fx',
                        '20210117215840-jcl17fx.sy',
                        '/20210117215840-jcl17fx.sy',
                        './20210117215840-jcl17fx.sy',
                    ],
                },
                sort: {
                    // 文档排序规则
                    type: 'integer',
                    description: 'document sort rule\n0: Name Alphabet ASC\n1: Name Alphabet DESC\n2: Modified Time ASC\n3: Modified Time DESC\n4: Name Natural ASC\n5: Name Natural DESC\n6: Custom Sorting\n7: Ref Count ASC\n8: Ref Count DESC\n9: Created Time ASC\n10: Created Time DESC\n11: Document Size ASC\n12: Document Size DESC\n13: Sub-docs Count ASC \n14: Sub-docs Count DESC\n15: Use doc tree sorting rule\n256: (default) Use notebook sorting rule',
                    default: 256, // 默认使用笔记本排序规则
                    enum: [
                        // REF: https://github.com/siyuan-note/siyuan/blob/v2.9.8/kernel/util/sort.go#L60-L79
                        0, //文件名字母升序
                        1, //文件名字母降序
                        2, //文件更新时间升序
                        3, //文件更新时间降序
                        4, //文件名自然数升序
                        5, //文件名自然数降序
                        6, //自定义排序
                        7, //引用数升序
                        8, //引用数降序
                        9, //文件创建时间升序
                        10, //文件创建时间降序
                        11, //文件大小升序
                        12, //文件大小降序
                        13, //子文档数升序
                        14, //子文档数降序
                        15, //使用文档树排序规则
                        256, //未指定排序规则,按照笔记本优先于文档树获取排序规则
                    ],
                },
                maxListCount: {
                    // 最大列出文档数
                    // 默认为 Conf.FileTree.MaxListCount
                    // 设置为 <= 0 的数标示无限制
                    type: 'integer',
                    description: 'max list count of docs\n`<= 0`: unlimited',
                },
                flashcard: {
                    // 是否列出闪卡数
                    type: 'boolean',
                    description: 'whether to list flashcard count',
                    default: false,
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/listDocsByPath/payload.schema.json",
    "$comment": "v2.9.8",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "List sub docs by path",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "notebook",
                "path"
            ],
            "properties": {
                "notebook": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "document file/folder path",
                    "examples": [
                        "",
                        "/",
                        ".",
                        "./",
                        "20210117215840-jcl17fx",
                        "/20210117215840-jcl17fx",
                        "./20210117215840-jcl17fx",
                        "20210117215840-jcl17fx.sy",
                        "/20210117215840-jcl17fx.sy",
                        "./20210117215840-jcl17fx.sy"
                    ]
                },
                "sort": {
                    "type": "integer",
                    "description": "document sort rule\n0: Name Alphabet ASC\n1: Name Alphabet DESC\n2: Modified Time ASC\n3: Modified Time DESC\n4: Name Natural ASC\n5: Name Natural DESC\n6: Custom Sorting\n7: Ref Count ASC\n8: Ref Count DESC\n9: Created Time ASC\n10: Created Time DESC\n11: Document Size ASC\n12: Document Size DESC\n13: Sub-docs Count ASC \n14: Sub-docs Count DESC\n15: Use doc tree sorting rule\n256: (default) Use notebook sorting rule",
                    "default": 256,
                    "enum": [
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        256
                    ]
                },
                "maxListCount": {
                    "type": "integer",
                    "description": "max list count of docs\n`<= 0`: unlimited"
                },
                "flashcard": {
                    "type": "boolean",
                    "description": "whether to list flashcard count",
                    "default": false
                }
            }
        }
    }
}

响应

ts
/**
 * List sub docs by path
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: IData;
    /**
     * status message
     */
    readonly msg: string;
}

/**
 * response data
 */
export interface IData {
    /**
     * notebook ID
     */
    readonly box: string;
    readonly files: IFile[];
    /**
     * document file/folder path
     */
    readonly path: string;
}

/**
 * Document information
 */
export interface IFile {
    /**
     * document alias
     */
    readonly alias: string;
    /**
     * document bookmark
     */
    readonly bookmark: string;
    /**
     * document reference count
     */
    readonly count: number;
    /**
     * document created time (Unix timestamp, unit: s)
     */
    readonly ctime: number;
    /**
     * due flashcard count
     */
    readonly dueFlashcardCount: number;
    /**
     * flashcard count
     */
    readonly flashcardCount: number;
    /**
     * human readable document created time
     */
    readonly hCtime: string;
    /**
     * is hidden
     */
    readonly hidden: boolean;
    /**
     * human readable document modified time
     */
    readonly hMtime: string;
    /**
     * human readable document size
     */
    readonly hSize: string;
    /**
     * document icon
     */
    readonly icon: string;
    /**
     * document ID
     */
    readonly id: string;
    /**
     * document memo
     */
    readonly memo: string;
    /**
     * document modified time (Unix timestamp, unit: s)
     */
    readonly mtime: number;
    /**
     * document title
     */
    readonly name: string;
    /**
     * document name
     */
    readonly name1: string;
    /**
     * new flashcard count
     */
    readonly newFlashcardCount: number;
    /**
     * file path of document
     */
    readonly path: string;
    /**
     * document size (unit: Byte)
     */
    readonly size: number;
    /**
     * document sort rule
     * 0: Name Alphabet ASC
     * 1: Name Alphabet DESC
     * 2: Modified Time ASC
     * 3: Modified Time DESC
     * 4: Name Natural ASC
     * 5: Name Natural DESC
     * 6: Custom Sorting
     * 7: Ref Count ASC
     * 8: Ref Count DESC
     * 9: Created Time ASC
     * 10: Created Time DESC
     * 11: Document Size ASC
     * 12: Document Size DESC
     * 13: Sub-docs Count ASC
     * 14: Sub-docs Count DESC
     * 15: Use doc tree sorting rule
     * 256: (default) Use notebook sorting rule
     */
    readonly sort: number;
    /**
     * sub file count
     */
    readonly subFileCount: number;
}
json5
/**
 * schemas/kernel/api/filetree/listDocsByPath/response.schema.json5
 * 根据文档文件路径列出文档
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.4/kernel/api/filetree.go#L627-L675
 * @pathname: /api/filetree/listDocsByPath
 * @version: 2.10.4
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/listDocsByPath/response.schema.json5',
    $comment: 'v2.10.4',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'List sub docs by path',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    $ref: '#/$defs/data',
                },
            },
        },
        data: {
            title: 'IData',
            description: 'response data',

            type: 'object',
            additionalProperties: false,
            required: [
                'box',
                'path',
                'files',
            ],
            properties: {
                box: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 文档文件/文件夹路径
                    type: 'string',
                    description: 'document file/folder path',
                },
                files: {
                    type: 'array',
                    items: {
                        $ref: '#/$defs/file',
                    },
                },
            },
        },
        file: {
            title: 'IFile',
            description: 'Document information',

            type: 'object',
            additionalProperties: false,
            required: [
                'path',
                'name',
                'icon',
                'name1',
                'alias',
                'memo',
                'bookmark',
                'id',
                'count',
                'size',
                'hSize',
                'mtime',
                'ctime',
                'hMtime',
                'hCtime',
                'sort',
                'subFileCount',
                'hidden',
                'newFlashcardCount',
                'dueFlashcardCount',
                'flashcardCount',
            ],
            properties: {
                path: {
                    // 文档文件路径
                    type: 'string',
                    description: 'file path of document',
                },
                name: {
                    // 文档标题
                    type: 'string',
                    description: 'document title',
                    examples: [
                        'title.sy',
                    ],
                },
                icon: {
                    // 文海图标
                    type: 'string',
                    description: 'document icon',
                },
                name1: {
                    // 文档命名
                    type: 'string',
                    description: 'document name',
                },
                alias: {
                    // 文档别名
                    type: 'string',
                    description: 'document alias',
                },
                memo: {
                    // 文档备注
                    type: 'string',
                    description: 'document memo',
                },
                bookmark: {
                    // 文档书签
                    type: 'string',
                    description: 'document bookmark',
                },
                id: {
                    // 文档 ID
                    type: 'string',
                    description: 'document ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                count: {
                    // 文档被引用数
                    type: 'integer',
                    description: 'document reference count',
                },
                size: {
                    // 文档大小 (单位: 字节)
                    type: 'integer',
                    description: 'document size (unit: Byte)',
                },
                hSize: {
                    // 人类可读的文档大小
                    type: 'string',
                    description: 'human readable document size',
                    examples: [
                        '1 B',
                        '1 kB',
                        '1 MB',
                        '1 GB',
                        '1 TB',
                        '1 PB',
                        '1 EB',
                    ],
                },
                mtime: {
                    // 文档修改时间 (Unix 时间戳, 单位: ms)
                    type: 'integer',
                    description: 'document modified time (Unix timestamp, unit: s)',
                    examples: [
                        1690511805,
                    ],
                },
                ctime: {
                    // 文档创建时间 (Unix 时间戳, 单位: ms)
                    type: 'integer',
                    description: 'document created time (Unix timestamp, unit: s)',
                    examples: [
                        1597241155,
                    ],
                },
                hMtime: {
                    // 人类可读的文档修改时间
                    type: 'string',
                    description: 'human readable document modified time',
                    examples: [
                        '1 week ago',
                    ],
                },
                hCtime: {
                    // 人类可读的文档创建时间
                    type: 'string',
                    description: 'human readable document created time',
                    examples: [
                        '1 week ago',
                    ],
                },
                sort: {
                    // 文档排序规则
                    type: 'integer',
                    description: 'document sort rule\n0: Name Alphabet ASC\n1: Name Alphabet DESC\n2: Modified Time ASC\n3: Modified Time DESC\n4: Name Natural ASC\n5: Name Natural DESC\n6: Custom Sorting\n7: Ref Count ASC\n8: Ref Count DESC\n9: Created Time ASC\n10: Created Time DESC\n11: Document Size ASC\n12: Document Size DESC\n13: Sub-docs Count ASC \n14: Sub-docs Count DESC\n15: Use doc tree sorting rule\n256: (default) Use notebook sorting rule',
                    default: 256, // 默认使用笔记本排序规则
                    enum: [
                        // REF: https://github.com/siyuan-note/siyuan/blob/v2.10.4/kernel/util/sort.go#L60-L79
                        0, //文件名字母升序
                        1, //文件名字母降序
                        2, //文件更新时间升序
                        3, //文件更新时间降序
                        4, //文件名自然数升序
                        5, //文件名自然数降序
                        6, //自定义排序
                        7, //引用数升序
                        8, //引用数降序
                        9, //文件创建时间升序
                        10, //文件创建时间降序
                        11, //文件大小升序
                        12, //文件大小降序
                        13, //子文档数升序
                        14, //子文档数降序
                        15, //使用文档树排序规则
                        256, //未指定排序规则,按照笔记本优先于文档树获取排序规则
                    ],
                },
                subFileCount: {
                    // 下级文件数
                    type: 'integer',
                    description: 'sub file count',
                },
                hidden: {
                    // 是否隐藏
                    type: 'boolean',
                    description: 'is hidden',
                },
                newFlashcardCount: {
                    // 新闪卡数
                    type: 'integer',
                    description: 'new flashcard count',
                },
                dueFlashcardCount: {
                    // 到期闪卡数
                    type: 'integer',
                    description: 'due flashcard count',
                },
                flashcardCount: {
                    // 闪卡总数
                    type: 'integer',
                    description: 'flashcard count',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/listDocsByPath/response.schema.json",
    "$comment": "v2.10.4",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "List sub docs by path",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "$ref": "#/$defs/data"
                }
            }
        },
        "data": {
            "title": "IData",
            "description": "response data",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "box",
                "path",
                "files"
            ],
            "properties": {
                "box": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "document file/folder path"
                },
                "files": {
                    "type": "array",
                    "items": {
                        "$ref": "#/$defs/file"
                    }
                }
            }
        },
        "file": {
            "title": "IFile",
            "description": "Document information",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "path",
                "name",
                "icon",
                "name1",
                "alias",
                "memo",
                "bookmark",
                "id",
                "count",
                "size",
                "hSize",
                "mtime",
                "ctime",
                "hMtime",
                "hCtime",
                "sort",
                "subFileCount",
                "hidden",
                "newFlashcardCount",
                "dueFlashcardCount",
                "flashcardCount"
            ],
            "properties": {
                "path": {
                    "type": "string",
                    "description": "file path of document"
                },
                "name": {
                    "type": "string",
                    "description": "document title",
                    "examples": [
                        "title.sy"
                    ]
                },
                "icon": {
                    "type": "string",
                    "description": "document icon"
                },
                "name1": {
                    "type": "string",
                    "description": "document name"
                },
                "alias": {
                    "type": "string",
                    "description": "document alias"
                },
                "memo": {
                    "type": "string",
                    "description": "document memo"
                },
                "bookmark": {
                    "type": "string",
                    "description": "document bookmark"
                },
                "id": {
                    "type": "string",
                    "description": "document ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "count": {
                    "type": "integer",
                    "description": "document reference count"
                },
                "size": {
                    "type": "integer",
                    "description": "document size (unit: Byte)"
                },
                "hSize": {
                    "type": "string",
                    "description": "human readable document size",
                    "examples": [
                        "1 B",
                        "1 kB",
                        "1 MB",
                        "1 GB",
                        "1 TB",
                        "1 PB",
                        "1 EB"
                    ]
                },
                "mtime": {
                    "type": "integer",
                    "description": "document modified time (Unix timestamp, unit: s)",
                    "examples": [
                        1690511805
                    ]
                },
                "ctime": {
                    "type": "integer",
                    "description": "document created time (Unix timestamp, unit: s)",
                    "examples": [
                        1597241155
                    ]
                },
                "hMtime": {
                    "type": "string",
                    "description": "human readable document modified time",
                    "examples": [
                        "1 week ago"
                    ]
                },
                "hCtime": {
                    "type": "string",
                    "description": "human readable document created time",
                    "examples": [
                        "1 week ago"
                    ]
                },
                "sort": {
                    "type": "integer",
                    "description": "document sort rule\n0: Name Alphabet ASC\n1: Name Alphabet DESC\n2: Modified Time ASC\n3: Modified Time DESC\n4: Name Natural ASC\n5: Name Natural DESC\n6: Custom Sorting\n7: Ref Count ASC\n8: Ref Count DESC\n9: Created Time ASC\n10: Created Time DESC\n11: Document Size ASC\n12: Document Size DESC\n13: Sub-docs Count ASC \n14: Sub-docs Count DESC\n15: Use doc tree sorting rule\n256: (default) Use notebook sorting rule",
                    "default": 256,
                    "enum": [
                        0,
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        256
                    ]
                },
                "subFileCount": {
                    "type": "integer",
                    "description": "sub file count"
                },
                "hidden": {
                    "type": "boolean",
                    "description": "is hidden"
                },
                "newFlashcardCount": {
                    "type": "integer",
                    "description": "new flashcard count"
                },
                "dueFlashcardCount": {
                    "type": "integer",
                    "description": "due flashcard count"
                },
                "flashcardCount": {
                    "type": "integer",
                    "description": "flashcard count"
                }
            }
        }
    }
}

getIDsByHPath

  • 🔥 通过文档路径获取下级文档列表
  • /api/filetree/getIDsByHPath

请求

ts
/**
 * Get document block ID list from human readable path
 */
export interface IPayload {
    /**
     * notebook ID
     */
    readonly notebook: string;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database hpath field
     */
    readonly path: string;
}
json5
/**
 * schemas/kernel/api/filetree/getIDsByHPath/payload.schema.json5
 * 根据人类可读路径获取文档 ID 列表
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-ids-based-on-human-readable-path
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.15/kernel/api/filetree.go#L252-L280
 * @pathname: /api/filetree/getIDsByHPath
 * @version: 2.10.15
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getIDsByHPath/payload.schema.json5',
    $comment: 'v2.10.15',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Get document block ID list from human readable path',

            type: 'object',
            additionalProperties: false,
            required: [
                'notebook',
                'path',
            ],
            properties: {
                notebook: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 文档的人类可读路径, 以 / 开始, 使用 / 分割层级
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field',
                    pattern: '^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$',
                    examples: [
                        '/doc-name',
                        '/parent-doc-name/doc-name',
                    ],
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getIDsByHPath/payload.schema.json",
    "$comment": "v2.10.15",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Get document block ID list from human readable path",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "notebook",
                "path"
            ],
            "properties": {
                "notebook": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database hpath field",
                    "pattern": "^(/[^/\\t\\r\\n\\u2028\\u2029]+)+$",
                    "examples": [
                        "/doc-name",
                        "/parent-doc-name/doc-name"
                    ]
                }
            }
        }
    }
}

响应

ts
/**
 * Get document block ID list from human readable path
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    /**
     * document block ID list
     */
    readonly data: string[];
    /**
     * status message
     */
    readonly msg: string;
}
json5
/**
 * schemas/kernel/api/filetree/getIDsByHPath/response.schema.json5
 * 根据人类可读路径获取文档 ID 列表
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-ids-based-on-human-readable-path
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.15/kernel/api/filetree.go#L252-L280
 * @pathname: /api/filetree/getIDsByHPath
 * @version: 2.10.15
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getIDsByHPath/response.schema.json5',
    $comment: 'v2.10.15',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Get document block ID list from human readable path',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    type: 'array',
                    description: 'document block ID list',

                    items: {
                        // 笔记本 ID
                        type: 'string',
                        description: 'document ID',
                        pattern: '^\\d{14}-[0-9a-z]{7}$',
                    },
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/getIDsByHPath/response.schema.json",
    "$comment": "v2.10.15",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Get document block ID list from human readable path",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "array",
                    "description": "document block ID list",
                    "items": {
                        "type": "string",
                        "description": "document ID",
                        "pattern": "^\\d{14}-[0-9a-z]{7}$"
                    }
                }
            }
        }
    }
}

moveDocs

  • 🔥 移动文档
  • /api/filetree/moveDocs

请求

ts
/**
 * Move documents
 */
export interface IPayload {
    /**
     * document paths list
     */
    readonly fromPaths: string[];
    /**
     * target notebook ID
     */
    readonly toNotebook: string;
    /**
     * target path
     */
    readonly toPath: string;
}
json5
/**
 * schemas/kernel/api/filetree/moveDocs/payload.schema.json5
 * 重命名文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#move-documents
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L251-L280
 * @pathname: /api/filetree/moveDocs
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/moveDocs/payload.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Move documents',

            type: 'object',
            additionalProperties: false,
            required: [
                'fromPaths',
                'toNotebook',
                'toPath',
            ],
            properties: {
                fromPaths: {
                    /**
                     * 待移动的文档路径列表
                     * 文档不能存在上级与下级的依赖关系
                     */
                    type: 'array',
                    description: 'document paths list',
                    items: {
                        type: 'string',
                        description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field',
                        pattern: '^(/\\d{14}-[0-9a-z]{7})+\\.sy$',
                        examples: [
                            '/20200812220555-lj3enxa.sy',
                            '/20200812220555-lj3enxa/20210808180320-fqgskfj.sy',
                        ],
                    },
                },
                toNotebook: {
                    // 移动目标笔记本 ID
                    type: 'string',
                    description: 'target notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                toPath: {
                    // 目标目录路径
                    type: 'string',
                    description: 'target path',
                    pattern: '^(/\\d{14}-[0-9a-z]{7})*/$',
                    examples: [
                        '/',
                        '/20200812220555-lj3enxa/',
                    ],
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/moveDocs/payload.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Move documents",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "fromPaths",
                "toNotebook",
                "toPath"
            ],
            "properties": {
                "fromPaths": {
                    "type": "array",
                    "description": "document paths list",
                    "items": {
                        "type": "string",
                        "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field",
                        "pattern": "^(/\\d{14}-[0-9a-z]{7})+\\.sy$",
                        "examples": [
                            "/20200812220555-lj3enxa.sy",
                            "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
                        ]
                    }
                },
                "toNotebook": {
                    "type": "string",
                    "description": "target notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "toPath": {
                    "type": "string",
                    "description": "target path",
                    "pattern": "^(/\\d{14}-[0-9a-z]{7})*/$",
                    "examples": [
                        "/",
                        "/20200812220555-lj3enxa/"
                    ]
                }
            }
        }
    }
}

响应

ts
/**
 * Move documents
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: null;
    /**
     * status message
     */
    readonly msg: string;
}
json5
/**
 * schemas/kernel/api/filetree/moveDocs/response.schema.json5
 * 重命名文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#move-documents
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L251-L280
 * @pathname: /api/filetree/moveDocs
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/moveDocs/response.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Move documents',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    type: 'null',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/moveDocs/response.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Move documents",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "null"
                }
            }
        }
    }
}

removeDoc

  • 🔥 删除文档
  • /api/filetree/removeDoc

请求

ts
/**
 * Remove a document
 */
export interface IPayload {
    /**
     * notebook ID
     */
    readonly notebook: string;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database path field
     */
    readonly path: string;
}
json5
/**
 * schemas/kernel/api/filetree/removeDoc/payload.schema.json5
 * 删除文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#remove-a-document
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L300-L315
 * @pathname: /api/filetree/removeDoc
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/removeDoc/payload.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Remove a document',

            type: 'object',
            additionalProperties: false,
            required: [
                'notebook',
                'path',
            ],
            properties: {
                notebook: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 相对于笔记本目录的文档文件目录
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field',
                    pattern: '^(/\\d{14}-[0-9a-z]{7})+\\.sy$',
                    examples: [
                        '/20200812220555-lj3enxa.sy',
                        '/20200812220555-lj3enxa/20210808180320-fqgskfj.sy',
                    ],
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/removeDoc/payload.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Remove a document",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "notebook",
                "path"
            ],
            "properties": {
                "notebook": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field",
                    "pattern": "^(/\\d{14}-[0-9a-z]{7})+\\.sy$",
                    "examples": [
                        "/20200812220555-lj3enxa.sy",
                        "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
                    ]
                }
            }
        }
    }
}

响应

ts
/**
 * Remove a document
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: null;
    /**
     * status message
     */
    readonly msg: string;
}
json5
/**
 * schemas/kernel/api/filetree/removeDoc/response.schema.json5
 * 删除文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#remove-a-document
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L300-L315
 * @pathname: /api/filetree/removeDoc
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/removeDoc/response.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Remove a document',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    type: 'null',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/removeDoc/response.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Remove a document",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "null"
                }
            }
        }
    }
}

renameDoc

  • 🔥 重命名文档
  • /api/filetree/renameDoc

请求

ts
/**
 * Rename a document
 */
export interface IPayload {
    /**
     * notebook ID
     */
    readonly notebook: string;
    /**
     * Document path, which needs to start with / and separate levels with /
     * path here corresponds to the database path field
     */
    readonly path: string;
    /**
     * new document title
     */
    readonly title: string;
}
json5
/**
 * schemas/kernel/api/filetree/renameDoc/payload.schema.json5
 * 重命名文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#rename-a-document
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L317-L341
 * @pathname: /api/filetree/renameDoc
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/renameDoc/payload.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Rename a document',

            type: 'object',
            additionalProperties: false,
            required: [
                'notebook',
                'path',
                'title',
            ],
            properties: {
                notebook: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'notebook ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                path: {
                    // 相对于笔记本目录的文档文件目录
                    type: 'string',
                    description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field',
                    pattern: '^(/\\d{14}-[0-9a-z]{7})+\\.sy$',
                    examples: [
                        '/20200812220555-lj3enxa.sy',
                        '/20200812220555-lj3enxa/20210808180320-fqgskfj.sy',
                    ],
                },
                title: {
                    // 文档的新标题
                    // REF: https://github.github.com/gfm/
                    type: 'string',
                    description: 'new document title',
                    pattern: '^[^/\\t\\r\\n\\u2028\\u2029]+$',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/renameDoc/payload.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Rename a document",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "notebook",
                "path",
                "title"
            ],
            "properties": {
                "notebook": {
                    "type": "string",
                    "description": "notebook ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "path": {
                    "type": "string",
                    "description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field",
                    "pattern": "^(/\\d{14}-[0-9a-z]{7})+\\.sy$",
                    "examples": [
                        "/20200812220555-lj3enxa.sy",
                        "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
                    ]
                },
                "title": {
                    "type": "string",
                    "description": "new document title",
                    "pattern": "^[^/\\t\\r\\n\\u2028\\u2029]+$"
                }
            }
        }
    }
}

响应

ts
/**
 * Rename a document
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: null;
    /**
     * status message
     */
    readonly msg: string;
}
json5
/**
 * schemas/kernel/api/filetree/renameDoc/response.schema.json5
 * 重命名文档
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#rename-a-document
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/filetree.go#L317-L341
 * @pathname: /api/filetree/renameDoc
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/renameDoc/response.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Rename a document',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    type: 'null',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/renameDoc/response.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Rename a document",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "null"
                }
            }
        }
    }
}

searchDocs

  • 🛠 搜索文档
  • /api/filetree/searchDocs

请求

ts
/**
 * Search Document by Keyword
 */
export interface IPayload {
    /**
     * whether is flashcard
     */
    readonly flashcard?: boolean;
    /**
     * keyword
     */
    readonly k: string;
}
json5
/**
 * schemas/kernel/api/filetree/searchDocs/payload.schema.json5
 * 通过关键词搜索文档
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.0/kernel/api/filetree.go#L599-L615
 * @pathname: /api/filetree/searchDocs
 * @version: 2.10.0
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/searchDocs/payload.schema.json5',
    $comment: 'v2.10.0',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Search Document by Keyword',

            type: 'object',
            additionalProperties: false,
            required: [
                'k',
            ],
            properties: {
                k: {
                    // 关键字
                    type: 'string',
                    minLength: 1,
                    description: 'keyword',
                },
                flashcard: {
                    // 是否是复习卡片
                    type: 'boolean',
                    description: 'whether is flashcard',
                    default: false,
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/searchDocs/payload.schema.json",
    "$comment": "v2.10.0",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Search Document by Keyword",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "k"
            ],
            "properties": {
                "k": {
                    "type": "string",
                    "minLength": 1,
                    "description": "keyword"
                },
                "flashcard": {
                    "type": "boolean",
                    "description": "whether is flashcard",
                    "default": false
                }
            }
        }
    }
}

响应

ts
/**
 * Search Document by Keyword
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    /**
     * document info list
     */
    readonly data: IDocInfo[];
    /**
     * status message
     */
    readonly msg: string;
}

export interface IDocInfo {
    /**
     * Document Block ID
     */
    readonly box: string;
    /**
     * Notebook icon
     */
    readonly boxIcon: string;
    /**
     * Number of expired cards
     */
    readonly dueFlashcardCount?: number;
    /**
     * Total number of cards
     */
    readonly flashcardCount?: number;
    /**
     * The readable path that contains the name of the notebook
     */
    readonly hPath: string;
    /**
     * Number of new cards
     */
    readonly newFlashcardCount?: number;
    /**
     * Directory path
     */
    readonly path: string;
    [property: string]: any;
}
json5
/**
 * schemas/kernel/api/filetree/searchDocs/response.schema.json5
 * 通过关键词搜索文档
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.0/kernel/api/filetree.go#L599-L615
 * @pathname: /api/filetree/searchDocs
 * @version: 2.10.0
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/searchDocs/response.schema.json5',
    $comment: 'v2.10.0',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Search Document by Keyword',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    type: 'array',
                    description: 'document info list',

                    items: {
                        $ref: '#/$defs/datum',
                    },
                },
            },
        },
        datum: {
            title: 'IDocInfo',
            type: 'object',
            additionalProperties: true,
            required: [
                'box',
                'boxIcon',
                'hPath',
                'path',
            ],
            properties: {
                box: {
                    // 笔记本 ID
                    type: 'string',
                    description: 'Document Block ID',
                    pattern: '^\\d{14}-[0-9a-z]{7}$',
                },
                boxIcon: {
                    // 笔记本图标
                    type: 'string',
                    description: 'Notebook icon',
                    examples: [
                        '1f3d8',
                        'icon.svg',
                        'folder/icon.png',
                    ],
                },
                hPath: {
                    // 包含笔记本名称的可读路径
                    type: 'string',
                    description: 'The readable path that contains the name of the notebook',
                    pattern: '^[^/]+/|[^/]+(/[^/]+)+$',
                    examples: [
                        'notebook/',
                        'notebook/document1',
                        'notebook/document1/document2',
                    ],
                },
                path: {
                    // 目录路径
                    type: 'string',
                    description: 'Directory path',
                    pattern: '^/|(/\\d{14}-[0-9a-z]{7})+\\.sy$',
                    examples: [
                        '/',
                        '/20200812220555-lj3enxa.sy',
                        '/20200812220555-lj3enxa/20210808180320-fqgskfj.sy',
                    ],
                },
                flashcardCount: {
                    // 总卡片数量
                    type: 'integer',
                    description: 'Total number of cards',
                    minimum: 0,
                },
                newFlashcardCount: {
                    // 新卡片数量
                    type: 'integer',
                    description: 'Number of new cards',
                    minimum: 0,
                },
                dueFlashcardCount: {
                    // 到期卡片数量
                    type: 'integer',
                    description: 'Number of expired cards',
                    minimum: 0,
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/filetree/searchDocs/response.schema.json",
    "$comment": "v2.10.0",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Search Document by Keyword",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "type": "array",
                    "description": "document info list",
                    "items": {
                        "$ref": "#/$defs/datum"
                    }
                }
            }
        },
        "datum": {
            "title": "IDocInfo",
            "type": "object",
            "additionalProperties": true,
            "required": [
                "box",
                "boxIcon",
                "hPath",
                "path"
            ],
            "properties": {
                "box": {
                    "type": "string",
                    "description": "Document Block ID",
                    "pattern": "^\\d{14}-[0-9a-z]{7}$"
                },
                "boxIcon": {
                    "type": "string",
                    "description": "Notebook icon",
                    "examples": [
                        "1f3d8",
                        "icon.svg",
                        "folder/icon.png"
                    ]
                },
                "hPath": {
                    "type": "string",
                    "description": "The readable path that contains the name of the notebook",
                    "pattern": "^[^/]+/|[^/]+(/[^/]+)+$",
                    "examples": [
                        "notebook/",
                        "notebook/document1",
                        "notebook/document1/document2"
                    ]
                },
                "path": {
                    "type": "string",
                    "description": "Directory path",
                    "pattern": "^/|(/\\d{14}-[0-9a-z]{7})+\\.sy$",
                    "examples": [
                        "/",
                        "/20200812220555-lj3enxa.sy",
                        "/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
                    ]
                },
                "flashcardCount": {
                    "type": "integer",
                    "description": "Total number of cards",
                    "minimum": 0
                },
                "newFlashcardCount": {
                    "type": "integer",
                    "description": "Number of new cards",
                    "minimum": 0
                },
                "dueFlashcardCount": {
                    "type": "integer",
                    "description": "Number of expired cards",
                    "minimum": 0
                }
            }
        }
    }
}