开发者

在 01 上构建。

一切皆为纯 HTTP 与 JSON。没有需要安装的专有 SDK,也没有外部运行时。 本页记录 01 保险箱与公开开发者平台所用的端点。

Base URL。 只读端点在 https://api.01.run 公开; 收据受理在 https://ingest.01.run。发送数据之前,务必从 /health 核对 chain_id 与创世哈希。 当前网络是 01-mainnet-1。早期阶段,请为你无法承受丢失的任何内容保留一份独立副本。

认证

使用两种机制:

每个响应都是 JSON。错误使用 HTTP 状态码与 { "error": "..." }。

快速开始

终端
# 1. Health (no key)
curl https://api.01.run/health

# 2. Gateway statistics (no key)
curl https://ingest.01.run/v1/stream/stats

# 3. Write receipts in batches of up to 1000 items (API key from 01 Vault → Developer)
curl -X POST https://ingest.01.run/v1/stream/receipts \
  -H "content-type: application/json" \
  -H "x-api-key: 01ak_…" \
  -d '{"items":[
        {"payload_hash":"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824","tenant":"my-app","ref":"order-1042"},
        {"payload_hash":"486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7","tenant":"my-app"}
      ]}'

# 4. Fetch one receipt and its Merkle proof
curl https://ingest.01.run/v1/stream/receipts/rc_…

# 5. Read the public event feed
curl "https://ingest.01.run/v1/open/events?since=0&limit=50" \
  -H "x-api-key: 01ak_…"

高吞吐收据网关

如果你需要证明数百万次 API 调用确实发生过——而不必把每一次调用都写进链—— 就把每次调用作为一条收据提交。网关把收据按一秒一批归组为 Merkle 批次,并把根锚定 到 01 链上。每笔收据都可以独立验证,批次也可以跨网关聚合。

方法路径用途认证
POST/v1/stream/receipts单次请求最多受理 1000 条API Key
GET/v1/stream/receipts/:id读取一笔收据及其 Merkle 证明公开
GET/v1/stream/batches列出最近的 Merkle 批次公开
GET/v1/stream/stats收据、批次与锚定计数公开
POST/v1/stream/anchors提交子网关批次根用于聚合API Key
GET/v1/stream/anchors列出聚合锚定公开
GET/v1/stream/anchors/:id读取一个聚合锚定及其证明公开

每条请求的收据条目上限为 1000 条。载荷是哈希与元数据;请不要发送明文个人数据。

开放平台与 Webhook

订阅公开事件(已发布作品、公告、锚定),接收带签名的 Webhook 投递。 每个订阅都有独立的签名密钥;在信任载荷之前请验证 HMAC。

方法路径用途认证
GET/v1/open/events?since=&limit=公开事件的游标事件流API Key
POST/v1/open/subscriptions创建 Webhook 订阅API Key
GET/v1/open/subscriptions列出订阅API Key
DELETE/v1/open/subscriptions/:id删除订阅API Key
POST/v1/open/subscriptions/:id/test发送一次签名测试投递API Key
GET/v1/open/deliveries查看投递尝试API Key

验证 Webhook(Node.js)

verify.mjs
import express from "express";
import { createHmac, timingSafeEqual } from "node:crypto";

const app = express();
// Keep the raw bytes: signatures are computed over the exact request body.
app.use(express.json({ verify: (req, _res, buf) => { req.rawBody = buf; } }));

function verify(rawBody, header, secret) {
  const [scheme, signature] = String(header || "").split("=");
  if (scheme !== "sha256") return false;
  const expected = createHmac("sha256", secret).update(rawBody).digest();
  const a = Buffer.from(signature, "hex");
  return a.length === expected.length && timingSafeEqual(a, expected);
}

app.post("/01-webhook", (req, res) => {
  const ok = verify(req.rawBody, req.get("x-01-signature"), process.env.ZERO1_WEBHOOK_SECRET);
  if (!ok) return res.status(401).send("bad signature");
  res.status(200).send("ok");
});

01 Connect

01 Connect 让第三方应用申请一项有范围、经用户批准的声明,而不是密码。 应用由 01 身份创建;授权在用户的应用中批准,并且可以逐项撤销。

方法路径用途
POST/v1/connect/apps创建应用(用户会话)
POST/v1/connect/apps/:id/rotate-secret轮换客户端密钥
POST/v1/connect/requests创建授权请求
GET/v1/connect/lookup按客户端 ID 查询应用
POST/v1/connect/requests/:id/approve用户在设备上批准请求
POST/v1/connect/requests/:id/deny用户拒绝请求
POST/v1/connect/token用已批准的请求换取声明
POST/v1/connect/verify验证声明
GET/v1/me/connect/authorizations列出用户的授权
POST/v1/me/connect/authorizations/:id/revoke撤销一项授权

链协议

链规范、事件 Schema 与签名规则随节点源码一同发布 (chain/docs/01-chain-spec-v1.0.md)。账本只追加,存储哈希、 Merkle 根与锚定——从不存储加密数据块或明文。身份用后量子密钥签署事件; 验证者会拒绝签名无效或序列号过期的事件。

查看实时网络状态 → 安全模型 →


安全问题报告:security@01.run。请不要为漏洞提交公开 issue。 本文档描述 01-mainnet-1,会随网络演进扩展;创世规则本身不会改变。