鉴权
| 凭据 | 用途 | 位置 | 有效期 |
|---|---|---|---|
| session cookie | Web UI(app.panshi.io)登录态 | 浏览器自动携带 | 30 天 |
| api_key | 服务端 REST / WebSocket 调用 | Authorization: Bearer <key> | 长期,可吊销 |
| webhook_token | TradingView webhook 鉴权 | URL path:/webhook/tv/<token> | 长期,可吊销 |
用途不同,不要互相混用。
session cookie
Section titled “session cookie”登录后浏览器自动持有。Cookie 域是 .panshi.io,对 app / docs / api 三个子域同源可用;HttpOnly、Secure。点右上头像 → 注销立即吊销。
api_key
Section titled “api_key”- 登录 app.panshi.io → 设置 → API Keys
- 新建 → 填写用途备注 → 一次性显示 key(关闭即不可再查看,只能吊销重建)
- 服务端调用:
curl -H "Authorization: Bearer <your_api_key>" \ https://api.panshi.io/v1/portfolios/my怀疑泄漏:设置里删除 → 立即失效。历史数据保留,后续该 key 无法再下单。
webhook_token
Section titled “webhook_token”TradingView Alert 的 Webhook 不能加 HTTP header,因此鉴权放进 URL path。
- 组合详情页 → Webhook 面板 → 生成
- 系统返回形如:
https://api.panshi.io/webhook/tv/<webhook_token>- 把这个 URL 贴到 TradingView Alert 的 Webhook 栏
见 速率限制。不同凭据独立计费,超限返回 429 Too Many Requests + Retry-After 头。
最小权限原则
Section titled “最小权限原则”- 只给脚本必要的能力(读 / 写)
- 定期复盘 API Keys 列表,删掉不再用的
- 生产脚本 / 开发脚本用不同 key,一旦泄漏爆炸半径小