Authentication, Rate Limits & Quotas
OursMeme AI Agent API follows standard exchange-style API Key authentication + dual-window rate limiting, while replacing email/password onboarding with a single gasless wallet signature.
1. API Key Lifecycle
- One Key per Wallet: Keyed by wallet address (
wallet PRIMARY KEY), so each wallet has at most 1 active API Key. - Atomic Rotation: Re-issuing via
POST /api/v1/agent/keysatomically overwrites the previous hash and evicts the cache; the old key immediately returns HTTP401. - Shown Once Only: Only
HMAC-SHA256(pepper, rawKey)is stored server-side. If lost, simply sign again to rotate. - Instant Revocation: Call
DELETE /api/v1/agent/keys/mewith a logged-in wallet JWT or anaction=revokewallet signature. - Key Prefixes:
- BSC Mainnet (Chain ID 56):
mpk_live_<base64url> - BSC Testnet (Chain ID 97):
mpk_test_<base64url>
- BSC Mainnet (Chain ID 56):
2. Authentication Headers
Supported across both HTTP tool endpoints and Remote MCP (POST /api/mcp, POST /api/baw/mcp):
http
X-API-Key: mpk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxor:
http
Authorization: Bearer mpk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxPassing an invalid, overwritten, or revoked API Key always returns HTTP
401 Unauthorized.
3. Per-Minute Rate Limits & UTC Daily Quotas (HTTP 429)
Quotas are enforced independently per wallet API Key:
| Dimension | Default Limit (Phase 1) | Window | HTTP Status | data.reason |
|---|---|---|---|---|
| Per-Minute Total | 60 req / min | 60s fixed window | 429 | rate_limit_minute_exceeded |
| Per-Minute Heavy / Builders | 20 req / min | 60s fixed window | 429 | rate_limit_heavy_exceeded |
| Daily Total Quota | 2,000 req / day | UTC calendar day (resets 00:00 UTC) | 429 | daily_quota_exceeded |
| Key Rotation Limit | 10 rotations / hour | 1-hour window | 429 | — |
Standard Response Headers
X-RateLimit-Limit/X-RateLimit-Remaining/X-RateLimit-ResetX-DailyLimit-Limit/X-DailyLimit-Remaining/X-DailyLimit-ResetRetry-After(returned on HTTP429)
Example 429 Error Body
json
{
"code": 500,
"msg": "Daily API Key quota reached (2000/day, resets at 00:00 UTC). Retry in 14280 seconds.",
"data": {
"retryAfterSec": 14280,
"tier": "wallet_daily",
"reason": "daily_quota_exceeded",
"limit": 2000,
"used": 2000,
"resetAt": 1764028800
}
}4. API Categories & Phase-2 Credit Mode
In Phase 1 every tool consumes 1 unit. All 48 tools are pre-classified into 5 categories (x-category and x-credit-cost in OpenAPI) so enabling Phase-2 Credit Mode requires zero client-side breaking changes:
Category (x-category) | Example Tools | Phase 1 Cost | Phase 2 Credit Weight |
|---|---|---|---|
public_meta | get_rules, get_launch_params | 1 | 1 |
market_light | get_price, get_overview, list_markets, get_candles | 1 | 1 |
account_read | get_account, get_account_trades, get_account_stats, get_account_rewards, get_account_referrals | 1 | 2 |
tx_build | build_open_position, build_close_position, build_deposit_lp, all build_* | 1 | 3 |
analytics_heavy | get_leaderboard, get_market_positions, get_market_economics, get_stats | 1 | 5 |
5. Personal Account Privacy Isolation
The following 5 personal endpoints enforce strict ownership checks:
get_account(positions, balances, claimables, and private pending orders)get_account_tradesget_account_statsget_account_rewardsget_account_referrals
Access policy:
- Unauthenticated caller (no API Key or wallet JWT) →
401 Unauthorized. - Owner wallet API Key (
apiKey.wallet === account) →200 OK(full data includingorders). - Active on-chain authorized subaccount API Key (
SubaccountRouterauthorized, unexpired, remaining actions > 0) →200 OK(full data includingorders, enabling autonomous bots to reconcile and cancel orders). - Any unrelated wallet API Key →
403 Forbidden.