现货交易
本模块所有接口 baseurl:
https://openapi.bitbaby.com/spot/open完整 URL 格式:
{baseurl}{requestPath},例如https://openapi.bitbaby.com/spot/open/sapi/v1/order。签名时
requestPath仅使用/sapi/v1/...部分,不要带/spot/open前缀。详见基本信息 → 需要签名的接口。
公共
安全类型: NONE
公共下方的接口不需要 API-Key 或者签名就能自由访问。
测试连接
GET /sapi/v1/ping
测试 REST API 的连通性。
200 连接正常
{}服务器时间
GET /sapi/v1/time
获取服务器时间。建议下单前先调用一次以校准本地时钟。
200
{
"timezone": "GMT+08:00",
"serverTime": 1595563624731
}币对列表
GET /sapi/v1/symbols
获取市场支持的所有币对及其精度、最小下单量等元信息。
200
{
"symbols": [
{
"symbol": "btcusdt",
"baseAsset": "BTC",
"quoteAsset": "USDT",
"pricePrecision": 2,
"quantityPrecision": 8,
"limitPriceMin": "0.01",
"limitVolumeMin": "0.0001",
"marketBuyMin": "10",
"marketSellMin": "0.0001"
}
]
}Response:
| 名称 | 类型 | 例子 | 描述 |
|---|---|---|---|
| symbol | string | btcusdt | 币对名称(小写) |
| baseAsset | string | BTC | base 货币 |
| quoteAsset | string | USDT | 计价货币 |
| pricePrecision | integer | 2 | 价格精度 |
| quantityPrecision | integer | 8 | 数量精度 |
| limitPriceMin | string | 0.01 | 限价单最小价格步长 |
| limitVolumeMin | string | 0.0001 | 限价单最小数量 |
| marketBuyMin | string | 10 | 市价买单最小金额(计价币) |
| marketSellMin | string | 0.0001 | 市价卖单最小数量 |
行情
安全类型: NONE
行情下方的接口不需要 API-Key 或者签名就能自由访问。
订单薄
GET /sapi/v1/depth
市场订单薄深度信息。
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| limit | integer | 默认 100;最大 100 |
200
{
"time": 1595563624731,
"bids": [
["3.90000000", "431.00000000"],
["4.00000000", "431.00000000"]
],
"asks": [
["4.00000200", "12.00000000"],
["5.10000000", "28.00000000"]
]
}bids / asks 中的每一档为 [price, quantity],按最优价排序。
行情ticker
GET /sapi/v1/ticker
24 小时价格变化数据。
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
200
{
"high": "9279.0301",
"vol": "1302",
"last": "9200",
"low": "9279.0301",
"rose": "0",
"time": 1595563624731
}Response:
| 名称 | 类型 | 描述 |
|---|---|---|
| time | long | 时间戳(毫秒) |
| high | string | 最高价 |
| low | string | 最低价 |
| last | string | 最新价 |
| vol | string | 24h 成交量 |
| rose | string | 24h 涨跌幅 |
最近成交
GET /sapi/v1/trades
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| limit | integer | 默认 200 |
200
[
{
"price": "3.00000100",
"qty": "11.00000000",
"time": 1499865549590,
"side": "BUY"
}
]Response:
| 名称 | 类型 | 描述 |
|---|---|---|
| price | string | 成交价格 |
| qty | string | 成交数量 |
| time | long | 成交时间戳(毫秒) |
| side | string | 主动方向,BUY / SELL |
K 线/蜡烛图数据
GET /sapi/v1/klines
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| interval* | string | K 线区间,可选值:1min, 5min, 15min, 30min, 60min, 1day, 1week, 1month |
| limit | integer | 默认 100;最大 300 |
200
[
{
"idx": 1594640340,
"open": "6228.77",
"close": "6228.77",
"high": "6228.77",
"low": "6228.77",
"vol": "111"
}
]Response:
| 名称 | 类型 | 描述 |
|---|---|---|
| idx | long | K 线开始时间(秒) |
| open | string | 开盘价 |
| close | string | 收盘价 |
| high | string | 最高价 |
| low | string | 最低价 |
| vol | string | 成交量 |
交易
安全类型: TRADE
交易下方的接口都需要签名和 API-Key 验证。所有接口必须携带以下 Headers,下文 Headers 表格不再重复列出。
| Header | Type | Description |
|---|---|---|
| X-CH-APIKEY* | string | 您的 API-Key |
| X-CH-TS* | string | 时间戳(毫秒) |
| X-CH-SIGN* | string | 签名(hex) |
| Content-Type* | string | application/json |
创建新订单
POST /sapi/v1/order
限速规则: 100次/2s
Request Body
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| volume* | number | 订单数量 |
| side* | string | 订单方向,BUY / SELL |
| type* | string | 订单类型,LIMIT / MARKET |
| price | number | 订单价格,对 LIMIT 订单必传 |
| newClientOrderId | string | 客户端订单标识,需自行保证唯一性 |
| recvWindow | integer | 时间窗口(毫秒) |
200
{
"symbol": "LXTUSDT",
"orderId": "150695552109032492",
"clientOrderId": "157371322565051",
"transactTime": "1573713225668",
"price": "0.005452",
"origQty": "110",
"executedQty": "0",
"status": "NEW",
"type": "LIMIT",
"side": "SELL"
}Response:
| 名称 | 类型 | 描述 |
|---|---|---|
| orderId | string | 订单 ID(系统生成) |
| clientOrderId | string | 客户端订单 ID |
| symbol | string | 币对名称 |
| transactTime | string | 订单创建时间(毫秒) |
| price | string | 订单价格 |
| origQty | string | 订单数量 |
| executedQty | string | 已成交数量 |
| type | string | LIMIT / MARKET |
| side | string | BUY / SELL |
| status | string | NEW / PARTIALLY_FILLED / FILLED / CANCELED / REJECTED |
创建测试订单
POST /sapi/v1/order/test
参数与 POST /sapi/v1/order 完全一致,但不会送入撮合引擎,仅用于校验签名 / 参数合法性。
200
{}撤销订单
POST /sapi/v1/cancel
限速规则: 100次/2s
Request Body
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| orderId* | string | 订单 ID |
| newClientOrderId | string | 客户端订单 ID |
200
{
"symbol": "BHTUSDT",
"clientOrderId": "0",
"orderId": "499890200602846976",
"status": "CANCELED"
}批量下单
POST /sapi/v1/batchOrders
限速规则: 50次/2s;一次最多 10 条订单
Request Body
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| orders* | array | 订单数组,最多 10 条 |
orders[] 字段:
| 名称 | 类型 | 描述 |
|---|---|---|
| price | number | 价格(LIMIT 必填) |
| volume | number | 数量 |
| side | string | BUY / SELL |
| batchType | string | LIMIT / MARKET |
| newClientOrderId | string | 单条订单的客户端 ID(可选) |
200
{
"ids": [
"165964665990709251",
"165964665990709252",
"165964665990709253"
]
}批量撤销订单
POST /sapi/v1/batchCancel
限速规则: 50次/2s;一次最多 10 条订单
Request Body
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| orderIds* | array | 要撤销的订单 ID 数组,例如 [123, 456] |
200
{
"success": ["165964665990709251", "165964665990709252"],
"failed": ["165964665990709250"]
}
failed中的订单通常是因为不存在或已到达终态(FILLED/CANCELED)。
订单查询
GET /sapi/v1/order
限速规则: 20次/2s
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| orderId* | string | 订单 ID |
| newClientOrderId | string | 客户端订单 ID |
200
{
"orderId": "499890200602846976",
"clientOrderId": "157432755564968",
"symbol": "BHTUSDT",
"price": "0.01",
"origQty": "50",
"executedQty": "0",
"avgPrice": "0",
"status": "NEW",
"type": "LIMIT",
"side": "BUY",
"transactTime": "1574327555669"
}当前委托
GET /sapi/v1/openOrders
获取当前 symbol 下未完结的订单列表。
限速规则: 20次/2s
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| limit | integer | 默认 100 |
200
[
{
"orderId": "499902955766523648",
"symbol": "BHTUSDT",
"price": "0.01",
"origQty": "50",
"executedQty": "0",
"avgPrice": "0",
"status": "NEW",
"type": "LIMIT",
"side": "BUY",
"time": "1574329076202"
}
]成交记录
GET /sapi/v1/myTrades
限速规则: 20次/2s
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol* | string | 币对名称 E.g. BTCUSDT |
| limit | integer | 默认 100;最大 100 |
| fromId | integer | 从这个 tradeId 开始检索(升序返回) |
200
[
{
"symbol": "ETHBTC",
"id": 100211,
"bidId": 150695552109032492,
"askId": 150695552109032493,
"price": "4.00000100",
"qty": "12.00000000",
"time": 1499865549590,
"isBuyer": true,
"isMaker": false,
"feeCoin": "ETH",
"fee": "0.001"
}
]Response:
| 名称 | 类型 | 描述 |
|---|---|---|
| symbol | string | 币对名称 |
| id | long | 成交 ID |
| bidId | long | 买方订单 ID |
| askId | long | 卖方订单 ID |
| price | string | 成交价格 |
| qty | string | 成交数量 |
| time | long | 成交时间戳(毫秒) |
| isBuyer | boolean | true 自己为买方 |
| isMaker | boolean | true 自己为 maker |
| feeCoin | string | 手续费币种 |
| fee | string | 手续费 |
账户
安全类型: USER_DATA
账户下方的接口都需要签名和 API-Key 验证。Headers 同 交易 部分。
账户信息
GET /sapi/v1/account
限速规则: 20次/2s
200
{
"balances": [
{ "asset": "BTC", "free": "0", "locked": "0" },
{ "asset": "ETH", "free": "0", "locked": "0" }
]
}Response:
| 名称 | 类型 | 描述 |
|---|---|---|
| balances | array | 余额列表 |
| asset | string | 币种 |
| free | string | 可用余额 |
| locked | string | 冻结余额(挂单占用) |
充值记录
GET /sapi/v1/deposit/history
提示
后端 controller 同时支持以 query string 与 JSON body 传参(@RequestBody(required = false))。推荐使用 query string,签名行为也与其他 GET 接口保持一致。
Query Parameters
| Name | Type | Description |
|---|---|---|
| symbol | string | 币种,例如 USDT |
| status | integer | 状态过滤 |
| startTime | long | 起始时间(毫秒),默认最近 90 天 |
| endTime | long | 结束时间(毫秒),默认当前时间 |
| txid | string | 链上 txid 过滤 |
| limit | integer | 返回条数上限,最大 1000 |
200
[
{
"symbol": "USDT",
"amount": "100.00",
"address": "0x...",
"txid": "0x...",
"status": 1,
"createTime": 1574329076202
}
]提现记录
GET /sapi/v1/withdraw/history
参数与 /sapi/v1/deposit/history 一致;返回结构相同(按提现业务字段填充)。