Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:memo: Document public API behavior semantics https://github.com/siyuan-note/siyuan/issues/18516

Daniel9751c2d231db
diff --git a/docs/API.ja.md b/docs/API.ja.md
index 785a3916ae..3a96914d61 100644
--- a/docs/API.ja.md
+++ b/docs/API.ja.md
@@ -4,6 +4,7 @@
* [仕様](#仕様)
* [パラメータと戻り値](#パラメータと戻り値)
+ * [動作セマンティクス](#動作セマンティクス)
* [認証](#認証)
* [ノートブック](#ノートブック)
* [ノートブック一覧を取得](#ノートブック一覧を取得)
@@ -112,6 +113,15 @@
* `msg`: 通常は空文字列、異常時にはエラーテキストが返される
* `data`: インターフェースによって`{}`、`[]`、または`NULL`となる
+### 動作セマンティクス
+
+* 本文書に個別のインターフェース説明があるものだけが公開 API です。その他のカーネルルートと `/api/transactions` の操作は内部実装であり、別途明記されていない限り、互換性や動作の安定性は保証されません
+* `code: 0` は、リクエストの処理中にインターフェースからエラーが報告されなかったことを示します。保証されるのは各インターフェースに明記された結果のみであり、関連するインデックス、キャッシュ、WebSocket ブロードキャスト、同期状態の更新完了を意味するものではありません
+* 省略されたフィールド、`null`、空のオブジェクト、空の配列の意味はインターフェースごとに定義されます。オブジェクトや配列が既存の状態を置換、マージ、または部分的に更新するか、および順序に意味があるかについても、各インターフェースの説明に従います
+* インターフェースは入力を切り詰め、無視、補完、または変換する場合があります。正規化された結果を返すことが説明されている場合、呼び出し側は返された `data` を実際に受け入れられた結果として使用してください
+* 操作名だけから読み取り専用であると判断しないでください。永続化を伴う副作用がある場合、各インターフェースでその影響範囲を説明します
+* 同じリクエストの反復が冪等または安全に再試行できるのは、明記されている場合に限ります。レスポンスが中断されるなど結果を確定できない場合は、可能な限り再試行前に現在の状態を読み取ってください
+
### 認証
<kbd>設定 - 認証 - API トークン</kbd> で API トークンを確認し、リクエストヘッダーに `Authorization: Token xxx` を設定
@@ -1010,6 +1020,8 @@
}
```
+* 決定性:返される Kramdown ではブロックレベル IAL 属性の順序が正規化され、ブロックの内容と属性が変更されない限り、その順序は安定します
+
### 子ブロックを取得
* `/api/block/getChildBlocks`
diff --git a/docs/API.md b/docs/API.md
index 1a904327a8..3bc8e09d38 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -4,6 +4,7 @@
* [Specification](#Specification)
* [Parameters and return values](#Parameters-and-return-values)
+ * [Behavior semantics](#Behavior-semantics)
* [Authentication](#Authentication)
* [Notebooks](#Notebooks)
* [List notebooks](#List-notebooks)
@@ -112,6 +113,15 @@
* `msg`: an empty string under normal circumstances, an error text will be returned under abnormal conditions
* `data`: may be `{}`, `[]` or `NULL`, depending on the interface
+### Behavior semantics
+
+* Only interfaces with dedicated interface sections in this document are public APIs. Other kernel routes and `/api/transactions` operations are internal implementations and provide no compatibility or behavioral stability guarantees unless otherwise stated
+* `code: 0` means the interface reported no error while handling the request. It guarantees only the outcome explicitly documented for that interface; it does not mean that related indexes, caches, WebSocket broadcasts, or sync state have all been updated
+* The meanings of omitted fields, `null`, empty objects, and empty arrays are interface-specific. Whether an object or array replaces, merges with, or partially updates existing state, and whether its order is significant, are also defined by each interface
+* An interface may trim, ignore, complete, or transform input. When its documentation states that a normalized result is returned, callers should use the returned `data` as the actual accepted result
+* Do not infer that an operation is read-only from its name. Persistent side effects and their scope are described by each interface when applicable
+* Repeating the same request is idempotent or safe to retry only when explicitly documented. If a response is interrupted or otherwise indeterminate, read the current state before retrying whenever possible
+
### Authentication
View the API token in <kbd>Settings - Authentication - API token</kbd>. Use it in the request header: `Authorization: Token xxx`
@@ -1016,6 +1026,8 @@ Move documents by `id`:
}
```
+* Determinism: The returned Kramdown canonicalizes block-level IAL attribute ordering; the order remains stable while the block content and attributes are unchanged
+
### Get child blocks
* `/api/block/getChildBlocks`
diff --git a/docs/API.zh-CN.md b/docs/API.zh-CN.md
index 6f5557f778..df361a63fb 100644
--- a/docs/API.zh-CN.md
+++ b/docs/API.zh-CN.md
@@ -4,6 +4,7 @@
* [规范](#规范)
* [参数和返回值](#参数和返回值)
+ * [行为语义](#行为语义)
* [鉴权](#鉴权)
* [笔记本](#笔记本)
* [列出笔记本](#列出笔记本)
@@ -112,6 +113,15 @@
* `msg`:正常情况下是空字符串,异常情况下会返回错误文案
* `data`:可能为 `{}`、`[]` 或者 `NULL`,根据不同接口而不同
+### 行为语义
+
+* 只有在本文档中设有独立接口说明的接口属于公开 API。其他内核路由和 `/api/transactions` 操作属于内部实现,除非另有说明,否则不承诺兼容性和行为稳定性
+* `code: 0` 表示接口处理请求时未报告错误,只保证该接口明确说明的结果,不表示相关索引、缓存、WebSocket 广播或同步状态均已更新
+* 省略字段、`null`、空对象和空数组的含义由各接口定义。对象或数组是替换、合并还是局部修改现有状态,以及顺序是否具有意义,也以各接口说明为准
+* 接口可能裁剪、忽略、补全或转换输入。接口说明会返回规范化结果时,调用方应将返回的 `data` 作为实际接受的结果
+* 不要根据操作名称推断其为只读操作。存在持久化副作用时,各接口会说明其影响范围
+* 只有接口明确说明时,相同请求才保证幂等或可以安全重试。响应中断或结果无法确定时,应尽可能先读取当前状态再决定是否重试
+
### 鉴权
在 <kbd>设置 - 鉴权 - API token</kbd> 中查看 API token,请求标头:`Authorization: Token xxx`
@@ -1010,6 +1020,8 @@
}
```
+* 确定性:返回的 Kramdown 会规范化块级 IAL 属性顺序;块内容和属性未变化时,属性顺序保持稳定
+
### 获取子块
* `/api/block/getChildBlocks`