/api/storage
getLocalStorage
- 🛠 获取持久化的本地存储数据
/api/storage/getLocalStorage
响应
ts
/**
* Get persisted locally stored content
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: { [key: string]: any };
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/kernel/api/storage/getLocalStorage/response.schema.json5
* 获取持久化的本地存储内容
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.12/kernel/api/storage.go#L176-L182
* @pathname: /api/storage/getLocalStorage
* @version: 2.10.12
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/storage/getLocalStorage/response.schema.json5',
$comment: 'v2.10.12',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get persisted locally stored content',
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: 'Local storage key-value pairs',
type: 'object',
additionalProperties: true,
propertyNames: {
type: 'string',
},
required: [],
properties: {},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/storage/getLocalStorage/response.schema.json",
"$comment": "v2.10.12",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get persisted locally stored content",
"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": "Local storage key-value pairs",
"type": "object",
"additionalProperties": true,
"propertyNames": {
"type": "string"
},
"required": [],
"properties": {}
}
}
}
getRecentDocs
- 🛠 获取最近打开的文档
/api/storage/getRecentDocs
响应
ts
/**
* Get the most recently updated documentation
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
/**
* document info list
*/
readonly data: IDocInfo[] | null;
/**
* status message
*/
readonly msg: string;
}
export interface IDocInfo {
/**
* Document icon
*/
readonly icon: string;
/**
* Document Block ID
*/
readonly rootID: string;
/**
* Document title
*/
readonly title: string;
}
json5
/**
* schemas/kernel/api/storage/getRecentDocs/response.schema.json5
* 获取最近更新的文档
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.0/kernel/api/storage.go#L28-L39
* @pathname: /api/storage/getRecentDocs
* @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/storage/getRecentDocs/response.schema.json5',
$comment: 'v2.10.0',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get the most recently updated documentation',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: [
'array',
'null',
],
description: 'document info list',
items: {
$ref: '#/$defs/datum',
},
},
},
},
datum: {
title: 'IDocInfo',
type: 'object',
additionalProperties: false,
required: [
'rootID',
'icon',
'title',
],
properties: {
rootID: {
// 文档块 ID
type: 'string',
description: 'Document Block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
icon: {
// 文档图标
type: 'string',
description: 'Document icon',
examples: [
'1f3d8',
'icon.svg',
'folder/icon.png',
],
},
title: {
// 文档标题
type: 'string',
description: 'Document title',
pattern: '^[^/]+$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/storage/getRecentDocs/response.schema.json",
"$comment": "v2.10.0",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get the most recently updated documentation",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": [
"array",
"null"
],
"description": "document info list",
"items": {
"$ref": "#/$defs/datum"
}
}
}
},
"datum": {
"title": "IDocInfo",
"type": "object",
"additionalProperties": false,
"required": [
"rootID",
"icon",
"title"
],
"properties": {
"rootID": {
"type": "string",
"description": "Document Block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"icon": {
"type": "string",
"description": "Document icon",
"examples": [
"1f3d8",
"icon.svg",
"folder/icon.png"
]
},
"title": {
"type": "string",
"description": "Document title",
"pattern": "^[^/]+$"
}
}
}
}
}
setLocalStorage
- 🛠 持久化本地存储数据
/api/storage/setLocalStorage
请求
ts
/**
* Persist local storage data
*/
export interface IPayload {
/**
* App ID
*/
readonly app?: string;
readonly val: { [key: string]: any };
}
json5
/**
* schemas/kernel/api/storage/setLocalStorage/payload.schema.json5
* 持久化本地存储数据
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.12/kernel/api/storage.go#L152-L174
* @pathname: /api/storage/setLocalStorage
* @version: 2.10.12
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/storage/setLocalStorage/payload.schema.json5',
$comment: 'v2.10.12',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Persist local storage data',
type: 'object',
additionalProperties: false,
required: [
'val',
],
properties: {
app: {
// Web 页面应用的 ID
// globalThis.siyuan.ws.app.appId
type: 'string',
description: 'App ID',
pattern: '^[0-9a-z]{5}$',
},
val: {
$ref: '#/$defs/val',
},
},
},
val: {
// 本地存储数据的键值对
title: 'IVal',
description: 'Local storage key-value pairs',
type: 'object',
additionalProperties: true,
propertyNames: {
type: 'string',
},
required: [],
properties: {},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/storage/setLocalStorage/payload.schema.json",
"$comment": "v2.10.12",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Persist local storage data",
"type": "object",
"additionalProperties": false,
"required": [
"val"
],
"properties": {
"app": {
"type": "string",
"description": "App ID",
"pattern": "^[0-9a-z]{5}$"
},
"val": {
"$ref": "#/$defs/val"
}
}
},
"val": {
"title": "IVal",
"description": "Local storage key-value pairs",
"type": "object",
"additionalProperties": true,
"propertyNames": {
"type": "string"
},
"required": [],
"properties": {}
}
}
}
响应
ts
/**
* Persist local storage data
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: null;
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/kernel/api/storage/setLocalStorage/response.schema.json5
* 持久化本地存储数据
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.12/kernel/api/storage.go#L152-L174
* @pathname: /api/storage/setLocalStorage
* @version: 2.10.12
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/storage/setLocalStorage/response.schema.json5',
$comment: 'v2.10.12',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Persist local storage data',
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/storage/setLocalStorage/response.schema.json",
"$comment": "v2.10.12",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Persist local storage data",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "null"
}
}
}
}
}