Skip to main content

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

StatusMeaningTypical triggers
400Bad requestduplicate name on strategy create, validation rejected by FastAPI/Pydantic, missing required query parameter
404Not foundstrategy id not in DB
429Rate limitedper-IP cap exceeded (see below)
500Internal server errorunhandled exception in the FastAPI handler
502Upstream failurethe 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.