ServerAPIv1.1.0

回應格式Response format

成功與失敗使用同一層信封,呼叫端先看 ok 分流即可,內容永遠在 data

{ "ok": true,  "data": { … }, "meta": { … } }
{ "ok": false, "error": { "status": 404, "message": "…", "path": "…" }, "meta": { … } }
一次完整的請求與回應,並標出 ok、data、meta 三個欄位

meta 的兩個時間戳

欄位出現於意義
updatedAt所有端點本次回應產生的時間
cachedAt快照端點資料實際擷取的時間

updatedAt - cachedAt 就是這份資料的陳舊程度。要「資料真正的時間」請用 cachedAt;快照尚未完成第一次擷取時為 null

快照間隔

需要主執行緒才安全的資料由主執行緒定期快照,HTTP 請求只讀快取,因此請求量再大也不影響 TPS。 可在 cache 區塊各自調整(單位為 tick,20 tick = 1 秒)。

端點預設理由
status5 秒最即時,成本也最低
entities20 秒需遍歷所有實體,最耗費
worlds / gamerules / spawnlimits10 分鐘變動慢

Success and failure share one envelope. Branch on ok; the payload is always in data.

{ "ok": true,  "data": { … }, "meta": { … } }
{ "ok": false, "error": { "status": 404, "message": "…", "path": "…" }, "meta": { … } }
A full request and response, with the ok, data and meta fields called out

The two timestamps in meta

FieldPresent onMeaning
updatedAtevery endpointWhen this response was produced
cachedAtsnapshot endpointsWhen the data was actually captured

updatedAt - cachedAt is how stale the payload is. Use cachedAt for the real age of the data; it is null until the first snapshot completes.

Snapshot intervals

Data that is only safe to read on the main thread is snapshotted there on a timer, and HTTP requests only ever read the cache, so traffic cannot drag down TPS. Tune each one in the cache block (values are in ticks, 20 ticks = 1 second).

EndpointDefaultWhy
status5sFreshest and cheapest
entities20sWalks every entity, the expensive one
worlds / gamerules / spawnlimits10mRarely change
ServerAPI · 僅供非商業用途,商業伺服器需另行取得授權。
ServerAPI · Free for non-commercial use; commercial servers need a separate licence.
Copyright © 2021-2026 CloudXact Studio. All Rights Reserved.