Skip to content

Rate limits

Evidence: ptrader-api-gateway/.../filter/RateLimitInterceptor.java, WeightConfigManager.

Behaviour (code)

  • Weighted rate limiting by IP and/or UID.
  • Interval config default includes 1m (ratelimit.intervals).
  • Response header pattern: X-SAPI-USED-%s-WEIGHT-%s (interval / mode).
  • On limit: HTTP body approximately
    {"code":-1003, "msg":"Too many requests; current request has limited."}
    (also ApiErrorCode.TOO_MANY_REQUESTS = -1003).

Weights and numeric ceilings are loaded from runtime configuration (Apollo / env), not fully checked into this docs repo.

Documented limits (To Do)

Item Status
Default IP/UID weight budget per interval [NEEDS-CONFIRMATION: export production weight tables]
Per-endpoint weight map [NEEDS-CONFIRMATION]
Order-count limits (TOO_MANY_ORDERS / -1015) [NEEDS-CONFIRMATION: thresholds]
listenKey create rate (CREATE_LISTEN_KEY_RATE_LIMIT / -1026) Message implies per-hour cap; confirm number

WebSocket (separate)

Evidence: ptrader-ws-gateway/docs/WS_API_SPOT.md

Limit Value
Client messages 25 / second / connection
Max streams 1024 / connection
Ping interval 20 s
Ping timeout 120 s
Idle (no subscriptions) 60 s disconnect