认证、权限范围 & 套餐
API 密钥
密钥有三种传法,在所有 REST 接口和实时流(WebSocket)上都同样有效:Authorization: Bearer xsf_…、X-API-Key 请求头,或者 URL 里的 ?api_key=(给浏览器用的,浏览器无法在 WebSocket 握手时设置请求头)。如果同时传了多种,优先用 Authorization,其次 X-API-Key,最后 api_key。不存在的密钥和已吊销的密钥会分别报错:invalid_api_key 表示检查是否拼错或用了旧密钥,key_revoked 表示请联系发放密钥的人。
权限范围
密钥携带若干权限范围(scope)。超出范围的调用返回 403,并以 {"error":{"code":"scope_required"}} 指明你缺少的 scope。GET /v1/account 列出你拥有的;GET /v1/meta/scopes 列出全部。
| 权限范围 | 允许的操作 |
|---|---|
| targets:read | 列出此密钥监控的账号 |
| targets:write | 添加、修改和移除被监控账号,单个或批量 |
| keywords:read | 列出关键词并接收 search.match 事件 |
| keywords:write | 添加和移除关键词 |
| stream | 打开 WebSocket |
| replay | 使用 last_id 和 GET /v1/events |
| webhook | 配置 Webhook 投递 |
| reads | 按需 REST 读取资料、帖子、粉丝、关注列表;消耗额度 |
管理类 scope 仅供我们自己的运营方使用,且通过单独的私有接口提供。客户密钥永远不会携带这类 scope。
套餐
套餐是 scope 与上限的预设组合;任何密钥都可以单独调整。实时矩阵见 GET /v1/meta/plans。价格不在此公布。
| 套餐 | 监控目标 | 关键词 | 连接数 | 请求数 / 分钟 | 权限范围 |
|---|---|---|---|---|---|
| starter | 50 | 0 | 2 | 300 | targets:read, targets:write, stream, replay, reads, webhook |
| pro | 200 | 20 | 5 | 600 | targets:read, targets:write, stream, replay, reads, webhook, keywords:read, keywords:write |
| scale | 1000 | 100 | 10 | 900 | targets:read, targets:write, keywords:read, keywords:write, stream, replay, webhook, reads |
| ultra | 2000 | 300 | 20 | 1200 | targets:read, targets:write, keywords:read, keywords:write, stream, replay, webhook, reads |