错误代码
本页列出了 BigONE OpenAPI 可能返回的所有错误代码。
错误响应格式
所有错误都遵循此格式:
{
"code": 40004,
"message": "Unauthorized"
}
code 字段包含错误代码,message 提供可读的描述。
认证错误
这些错误发生在认证过程中。
| 代码 | HTTP | 信息 | 描述 |
|---|---|---|---|
| 40004 | 401 | Unauthorized | 缺少认证凭证或凭证无效 |
| 40106 | 401 | Invalid token | JWT Token 格式错误、签名无效或已过期 |
| 40107 | 400 | Unexpected request header | Authorization 请求头格式不正确 |
| 10403 | 403 | Permission denied | API Key 缺少所需的权限范围或 IP 不在白名单中 |
| 10429 | 429 | Too many requests | 超出频率限制 |
通用错误
可能在所有端点发生的常见错误。
| 代码 | HTTP | 信息 | 描述 |
|---|---|---|---|
| 10005 | 500 | Internal error | 服务器遇到意外错误 |
| 10007 | 400 | Parameter error | 请求参数无效或缺失 |
| 10013 | 404 | Resource not found | 请求的资源不存在 |
| 10014 | 400 | Insufficient funds | 账户余额不足以执行操作 |
订单错误
订单创建和管理特有的错误。
| 代码 | HTTP | 信息 | 描述 |
|---|---|---|---|
| 40303 | 403 | Forbid cancel market order | 市价单提交后无法取消 |
| 40304 | 403 | Creating order is forbidden | 暂时禁止创建订单 |
| 40305 | 403 | Account restricted | 您的账户受到交易限制 |
| 50047 | 400 | Liquidity taken too much | 订单将消耗过多流动性 |
| 54041 | 400 | Duplicate order | 具有相同 client_order_id 的订单已存在 |
| 54043 | 400 | Unknown opening order | 未找到要取消的订单 |
| 60100 | 403 | Asset pair is suspended | 该交易对暂停交易 |
闪兑错误
闪兑 (Convert) API 特有的错误。
| 代码 | HTTP | 信息 | 描述 |
|---|---|---|---|
| 54046 | 400 | Convert asset not supported | 不支持指定的资产兑换 |
| 54047 | 400 | Convert price expired | 报价已过期,请重新请求 |
| 54048 | 400 | Convert parameter inconsistent | 请求参数与原始报价不匹配 |
| 54050 | 400 | Convert amount too small | 数量低于最小兑换限制 |
| 54053 | 403 | Convert system busy | 系统暂时过载,请稍后重试 |
错误处理
最佳实践
- 始终检查
code字段 — 不要仅依赖 HTTP 状态码 - 记录错误详情 — 记录错误代码和信息以便调试
- 实现重试逻辑 — 对于瞬时错误 (10005, 54053),使用指数退避重试
- 处理限频 — 对于 10429,在重试前等待(建议 10 秒)
错误处理示例 (Python)
import requests
import time
def make_api_request(url, headers):
response = requests.get(url, headers=headers)
data = response.json()
if data.get("code") != 0:
error_code = data.get("code")
error_message = data.get("message")
if error_code == 10429:
# 被限频 - 等待并重试
time.sleep(10)
return make_api_request(url, headers)
elif error_code == 40004:
# 认证错误 - 刷新 Token
raise AuthenticationError("Token expired")
elif error_code == 10014:
# 余额不足
raise InsufficientFundsError(error_message)
elif error_code in [10005, 54053]:
# 瞬时错误 - 带退避的重试
time.sleep(1)
return make_api_request(url, headers)
else:
raise APIError(f"Error {error_code}: {error_message}")
return data
错误处理示例 (Go)
type APIError struct {
Code int `json:"code"`
Message string `json:"message"`
}
func handleAPIError(resp *http.Response) error {
var apiErr APIError
if err := json.NewDecoder(resp.Body).Decode(&apiErr); err != nil {
return err
}
switch apiErr.Code {
case 10429:
// 限频
time.Sleep(10 * time.Second)
return ErrRateLimited
case 40004, 40106:
// 认证错误
return ErrUnauthorized
case 10014:
// 余额不足
return ErrInsufficientFunds
default:
return fmt.Errorf("API error %d: %s", apiErr.Code, apiErr.Message)
}
}
获取帮助
如果您遇到此处未列出的错误:
- 查看特定 API 端点文档以获取更多错误代码
- 加入 Telegram 群组 @bigapi 获取实时社区支持
- 联系 BigONE 客服并提供:
- 错误代码和信息
- 请求端点和参数
- 错误发生的时间戳 (UTC)