认证、权限范围 & 套餐

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。价格不在此公布。

套餐监控目标关键词连接数请求数 / 分钟权限范围
starter5002300targets:read, targets:write, stream, replay, reads, webhook
pro200205600targets:read, targets:write, stream, replay, reads, webhook, keywords:read, keywords:write
scale100010010900targets:read, targets:write, keywords:read, keywords:write, stream, replay, webhook, reads
ultra2000300201200targets:read, targets:write, keywords:read, keywords:write, stream, replay, webhook, reads