Manifest
GET
/api/v1Manifest 用于发现 API 版本、Worker 版本、认证模式、扩展能力和端点地址。集成初始化时应先读取它,而不是假设部署一定支持所有功能。
请求
bash
curl -fsSL https://YOUR-API/api/v1响应示例
json
{
"ok": true,
"api_version": "v1",
"worker_version": "1.0.0",
"stability": "stable",
"base_url": "https://api.example.com/api/v1",
"authentication": {
"read": "none",
"write": "not_available"
},
"cors": {
"mode": "explicit-origin-allowlist",
"environment": "DEVELOPER_API_ORIGINS"
},
"extensions": {
"alternate_frontends": true,
"themes": true,
"read_only_plugins": true,
"privileged_plugins": false
},
"endpoints": [
{
"method": "GET",
"url": "https://api.example.com/api/v1/status",
"path": "/status",
"description": "Public status, targets, summaries, incidents, and current telemetry"
}
]
}endpoints 实际会列出全部公开端点,示例只保留一项以便阅读。
字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
api_version | string | 当前公开协议版本 |
worker_version | string | 当前 Worker 应用版本 |
stability | string | 接口稳定性等级 |
base_url | URL | v1 端点基础地址 |
authentication.read | string | 公开读取是否需要认证 |
authentication.write | string | 第三方写入是否开放 |
cors | object | 浏览器访问策略与配置变量 |
extensions | object | 当前扩展能力开关 |
endpoints | array | 服务端实际提供的端点清单 |
能力协商
替代前端应检查:
js
const manifest = await fetch(`${apiBase}/api/v1`, {
credentials: 'omit',
}).then(response => response.json())
if (manifest.api_version !== 'v1') {
throw new Error('Unsupported NIE-SLA API version')
}
const canLoadThemes = manifest.extensions?.themes === true不要根据 worker_version 字符串推断功能;使用 extensions 和 endpoints 做能力检测。