Skip to content

现货交易

本模块所有接口 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 连接正常

json
{}

服务器时间

GET /sapi/v1/time

获取服务器时间。建议下单前先调用一次以校准本地时钟。

200

json
{
    "timezone": "GMT+08:00",
    "serverTime": 1595563624731
}

币对列表

GET /sapi/v1/symbols

获取市场支持的所有币对及其精度、最小下单量等元信息。

200

json
{
    "symbols": [
        {
            "symbol": "btcusdt",
            "baseAsset": "BTC",
            "quoteAsset": "USDT",
            "pricePrecision": 2,
            "quantityPrecision": 8,
            "limitPriceMin": "0.01",
            "limitVolumeMin": "0.0001",
            "marketBuyMin": "10",
            "marketSellMin": "0.0001"
        }
    ]
}

Response:

名称类型例子描述
symbolstringbtcusdt币对名称(小写)
baseAssetstringBTCbase 货币
quoteAssetstringUSDT计价货币
pricePrecisioninteger2价格精度
quantityPrecisioninteger8数量精度
limitPriceMinstring0.01限价单最小价格步长
limitVolumeMinstring0.0001限价单最小数量
marketBuyMinstring10市价买单最小金额(计价币)
marketSellMinstring0.0001市价卖单最小数量

行情

安全类型: NONE

行情下方的接口不需要 API-Key 或者签名就能自由访问。

订单薄

GET /sapi/v1/depth

市场订单薄深度信息。

Query Parameters

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
limitinteger默认 100;最大 100

200

json
{
  "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

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT

200

json
{
    "high": "9279.0301",
    "vol": "1302",
    "last": "9200",
    "low": "9279.0301",
    "rose": "0",
    "time": 1595563624731
}

Response:

名称类型描述
timelong时间戳(毫秒)
highstring最高价
lowstring最低价
laststring最新价
volstring24h 成交量
rosestring24h 涨跌幅

最近成交

GET /sapi/v1/trades

Query Parameters

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
limitinteger默认 200

200

json
[
    {
        "price": "3.00000100",
        "qty": "11.00000000",
        "time": 1499865549590,
        "side": "BUY"
    }
]

Response:

名称类型描述
pricestring成交价格
qtystring成交数量
timelong成交时间戳(毫秒)
sidestring主动方向,BUY / SELL

K 线/蜡烛图数据

GET /sapi/v1/klines

Query Parameters

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
interval*stringK 线区间,可选值:1min, 5min, 15min, 30min, 60min, 1day, 1week, 1month
limitinteger默认 100;最大 300

200

json
[
    {
        "idx": 1594640340,
        "open": "6228.77",
        "close": "6228.77",
        "high": "6228.77",
        "low": "6228.77",
        "vol": "111"
    }
]

Response:

名称类型描述
idxlongK 线开始时间(秒)
openstring开盘价
closestring收盘价
highstring最高价
lowstring最低价
volstring成交量

交易

安全类型: TRADE

交易下方的接口都需要签名和 API-Key 验证。所有接口必须携带以下 Headers,下文 Headers 表格不再重复列出。

HeaderTypeDescription
X-CH-APIKEY*string您的 API-Key
X-CH-TS*string时间戳(毫秒)
X-CH-SIGN*string签名(hex)
Content-Type*stringapplication/json

创建新订单

POST /sapi/v1/order

限速规则: 100次/2s

Request Body

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
volume*number订单数量
side*string订单方向,BUY / SELL
type*string订单类型,LIMIT / MARKET
pricenumber订单价格,对 LIMIT 订单必传
newClientOrderIdstring客户端订单标识,需自行保证唯一性
recvWindowinteger时间窗口(毫秒)

200

json
{
    "symbol": "LXTUSDT",
    "orderId": "150695552109032492",
    "clientOrderId": "157371322565051",
    "transactTime": "1573713225668",
    "price": "0.005452",
    "origQty": "110",
    "executedQty": "0",
    "status": "NEW",
    "type": "LIMIT",
    "side": "SELL"
}

Response:

名称类型描述
orderIdstring订单 ID(系统生成)
clientOrderIdstring客户端订单 ID
symbolstring币对名称
transactTimestring订单创建时间(毫秒)
pricestring订单价格
origQtystring订单数量
executedQtystring已成交数量
typestringLIMIT / MARKET
sidestringBUY / SELL
statusstringNEW / PARTIALLY_FILLED / FILLED / CANCELED / REJECTED

创建测试订单

POST /sapi/v1/order/test

参数与 POST /sapi/v1/order 完全一致,但不会送入撮合引擎,仅用于校验签名 / 参数合法性。

200

json
{}

撤销订单

POST /sapi/v1/cancel

限速规则: 100次/2s

Request Body

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
orderId*string订单 ID
newClientOrderIdstring客户端订单 ID

200

json
{
    "symbol": "BHTUSDT",
    "clientOrderId": "0",
    "orderId": "499890200602846976",
    "status": "CANCELED"
}

批量下单

POST /sapi/v1/batchOrders

限速规则: 50次/2s;一次最多 10 条订单

Request Body

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
orders*array订单数组,最多 10 条

orders[] 字段:

名称类型描述
pricenumber价格(LIMIT 必填)
volumenumber数量
sidestringBUY / SELL
batchTypestringLIMIT / MARKET
newClientOrderIdstring单条订单的客户端 ID(可选)

200

json
{
    "ids": [
        "165964665990709251",
        "165964665990709252",
        "165964665990709253"
    ]
}

批量撤销订单

POST /sapi/v1/batchCancel

限速规则: 50次/2s;一次最多 10 条订单

Request Body

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
orderIds*array要撤销的订单 ID 数组,例如 [123, 456]

200

json
{
    "success": ["165964665990709251", "165964665990709252"],
    "failed":  ["165964665990709250"]
}

failed 中的订单通常是因为不存在或已到达终态(FILLED / CANCELED)。

订单查询

GET /sapi/v1/order

限速规则: 20次/2s

Query Parameters

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
orderId*string订单 ID
newClientOrderIdstring客户端订单 ID

200

json
{
    "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

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
limitinteger默认 100

200

json
[
    {
        "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

NameTypeDescription
symbol*string币对名称 E.g. BTCUSDT
limitinteger默认 100;最大 100
fromIdinteger从这个 tradeId 开始检索(升序返回)

200

json
[
  {
    "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:

名称类型描述
symbolstring币对名称
idlong成交 ID
bidIdlong买方订单 ID
askIdlong卖方订单 ID
pricestring成交价格
qtystring成交数量
timelong成交时间戳(毫秒)
isBuyerbooleantrue 自己为买方
isMakerbooleantrue 自己为 maker
feeCoinstring手续费币种
feestring手续费

账户

安全类型: USER_DATA

账户下方的接口都需要签名和 API-Key 验证。Headers 同 交易 部分。

账户信息

GET /sapi/v1/account

限速规则: 20次/2s

200

json
{
    "balances": [
        { "asset": "BTC", "free": "0", "locked": "0" },
        { "asset": "ETH", "free": "0", "locked": "0" }
    ]
}

Response:

名称类型描述
balancesarray余额列表
assetstring币种
freestring可用余额
lockedstring冻结余额(挂单占用)

充值记录

GET /sapi/v1/deposit/history

提示

后端 controller 同时支持以 query string 与 JSON body 传参(@RequestBody(required = false))。推荐使用 query string,签名行为也与其他 GET 接口保持一致。

Query Parameters

NameTypeDescription
symbolstring币种,例如 USDT
statusinteger状态过滤
startTimelong起始时间(毫秒),默认最近 90 天
endTimelong结束时间(毫秒),默认当前时间
txidstring链上 txid 过滤
limitinteger返回条数上限,最大 1000

200

json
[
  {
    "symbol": "USDT",
    "amount": "100.00",
    "address": "0x...",
    "txid": "0x...",
    "status": 1,
    "createTime": 1574329076202
  }
]

提现记录

GET /sapi/v1/withdraw/history

参数与 /sapi/v1/deposit/history 一致;返回结构相同(按提现业务字段填充)。