Skip to content

Authentication, Rate Limits & Quotas ​

MemePerp 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 ​

  1. One Key per Wallet: Keyed by wallet address (wallet PRIMARY KEY), so each wallet has at most 1 active API Key.
  2. Atomic Rotation: Re-issuing via POST /api/v1/agent/keys atomically overwrites the previous hash and evicts the cache; the old key immediately returns HTTP 401.
  3. Shown Once Only: Only HMAC-SHA256(pepper, rawKey) is stored server-side. If lost, simply sign again to rotate.
  4. Instant Revocation: Call DELETE /api/v1/agent/keys/me with a logged-in wallet JWT or an action=revoke wallet signature.
  5. Key Prefixes:
    • BSC Mainnet (Chain ID 56): mpk_live_<base64url>
    • BSC Testnet (Chain ID 97): mpk_test_<base64url>

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_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

or:

http
Authorization: Bearer mpk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Passing 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:

DimensionDefault Limit (Phase 1)WindowHTTP Statusdata.reason
Per-Minute Total60 req / min60s fixed window429rate_limit_minute_exceeded
Per-Minute Heavy / Builders20 req / min60s fixed window429rate_limit_heavy_exceeded
Daily Total Quota2,000 req / dayUTC calendar day (resets 00:00 UTC)429daily_quota_exceeded
Key Rotation Limit10 rotations / hour1-hour window429—

Standard Response Headers ​

  • X-RateLimit-Limit / X-RateLimit-Remaining / X-RateLimit-Reset
  • X-DailyLimit-Limit / X-DailyLimit-Remaining / X-DailyLimit-Reset
  • Retry-After (returned on HTTP 429)

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 ToolsPhase 1 CostPhase 2 Credit Weight
public_metaget_rules, get_launch_params11
market_lightget_price, get_overview, list_markets, get_candles11
account_readget_account, get_account_trades, get_account_stats, get_account_rewards, get_account_referrals12
tx_buildbuild_open_position, build_close_position, build_deposit_lp, all build_*13
analytics_heavyget_leaderboard, get_market_positions, get_market_economics, get_stats15

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_trades
  • get_account_stats
  • get_account_rewards
  • get_account_referrals

Access policy:

  1. Unauthenticated caller (no API Key or wallet JWT) → 401 Unauthorized.
  2. Owner wallet API Key (apiKey.wallet === account) → 200 OK (full data including orders).
  3. Active on-chain authorized subaccount API Key (SubaccountRouter authorized, unexpired, remaining actions > 0) → 200 OK (full data including orders, enabling autonomous bots to reconcile and cancel orders).
  4. Any unrelated wallet API Key → 403 Forbidden.

Non-custodial perpetuals & AI Agent infrastructure on BNB Chain.