变更通知
限额调整、Key 变更与接口更新的记录。
返回与这把 Key 有关的通知:全体接入方的公告、你的账号的调整、这把 Key 自己的变更,按时间倒序。全体与账号级的通知不按 Key 的创建时间过滤:新建的 Key 也能看到它创建之前发布的这些通知;Key 级通知从这把 Key 创建后才会有。实时流在线时同样的通知会以 op = "notice" 立即推送;离线后用 since 补拉。
需要 API Key
参数
sinceintegerquery可选只返回这个时间(Unix 秒)之后的通知;0 = 全部。
limitintegerquery可选最多返回条数,1–200,默认 50。
响应
错误
| 错误码 | HTTP | 说明 |
|---|---|---|
missing_api_key | 401 | 没有带 Key。用 Authorization: Bearer <Key>。 |
invalid_api_key | 401 | Key 不存在,或已被重置 / 吊销。 |
key_expired | 401 | 试用 Key 已到期。重新申请试用 Key,或开通后创建正式 Key。 |
plan_required | 403 | 当前套餐不含开发者 API,或不含该项能力。 |
ip_not_allowed | 403 | 这把 Key 设置了 IP 白名单,请求来源 IP 不在其中。 |
invalid_parameter | 400 | 参数类型或取值不合法(例如 limit 超出范围)。 |
rate_limited | 429 | 超过这把 Key 的请求频率(REST 与 MCP 合计,间隔见 /v1/me 的 limits.rest_interval_seconds);按 Retry-After 头等待后重试。 |
curl "https://api.tokenearly.com/v1/notices?limit=10" \
-H "Authorization: Bearer $TOKENEARLY_API_KEY"import os, requests
resp = requests.get(
"https://api.tokenearly.com/v1/notices?limit=10",
headers={"Authorization": f"Bearer {os.environ['TOKENEARLY_API_KEY']}"},
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/notices?limit=10", {
headers: { Authorization: `Bearer ${process.env.TOKENEARLY_API_KEY}` },
});
const body = await resp.json();
if (!resp.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
console.log(body);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.tokenearly.com/v1/notices?limit=10", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("TOKENEARLY_API_KEY"))
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))
}示例响应
{
"notices": [
{
"id": "ntc_3f9c2a71d0b84e6c5a12",
"kind": "key_limits_changed",
"scope": "key",
"key_id": "key_8d2f0c1b7a6e4d3c2b1a",
"title": {
"zh": "API Key 限额已调整",
"en": "API key limits changed",
"ko": "API 키 한도 변경"
},
"body": {
"zh": "te_live_Ab12… 每把 Key 的实时连接数: 1 → 2",
"en": "te_live_Ab12… Stream connections per key: 1 → 2",
"ko": "te_live_Ab12… 키당 실시간 연결 수: 1 → 2"
},
"data": {
"key_id": "key_8d2f0c1b7a6e4d3c2b1a",
"prefix": "te_live_Ab12",
"changes": {
"streams_per_key": [
1,
2
]
}
},
"created_at": 1794208744
}
]
}通知类型
| kind | scope | 含义 |
|---|---|---|
defaults_changed | global | 默认限额调整(带旧值 → 新值) |
account_limits_changed | user | 你的账号限额调整 |
key_limits_changed | key | 某把 Key 的限额调整 |
ip_allowlist_changed | key | 某把 Key 的 IP 白名单修改(data.before / data.after) |
key_reset | key | 某把 Key 被重置(data.old_prefix / data.prefix 为新旧前缀;发给新 Key,旧 Key 的连接已断开) |
key_revoked | key | 某把 Key 被吊销 |
access_expiring | user | 含 API 的会员即将到期(7 / 3 / 1 天前各一次,data.expires_at 为到期时间) |
access_expired | user | 含 API 的会员已到期,Key 将以 403 plan_required / 4003 被拒,续费后原 Key 自动恢复 |
api_update | global | 接口更新公告 |
scope:global= 全体接入方,user= 你的账号,key= 某把 Key(看key_id)。data.changes是{项: [旧值, 新值]},null表示「默认值」。since是开区间(只返回严格晚于这个时间的通知);每次最多 200 条,没有分页游标——把最后一条的created_at作为下一次的since即可。