fix rate limit handling for skills

This commit is contained in:
deepfeature
2026-04-01 11:05:47 +08:00
parent 09351a9205
commit 221bf120a8
7 changed files with 340 additions and 31 deletions
+16
View File
@@ -58,6 +58,22 @@ Use the `gmgn-cli` tool to query K-line data for a token, browse trending tokens
- `gmgn-cli` installed globally — if missing, run: `npm install -g gmgn-cli`
- `GMGN_API_KEY` configured in `~/.config/gmgn/.env`
## Rate Limit Handling
All market routes used by this skill go through GMGN's leaky-bucket limiter with `rate=10` and `capacity=10`. Sustained throughput is roughly `10 ÷ weight` requests/second, and the max burst is roughly `floor(10 ÷ weight)` when the bucket is full.
| Command | Route | Weight |
|---------|-------|--------|
| `market kline` | `GET /v1/market/token_kline` | 2 |
| `market trending` | `GET /v1/market/rank` | 1 |
| `market trenches` | `POST /v1/trenches` | 3 |
When a request returns `429`:
- Read `X-RateLimit-Reset` from the response headers. It is a Unix timestamp in seconds that marks when the limit is expected to reset.
- The CLI may wait and retry once automatically when the remaining cooldown is short. If it still fails, stop and tell the user the exact retry time instead of sending more requests.
- For `RATE_LIMIT_EXCEEDED` or `RATE_LIMIT_BANNED`, repeated requests during the cooldown can extend the ban by 5 seconds each time, up to 5 minutes. Do not spam retries.
**First-time setup** (if `GMGN_API_KEY` is not configured):
1. Generate key pair and show the public key to the user: