Errors
Envelope
All errors are returned as JSON with a single detail field:
{ "detail": "<human-readable message>" }
This is the FastAPI default envelope. There are no machine-readable error codes; clients should branch on the HTTP status code.
The detail string is currently authored in Chinese on the backend (e.g. "策略不存在"). English equivalents are noted in each endpoint's error table; do not parse the literal string.
HTTP status codes
| Status | Meaning | Typical triggers |
|---|---|---|
400 | Bad request | duplicate name on strategy create, validation rejected by FastAPI/Pydantic, missing required query parameter |
404 | Not found | strategy id not in DB |
429 | Rate limited | per-IP cap exceeded (see below) |
500 | Internal server error | unhandled exception in the FastAPI handler |
502 | Upstream failure | the backend's call to Binance failed ({"detail": "Binance请求失败: <reason>"}) |
Rate-limit responses
When an IP exceeds 1000 requests per 60-second window, the backend returns HTTP 429:
{ "detail": "请求过于频繁。每个 IP 每分钟最多允许 1000 次请求。" }
It also marks the IP as blocked for one hour. Subsequent requests during the block return:
{ "detail": "IP <ip> 已被暂时封锁。请求过于频繁,请稍后再试。" }
/ and /health are excluded from rate limiting and never return 429.
Validation errors (FastAPI default)
When a request fails Pydantic validation, FastAPI returns HTTP 422 with its standard validation envelope:
{
"detail": [
{
"loc": ["body", "name"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
This shape only appears for validation failures; all hand-thrown errors use the simple {"detail": "<string>"} form above.