↗

事件 JSON Schema

事件信封与各类 data 的 JSON Schema(draft 2020-12)。

GEThttps://api.tokenearly.com/v1/schema

无需 Key,不计入限频。可直接用于校验收到的事件或生成类型定义。

公开接口,无需 Key

参数

没有参数。

在线调试
申请试用 Key

填入你的 API Key(正式 Key,或在控制台申请的试用 Key)即可调用真实接口;Key 只保存在你的浏览器里。

响应

错误

—

curl "https://api.tokenearly.com/v1/schema"
import requests

resp = requests.get("https://api.tokenearly.com/v1/schema", timeout=10)
resp.raise_for_status()
print(resp.json())
// Node 18+ (built-in fetch)
async function main() {
  const resp = await fetch("https://api.tokenearly.com/v1/schema");
  console.log(await resp.json());
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://api.tokenearly.com/v1/schema", nil)
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.Status, string(body))
}
示例响应
{
  "spec_version": "1.0",
  "event": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://api.tokenearly.com/v1/schema/event",
    "title": "Tokenearly event",
    "allOf": [
      "…"
    ],
    "$defs": {
      "announcement": "…",
      "news": "…",
      "signal": "…",
      "twitter": "…"
    }
  },
  "envelope": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Tokenearly event envelope",
    "type": "object",
    "required": [
      "spec_version",
      "id",
      "revision",
      "action",
      "topic",
      "type",
      "source",
      "published_at",
      "detected_at_ms",
      "data"
    ],
    "properties": {
      "id": {
        "type": "string",
        "description": "Stable event id (24 hex characters) shared by every revision; never changes. Ids increase with the time the event was first stored and compare correctly as strings. Also the pagination and resume cursor."
      },
      "…": "…"
    }
  },
  "data": {
    "announcement": {
      "title": "announcement data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    },
    "news": {
      "title": "news data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    },
    "signal": {
      "title": "signal data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    },
    "twitter": {
      "title": "twitter data",
      "type": "object",
      "properties": {
        "…": "…"
      }
    }
  }
}