简体中文
shell

更新日志

2022-10-16

创建文档

介绍

API Key 设置

API Key 权限设置

账户

现货账户

新注册的账号都会有一个现货(SPOT)账号。

基础信息

API 基本信息

HTTP 返回代码

接口的基本信息

访问限制

访问限制基本信息

下单频率限制

WEB SOCKET 连接限制

接口鉴权类型

鉴权类型 描述
NONE 端点可以自由访问。
TRADE 端点需要发送有效的API-Key和签名。
USER_DATA 端点需要发送有效的API-Key和签名
USER_STREAM 端点需要发送有效的API-Key。
MARKET_DATA 端点需要发送有效的API-Key。

需要签名的接口

逻辑伪代码
if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow) {
  // process request
} else {
  // reject request
}

关于交易时效性 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到TooBit服务器的时延会有抖动. 这是我们设置recvWindow的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置recvWindow以达到你的要求。

POST /api/v1/spot/order的示例

以下是在linux bash环境下使用 echo openssl 和curl工具实现的一个调用接口下单的示例 apikey、secret仅供示范

Key Value
apiKey SRQGN9M8Sr87nbfKsaSxm33Y6CmGVtUu9Erz73g9vHFNn36VROOKSaWBQ8OSOtSq
secretKey 30lfjDT51iOG1kYZnDoLNynOyMdIcmQyO1XYfxzYOmQfx9tjiI98Pzio4uhZ0Uk2
参数 取值
symbol BTCUSDT
side SELL
type LIMIT
timeInForce GTC
quantity 1
price 4000
recvWindow 100000
timestamp 1668481902307

示例 1: 所有参数通过 query string 发送

示例1:
HMAC SHA256 签名:
$ echo -n "symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=400&recvWindow=100000&timestamp=1668481902307" | openssl dgst -sha256 -hmac "30lfjDT51iOG1kYZnDoLNynOyMdIcmQyO1XYfxzYOmQfx9tjiI98Pzio4uhZ0Uk2"
(stdin)= 8420e499e71cce4a00946db16543198b6bcae01791bdb75a06b5a7098b156468
curl 调用:
(HMAC SHA256)
$ curl -H "X-BB-APIKEY: SRQGN9M8Sr87nbfKsaSxm33Y6CmGVtUu9Erz73g9vHFNn36VROOKSaWBQ8OSOtSq" -X POST 'https://api.toobit.com/api/v1/spot/order' -d 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=400&recvWindow=100000&timestamp=1668481902307&signature=8420e499e71cce4a00946db16543198b6bcae01791bdb75a06b5a7098b156468'

示例 2: 所有参数通过 request body 发送

示例2:
HMAC SHA256 签名:
$ echo -n "symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=400&recvWindow=100000&timestamp=1668481902307" | openssl dgst -sha256 -hmac "30lfjDT51iOG1kYZnDoLNynOyMdIcmQyO1XYfxzYOmQfx9tjiI98Pzio4uhZ0Uk2"
(stdin)= 8420e499e71cce4a00946db16543198b6bcae01791bdb75a06b5a7098b156468
curl 调用:
(HMAC SHA256)
$ curl -H "X-BB-APIKEY: SRQGN9M8Sr87nbfKsaSxm33Y6CmGVtUu9Erz73g9vHFNn36VROOKSaWBQ8OSOtSq" -X POST 'https://api.toobit.com/api/v1/spot/order' -d 'symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC&quantity=1&price=400&recvWindow=100000&timestamp=1668481902307&signature=8420e499e71cce4a00946db16543198b6bcae01791bdb75a06b5a7098b156468'

示例 3: 混合使用 query string 与 request body

示例3:
HMAC SHA256 签名:
$ echo -n "symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTCquantity=1&price=400&recvWindow=10000000&timestamp=1668481902307" | openssl dgst -sha256 -hmac "30lfjDT51iOG1kYZnDoLNynOyMdIcmQyO1XYfxzYOmQfx9tjiI98Pzio4uhZ0Uk2"
(stdin)= 59ef0b2085ebb99cca5b6445c202d99add17be2d5d1861c0f4aa17bc785ac4d5
curl 调用:
(HMAC SHA256)
$ curl -H "X-BB-APIKEY: SRQGN9M8Sr87nbfKsaSxm33Y6CmGVtUu9Erz73g9vHFNn36VROOKSaWBQ8OSOtSq" -X POST 'https://api.toobit.com/api/v1/spot/order?symbol=BTCUSDT&side=SELL&type=LIMIT&timeInForce=GTC' -d 'quantity=1&price=400&recvWindow=10000000&timestamp=1668481902307&signature=59ef0b2085ebb99cca5b6445c202d99add17be2d5d1861c0f4aa17bc785ac4d5'

注意在例子3里有一点不一样,"GTC"和"quantity=1"之间没有&。

公开API参数

术语解释

枚举定义

订单状态:

订单类型:

订单方向:

有效方式:

K线间隔:

m -> 分钟; h -> 小时; d -> 天; w -> 周; M -> 月

频率限制类型:

频率限制区间

钱包接口

提币 (USER_DATA)

提交一个提币请求。

权重:1

响应

{
"status": 0,
"success": true,
"needBrokerAudit": false, // 是否需要券商审核
"id": "423885103582776064", // 提币成功订单id
"refuseReason":"" // 失败拒绝原因
}

参数

参数名称 类型 是否必需 描述
coin STRING YES 资产
clientOrderId LONG YES 自定义提币ID
address STRING YES 提币地址(注意:提现地址必须是在PC端或者APP端维护在常用地址列表里面的地址)
addressExt STRING NO tag
quantity DECIMAL YES 提币数量
chainType STRING NO chain type, USDT的chainType分别是OMNI ERC20 TRC20,默认OMNI

获取提币记录 (USER_DATA)

权重:5

响应

[
    {
        "time":"1536232111669",
        "id ":"90161227158286336",
        "accountId":"517256161325920",
        "coinId ":"BHC",
        "coinName":"BHC",
        "address":"0x815bF1c3cc0f49b8FC66B21A7e48fCb476051209",
        "addressExt":"address tag",
        "quantity":"14", // 提币金额
        "arriveQuantity":"14", // 到账金额
        "statusCode":"PROCESSING_STATUS",
        "status":3,
        "txId ":"",
        "txIdUrl ":"",
        "walletHandleTime":"1536232111669",
        "feeCoinId ":"BHC",
        "feeCoinName ":"BHC",
        "fee":"0.1",
        "requiredConfirmTimes ":0, // 要求确认数
        "confirmTimes ":0, // 确认数
        "kernelId":"", // BEAM  GRIN 独有
        "isInternalTransfer": false // 是否内部转账
    }
]

参数

参数名称 类型 是否必需 描述
coin STRING NO 资产
startTime LONG NO 开始时间戳
endTime LONG NO 结束时间戳
fromId LONG NO 从哪个OrderId起开始抓取
withdrawOrderId LONG NO 提现订单ID
limit INT NO 默认 500; 最大 1000
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

获取充值地址 (USER_DATA)

权重:1

响应

    {
        "canDeposit":false,//是否可充值
        "address":"0x815bF1c3cc0f49b8FC66B21A7e48fCb476051209",//地址
        "addressExt":"address tag",
        "minQuantity":"100",//最小金额
        "requiredConfirmTimes ":1,//到账确认数
        "canWithdrawConfirmNum ":12,//提币确认数
        "coinType":"ERC20_TOKEN"//链类型
    }

参数

参数名称 类型 是否必需 描述
coin STRING YES 资产
chainType STRING YES chain type, USDT的chainType分别是OMNI ERC20 TRC20,默认OMNI

获取充值历史 (USER_DATA)

权重: 5

响应

[
  {
        "id": 100234,
        "coin": "EOS",
        "coinName": "EOS",
        "address": "deposit2bb",
        "addressTag": "19012584",
        "fromAddress": "clarkkent",
        "fromAddressTag": "19029901",
        "time": 1499865549590,
        "quantity": "1.01",
        "status": "2", // 2=成功,11=拒绝, 12=审核中
        "statusCode": "DEPOSIT_CAN_WITHDRAW",
        "requiredConfirmTimes": "5",
        "confirmTimes": "5",
        "txId": "98A3EA560C6B3336D348B6C83F0F95ECE4F1F5919E94BD006E5BF3BF264FACFC",
        "txIdUrl": ""
  }
]

请求参数

参数名称 类型 是否必需 描述
coin STRING NO 资产:例如BTC
startTime LONG NO 开始时间戳
endTime LONG NO 结束时间戳
fromId LONG NO 从哪个Id起开始抓取
limit INT NO 默认 500; 最大 1000
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

注意:

行情接口

测试服务器连通性

测试能否联通 Rest API。

权重:1

响应

{}

参数

NONE

获取服务器时间

测试能否联通 Rest API 并 获取服务器时间。

权重:1

响应

{
  "serverTime": 1538323200000
}

参数

NONE

获取交易规则和交易对

当前broker交易规则和symbol信息

权重:1

响应

{
  "timezone": "UTC",
  "brokerFilters": [],
  "symbols": [
    {
      "filters":[
          {
              "minPrice":"0.01",
              "maxPrice":"100000.00000000",
              "tickSize":"0.01",
              "filterType":"PRICE_FILTER"
          },
          {
              "minQty":"0.0001",
              "maxQty":"4000",
              "stepSize":"0.0001",
              "filterType":"LOT_SIZE"
          },
          {
              "minNotional":"10",
              "filterType":"MIN_NOTIONAL"
          },
          {
              "minAmount":"10", // 最小交易额
              "maxAmount":"6600000", // 最大交易额
              "minBuyPrice":"0.01", // 最小买入价格
              "filterType":"TRADE_AMOUNT" 
          },
          {
              "maxSellPrice":"99999999", // 限价最大卖出价格
              "buyPriceUpRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "maxEntrustNum":"100000",  // 委托单最大比数(合约)
              "maxConditionNum":"100000", // 条件单最大比数(合约
              "filterType":"LIMIT_TRADING"
          },
          {
              "buyPriceUpRate":"0.1", // 买入不能高于标记(合约)/最新(现货)价的 10%
              "sellPriceDownRate":"0.1", // 卖出不能低于标记(合约)/最新(现货)价的 10%
              "filterType":"MARKET_TRADING"
          },
          {
              "noAllowMarketStartTime":"0", // 不允许使用市价单开始时间 
              "noAllowMarketEndTime":"0", // 不允许使用市价单结束时间
              "limitOrderStartTime":"0", // 限时限价单开始时间
              "limitOrderEndTime":"0", // 限时限价单结束时间
              "limitMinPrice":"0", // 限时限价单最低价格
              "limitMaxPrice":"0", // 限时限价单最高价格
              "filterType":"OPEN_QUOTE"
          }
      ],
      "symbol": "ETHUSDT",
      "symbolName": "ETHUSDT",
      "status": "TRADING",
      "baseAsset": "ETH",
      "baseAssetName": "ETH",
      "baseAssetPrecision": "0.0001",
      "quoteAsset": "USDT",
      "quoteAssetName": "USDT",
      "quotePrecision": "0.01",
      "icebergAllowed": false,
      "isAggregate": false,
      "allowMargin": true
    },
    {
      "filters":[
          {
              "minPrice":"0.01",
              "maxPrice":"100000.00000000",
              "tickSize":"0.01",
              "filterType":"PRICE_FILTER"
          },
          {
              "minQty":"0.0001",
              "maxQty":"4000",
              "stepSize":"0.0001",
              "filterType":"LOT_SIZE"
          },
          {
              "minNotional":"10",
              "filterType":"MIN_NOTIONAL"
          },
          {
              "minAmount":"10", // 最小交易额
              "maxAmount":"6600000", // 最大交易额
              "minBuyPrice":"0.01", // 最小买入价格
              "filterType":"TRADE_AMOUNT" 
          },
          {
              "maxSellPrice":"99999999", // 限价最大卖出价格
              "buyPriceUpRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "maxEntrustNum":"100000",  // 委托单最大比数(合约)
              "maxConditionNum":"100000", // 条件单最大比数(合约
              "filterType":"LIMIT_TRADING"
          },
          {
              "buyPriceUpRate":"0.1", // 买入不能高于标记(合约)/最新(现货)价的 10%
              "sellPriceDownRate":"0.1", // 卖出不能低于标记(合约)/最新(现货)价的 10%
              "filterType":"MARKET_TRADING"
          },
          {
              "noAllowMarketStartTime":"0", // 不允许使用市价单开始时间 
              "noAllowMarketEndTime":"0", // 不允许使用市价单结束时间
              "limitOrderStartTime":"0", // 限时限价单开始时间
              "limitOrderEndTime":"0", // 限时限价单结束时间
              "limitMinPrice":"0", // 限时限价单最低价格
              "limitMaxPrice":"0", // 限时限价单最高价格
              "filterType":"OPEN_QUOTE"
          }
      ],
      "symbol": "BTCUSDT",
      "symbolName": "BTCUSDT",
      "status": "TRADING",
      "baseAsset": "BTC",
      "baseAssetName": "BTC",
      "baseAssetPrecision": "0.000001",
      "quoteAsset": "USDT",
      "quoteAssetName": "USDT",
      "quotePrecision": "0.01",
      "icebergAllowed": false,
      "isAggregate": false,
      "allowMargin": true
    },
    {
      "filters":[
          {
              "minPrice":"0.01",
              "maxPrice":"100000.00000000",
              "tickSize":"0.01",
              "filterType":"PRICE_FILTER"
          },
          {
              "minQty":"0.0001",
              "maxQty":"4000",
              "stepSize":"0.0001",
              "filterType":"LOT_SIZE"
          },
          {
              "minNotional":"10",
              "filterType":"MIN_NOTIONAL"
          },
          {
              "minAmount":"10", // 最小交易额
              "maxAmount":"6600000", // 最大交易额
              "minBuyPrice":"0.01", // 最小买入价格
              "filterType":"TRADE_AMOUNT" 
          },
          {
              "maxSellPrice":"99999999", // 限价最大卖出价格
              "buyPriceUpRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "maxEntrustNum":"100000",  // 委托单最大比数(合约)
              "maxConditionNum":"100000", // 条件单最大比数(合约
              "filterType":"LIMIT_TRADING"
          },
          {
              "buyPriceUpRate":"0.1", // 买入不能高于标记(合约)/最新(现货)价的 10%
              "sellPriceDownRate":"0.1", // 卖出不能低于标记(合约)/最新(现货)价的 10%
              "filterType":"MARKET_TRADING"
          },
          {
              "noAllowMarketStartTime":"0", // 不允许使用市价单开始时间 
              "noAllowMarketEndTime":"0", // 不允许使用市价单结束时间
              "limitOrderStartTime":"0", // 限时限价单开始时间
              "limitOrderEndTime":"0", // 限时限价单结束时间
              "limitMinPrice":"0", // 限时限价单最低价格
              "limitMaxPrice":"0", // 限时限价单最高价格
              "filterType":"OPEN_QUOTE"
          }
      ],
      "symbol": "XRPUSDT",
      "symbolName": "XRPUSDT",
      "status": "TRADING",
      "baseAsset": "XRP",
      "baseAssetName": "XRP",
      "baseAssetPrecision": "0.01",
      "quoteAsset": "USDT",
      "quoteAssetName": "USDT",
      "quotePrecision": "0.01",
      "icebergAllowed": false,
      "isAggregate": false,
      "allowMargin": false
    }
  ],
  "rateLimits": [
    {
      "rateLimitType": "REQUEST_WEIGHT",
      "interval": "MINUTE",
      "intervalUnit": 1,
      "limit": 3000
    },
    {
      "rateLimitType": "ORDERS",
      "interval": "SECOND",
      "intervalUnit": 60,
      "limit": 60
    }
  ],
  "options": [],
  "contracts": [
    {
      "filters":[
          {
              "minPrice":"0.01",
              "maxPrice":"100000.00000000",
              "tickSize":"0.01",
              "filterType":"PRICE_FILTER"
          },
          {
              "minQty":"0.0001",
              "maxQty":"4000",
              "stepSize":"0.0001",
              "filterType":"LOT_SIZE"
          },
          {
              "minNotional":"10",
              "filterType":"MIN_NOTIONAL"
          },
          {
              "minAmount":"10", // 最小交易额
              "maxAmount":"6600000", // 最大交易额
              "minBuyPrice":"0.01", // 最小买入价格
              "filterType":"TRADE_AMOUNT" 
          },
          {
              "maxSellPrice":"99999999", // 限价最大卖出价格
              "buyPriceUpRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "maxEntrustNum":"100000",  // 委托单最大比数(合约)
              "maxConditionNum":"100000", // 条件单最大比数(合约
              "filterType":"LIMIT_TRADING"
          },
          {
              "buyPriceUpRate":"0.1", // 买入不能高于标记(合约)/最新(现货)价的 10%
              "sellPriceDownRate":"0.1", // 卖出不能低于标记(合约)/最新(现货)价的 10%
              "filterType":"MARKET_TRADING"
          },
          {
              "noAllowMarketStartTime":"0", // 不允许使用市价单开始时间 
              "noAllowMarketEndTime":"0", // 不允许使用市价单结束时间
              "limitOrderStartTime":"0", // 限时限价单开始时间
              "limitOrderEndTime":"0", // 限时限价单结束时间
              "limitMinPrice":"0", // 限时限价单最低价格
              "limitMaxPrice":"0", // 限时限价单最高价格
              "filterType":"OPEN_QUOTE"
          }
      ],
      "symbol": "BTC-SWAP-USDT",
      "symbolName": "BTC-SWAP-USDTUSDT",
      "status": "TRADING",
      "baseAsset": "BTC-SWAP-USDT",
      "baseAssetPrecision": "1",
      "quoteAsset": "USDT",
      "quoteAssetPrecision": "0.1",
      "icebergAllowed": false,
      "inverse": false,
      "index": "BTCUSDT",
      "marginToken": "USDT",
      "marginPrecision": "0.0001",
      "contractMultiplier": "0.0001",
      "underlying": "BTC",
      "riskLimits": [
        {
          "riskLimitId": "200000133",
          "quantity": "1000000.0",
          "initialMargin": "0.01",
          "maintMargin": "0.005"
        },
        {
          "riskLimitId": "200000134",
          "quantity": "2000000.0",
          "initialMargin": "0.02",
          "maintMargin": "0.01"
        },
        {
          "riskLimitId": "200000135",
          "quantity": "3000000.0",
          "initialMargin": "0.03",
          "maintMargin": "0.015"
        },
        {
          "riskLimitId": "200000136",
          "quantity": "4000000.0",
          "initialMargin": "0.04",
          "maintMargin": "0.02"
        }
      ]
    },
    {
      "filters":[
          {
              "minPrice":"0.01",
              "maxPrice":"100000.00000000",
              "tickSize":"0.01",
              "filterType":"PRICE_FILTER"
          },
          {
              "minQty":"0.0001",
              "maxQty":"4000",
              "stepSize":"0.0001",
              "filterType":"LOT_SIZE"
          },
          {
              "minNotional":"10",
              "filterType":"MIN_NOTIONAL"
          },
          {
              "minAmount":"10", // 最小交易额
              "maxAmount":"6600000", // 最大交易额
              "minBuyPrice":"0.01", // 最小买入价格
              "filterType":"TRADE_AMOUNT" 
          },
          {
              "maxSellPrice":"99999999", // 限价最大卖出价格
              "buyPriceUpRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "sellPriceDownRate":"0.1", // 限价最大卖出价格
              "maxEntrustNum":"100000",  // 委托单最大比数(合约)
              "maxConditionNum":"100000", // 条件单最大比数(合约
              "filterType":"LIMIT_TRADING"
          },
          {
              "buyPriceUpRate":"0.1", // 买入不能高于标记(合约)/最新(现货)价的 10%
              "sellPriceDownRate":"0.1", // 卖出不能低于标记(合约)/最新(现货)价的 10%
              "filterType":"MARKET_TRADING"
          },
          {
              "noAllowMarketStartTime":"0", // 不允许使用市价单开始时间 
              "noAllowMarketEndTime":"0", // 不允许使用市价单结束时间
              "limitOrderStartTime":"0", // 限时限价单开始时间
              "limitOrderEndTime":"0", // 限时限价单结束时间
              "limitMinPrice":"0", // 限时限价单最低价格
              "limitMaxPrice":"0", // 限时限价单最高价格
              "filterType":"OPEN_QUOTE"
          }
      ],
      "symbol": "BTC-SWAP",
      "symbolName": "BTC-SWAP",
      "status": "TRADING",
      "baseAsset": "BTC-SWAP",
      "baseAssetPrecision": "1",
      "quoteAsset": "USDT",
      "quoteAssetPrecision": "0.1",
      "icebergAllowed": false,
      "inverse": true,
      "index": "BTCUSDT",
      "marginToken": "BTC",
      "marginPrecision": "0.00000001",
      "contractMultiplier": "1.0",
      "underlying": "BTC",
      "riskLimits": [
        {
          "riskLimitId": "200000137",
          "quantity": "1000000.0",
          "initialMargin": "0.01",
          "maintMargin": "0.005"
        },
        {
          "riskLimitId": "200000138",
          "quantity": "2000000.0",
          "initialMargin": "0.02",
          "maintMargin": "0.01"
        },
        {
          "riskLimitId": "200000139",
          "quantity": "3000000.0",
          "initialMargin": "0.03",
          "maintMargin": "0.015"
        },
        {
          "riskLimitId": "200000140",
          "quantity": "4000000.0",
          "initialMargin": "0.04",
          "maintMargin": "0.02"
        }
      ]
    }
  ],
  "coins": [
    {
      "coinId": "ETH",
      "coinName": "ETH",
      "coinFullName": "Ethereum",
      "allowWithdraw": true,
      "allowDeposit": true,
      "chainTypes": []
    },
    {
      "coinId": "USDT",
      "coinName": "USDT",
      "coinFullName": "TetherUS",
      "allowWithdraw": true,
      "allowDeposit": true,
      "chainTypes": [
        {
          "chainType": "ERC20",
          "withdrawFee": "0.1",
          "minWithdrawQuantity": "10",
          "maxWithdrawQuantity": "1000",
          "minDepositQuantity": "1",
          "allowDeposit": true,
          "allowWithdraw": true
        },
        {
          "chainType": "TRC20",
          "withdrawFee": "0.1",
          "minWithdrawQuantity": "10",
          "maxWithdrawQuantity": "1000",
          "allowDeposit": true,
          "allowWithdraw": true
        },
        {
          "chainType": "OMNI",
          "withdrawFee": "0.1",
          "minWithdrawQuantity": "10",
          "maxWithdrawQuantity": "1000",
          "allowDeposit": true,
          "allowWithdraw": true
        }
      ]
    },
    {
      "coinId": "BTC",
      "coinName": "BTC",
      "coinFullName": "Bitcoin",
      "allowWithdraw": false,
      "allowDeposit": false,
      "chainTypes": []
    },
    {
      "coinId": "UNI",
      "coinName": "UNI",
      "coinFullName": "uniswap",
      "allowWithdraw": false,
      "allowDeposit": false,
      "chainTypes": []
    },
    {
      "coinId": "XRP",
      "coinName": "XRP",
      "coinFullName": "XRP",
      "allowWithdraw": false,
      "allowDeposit": false,
      "chainTypes": []
    },
    {
      "coinId": "EOS",
      "coinName": "EOS1",
      "coinFullName": "EOS",
      "allowWithdraw": true,
      "allowDeposit": true,
      "chainTypes": []
    },
    {
      "coinId": "JET",
      "coinName": "JET",
      "coinFullName": "JET",
      "allowWithdraw": false,
      "allowDeposit": false,
      "chainTypes": []
    }
  ]
}

参数

NONE

深度信息

响应

{
  "b": [
    [
      "3.90000000",   // 价格
      "431.00000000"  // 数量
    ],
    [
      "4.00000000",
      "431.00000000"
    ]
  ],
  "a": [
    [
      "4.00000200",  // 价格
      "12.00000000"  // 数量
    ],
    [
      "5.10000000",
      "28.00000000"
    ]
  ]
}

参数

参数名称 类型 是否必需 描述
symbol STRING YES
limit INT NO 默认 100; 最大 200.

注意: 如果设置limit=0会返回很多数据。

最近成交

获取当前最新成交(最多60)

权重: 1

响应

[
  {
    "p": "4.00000100",
    "q": "12.00000000",
    "t": 1499865549590,
    "ibm": true  // 成交方向 isBuyerMaker
  }
]

参数

参数名称 类型 是否必需 描述
symbol STRING YES
limit INT NO 默认 60; 最大 60.

k线/烛线图数据

权重:1

响应

[
  [
    1499040000000,      // 开盘时间
    "0.01634790",       // 开盘价
    "0.80000000",       // 最高价
    "0.01575800",       // 最低价
    "0.01577100",       // 收盘价
    "148976.11427815",  // 交易量
    1499644799999,      // 收盘时间
    "2434.19055334",    // Quote asset数量
    308,                // 交易次数
    "1756.87402397",    // Taker buy base asset数量
    "28.46694368"       // Taker buy quote asset数量
  ]
]

参数

参数名称 类型 是否必需 描述
symbol STRING YES
interval ENUM YES
startTime LONG NO
endTime LONG NO
limit INT NO 默认 100; 最大 100.

24hr 价格变动情况

24小时价格变化数据。注意 如果没有发送symbol,会返回很多数据。

权重:

如果只有一个symbol为1; 如果symbol没有被发送为40。

响应

[
    {
        "t": 1538725500422,   // 时间
        "a": "1.10000000",    // 最高卖价
        "b": "1.00000000",    // 最高买价
        "s": "ETHBTC",        // symbol 
        "c": "4.00000200",    // 最新成交价
        "o": "99.00000000",   // 开盘价
        "h": "100.00000000",  // 最高价 
        "l": "0.10000000",    // 最低价
        "v": "8913.30000000", // 成交量
        "qv": "15.30000000",   // 成交额
        "pc": "15.30000000",   // 24小时价格变动
        "pcp": "15.30000000"   // 24小时价格变动百分比
    }
]

参数

参数名称 类型 是否必需 描述
symbol STRING NO

最新价格

单个或多个symbol的最新价。

权重:1

响应

[
  {
    "s": "LTCBTC",     // 交易对
    "p": "4.00000200"  // 最新价
  }
]

参数

参数名称 类型 是否必需 描述
symbol STRING NO

当前最优挂单

单个或者多个symbol的最佳买单卖单价格。

权重:1

响应

[
  {
      "t": 132222222222222,     // 时间
      "s": "LTCBTC",            // 交易对          
      "b": "4.00000000",        // 最高买价
      "bq": "431.00000000",     // 最高买价对应的数量
      "a": "4.00000200",        // 最高卖价
      "aq": "9.00000000"        // 最高卖价对应的数量
  }
]

参数

参数名称 类型 是否必需 描述
symbol STRING NO

合并深度

权重: 1

响应

{
    "t": 1672035413265,//时间
    "b": [//买入深度高到低
        [
            "16851.95",//价格
            "0.003321"//数量
        ],
        [
            "16851.87",
            "0.005456"
        ],
        [
            "16851.47",
            "0.002219"
        ]
    ],
    "a": [//卖出深度低到高
        [
            "16870.19",
            "0.003838"
        ],
        [
            "16873.05",
            "0.00361"
        ],
        [
            "16873.06",
            "0.002623"
        ]
    ]
}

参数

参数名称 类型 是否必需 描述
symbol STRING YES 交易对
scale INT NO 档位: 0,1,2,3,4,5 例如:0表示1档,1表示2档
limit INT NO 限制条数

Websocket 行情推送

名称
topic realtimes(实时行情), trade(最新成交), kline_$interval(k线), depth(深度),markPrice(标记价格),markPriceKline_$interval(标记价格K线),index(指数价格)indexKline_$interval(指数价格K线)
event sub(订阅), cancel(取消), cancel_all(取消全部)
interval 1m, 5m, 15m, 30m, 1h, 2h, 6h, 12h, 1d, 1w, 1M

实时订阅/取消数据流

请求订阅数据样例:

{

"symbol": "$symbol0, $symbol1",

"topic": "$topic",

"event": "sub",

"params": {

"limit": "$limit", // kline返回上限是2000,默认为1

"binary": "false" //返回的数据是否是压缩过的,默认为false

}

}

取消订阅数据样例:

{

"symbol": "$symbol0, $symbol1",

"topic": "$topic",

"event": "cancel",

"params": {

"limit": "$limit", // kline返回上限是2000,默认为1

"binary": "false" //返回的数据是否是压缩过的,默认为false

}

}

心跳

每隔一段时间,客户端需要发送ping帧,服务端会回复pong帧,否则服务端会在5分钟内主动断开链接。

Payblad

{
    "pong": 1535975085052
}

请求

{

"ping": 1535975085052

}

逐笔交易

逐笔交易推送每一笔成交的信息。成交,或者说交易的定义是仅有一个吃单者与一个挂单者相互交易。 在成功连接到服务器后,服务器首先会推送一条最近的60条成交。在这条推送之后,每条推送都是实时的成交。 变量“v”可以理解成一个交易ID。这个变量是全局递增的并且独特的。例如:假设过去5秒有3笔交易发生,分别是ETHUSDTBTCUSDTBHTBTC。它们的“v”会为连续的值(112,113,114)。

Payload

{
    "symbol": "BTCUSDT",
    "symbolName": "BTCUSDT",
    "topic": "trade",
    "params": {
        "realtimeInterval": "24h",
        "binary": "false"
    },
    "data": [
        {
            "v": "1291465821801168896", // 参见解释
            "t": 1668690723096, //时间戳
            "p": "399", // 价格
            "q": "1", // 数量
            "m": false // true = , false = 
        },
        {
            "v": "1291465842546196481",
            "t": 1668690725569,
            "p": "399",
            "q": "1",
            "m": false
        }
    ],
    "f": true, // 是不是第一个返回
    "sendTime": 1668753154192,
    "shared": false
}

请求订阅数据样例:

{

"symbol": "$symbol0, $symbol1",'

"topic": "trade",

"event": "sub",

"params": {

"binary": false // Whether data returned is in binary format

}

}

K线 Streams

K线stream逐秒推送所请求的K线种类(最新一根K线)的更新

K线图间隔参数:

m -> 分钟; h -> 小时; d -> 天; w -> 周; M -> 月

Payload

{
    "symbol": "BTCUSDT",
    "symbolName": "BTCUSDT",
    "topic": "kline",
    "params": {
        "realtimeInterval": "24h",
        "klineType": "1m",
        "binary": "false"
    },
    "data": [
        {
            "t": 1668753840000,//k线开始时间
            "s": "BTCUSDT",// symbol
            "sn": "BTCUSDT",// symbol name
            "c": "445",//收盘价
            "h": "445",//最高价
            "l": "445",//最低价
            "o": "445",//开盘价
            "v": "0"//交易量
        }
    ],
    "f": true,// 是否为第一个返回
    "sendTime": 1668753854576,
    "shared": false
}

请求订阅数据样例:

{

"symbol": "$symbol0, $symbol1",

"topic": "kline_"+$间隔,

"event": "sub",

"params": {

"binary": false

}

}

按Symbol的完整Ticker

按Symbol逐秒刷新的24小时完整ticker信息

Payload

{
    "symbol": "BTCUSDT",
    "symbolName": "BTCUSDT",
    "topic": "realtimes",
    "params": {
        "realtimeInterval": "24h",
        "binary": "false"
    },
    "data": [
        {
            "t": 1668753480049, //时间戳
            "s": "BTCUSDT", //symbol
            "sn": "BTCUSDT", // symbol name
            "c": "445", //收盘价
            "h": "445", //最高价
            "l": "310", //最低价
            "o": "311", //开盘价
            "v": "3747.7597191", //交易量
            "qv": "1426443.9553995", //交易额
            "m": "0.4309", // margin
            "e": 301 // 交易id
        }
    ],
    "f": true, // 是否为第一个返回
    "sendTime": 1668753481048,
    "shared": false
}

请求订阅数据样例:

{

"symbol": "$symbol0, $symbol1",

"topic": "realtimes",

"event": "sub",

"params": {

"binary": false

}

}

有限档深度信息

Symbol的深度信息。

Payload

{
  "symbol": "BTCUSDT",
  "topic": "depth",
  "data": [{
    "s": "BTCUSDT", //Symbol
    "t": 1565600357643, //时间戳
    "v": "112801745_18", //见上面解释
    "b": [ //Bids
      ["11371.49", "0.0014"], //[价格, 数量]
      ["11371.12", "0.2"],
      ["11369.97", "0.3523"],
      ["11369.96", "0.5"],
      ["11369.95", "0.0934"],
      ["11369.94", "1.6809"],
      ["11369.6", "0.0047"],
      ["11369.17", "0.3"],
      ["11369.16", "0.2"],
      ["11369.04", "1.3203"],
    "a": [//Asks
      ["11375.41", "0.0053"], //[价格, 数量]
      ["11375.42", "0.0043"],
      ["11375.48", "0.0052"],
      ["11375.58", "0.0541"],
      ["11375.7", "0.0386"],
      ["11375.71", "2"],
      ["11377", "2.0691"],
      ["11377.01", "0.0167"],
      ["11377.12", "1.5"],
      ["11377.61", "0.3"]
    ]
  }],
  "f": true//是否为第一个返回
}

请求订阅数据样例:

{

  "symbol": "$symbol0, $symbol1",
  "topic": "depth",
  "event": "sub",
  "params": {
    "binary": false
  }

增量深度信息

Payload

{
  "symbol": "BTCUSDT",
  "topic": "diffDepth",
  "data": [{
    "e": 0,
    "t": 1565687625534,
    "v": "115277986_18",
    "b": [
      ["11316.78", "0.078"],
      ["11313.16", "0.0052"],
      ["11312.12", "0"],
      ["11309.75", "0.0067"],
      ["11309.58", "0"],
      ["11306.14", "0.0073"]
    ],
    "a": [
      ["11318.96", "0.0041"],
      ["11318.99", "0.0017"],
      ["11319.12", "0.0017"],
      ["11319.22", "0.4516"],
      ["11319.23", "0.0934"],
      ["11319.24", "3.0665"]
    ]
  }],
  "f": false //是否为第一个返回值
}

请求订阅数据样例:

{

"symbol": "$symbol0, $symbol1",

"topic": "diffDepth",

"event": "sub",

"params": {

"binary": false

}

}

每秒推送订单簿的变化部分(如果有)。 在增量深度信息中,数量不一定等于对应价格的数量。如果数量=0,这说明在上一条推送中的这个价格已经没有了。如果数量>0,这时的数量为更新后的这个价格所对应的数量 假设我们收到的返回数据中有这样一条:

["0.00181860", "155.92000000"]// 价格,数量

如果下一条返回数据中有:

["0.00181860", "12.3"]

这说明这个价格对应的数量有变更,已经更新变更的数量 如果下一条返回数据中有:

["0.00181860", "0"]

这说明这个价格对应的数量已经消失,将会在客户端中删除。

现货账户和交易接口

测试下单 (TRADE)

用于测试订单请求,但不会提交到撮合引擎

权重:1

响应

{}

参数

同于 POST /api/v1/spot/order

下单 (TRADE)

发送下单。

权重:1

响应

{
    "accountId": "1287091689761137921",
    "symbol": "BTCUSDT",
    "symbolName": "BTCUSDT",
    "clientOrderId": "1668483032042259",
    "orderId": "1289723583082363136",
    "transactTime": "1668483032058",
    "price": "400",
    "origQty": "1",
    "executedQty": "0",
    "status": "FILLED",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "SELL"
}

参数

参数名称 类型 是否必需 描述
symbol STRING YES 交易对
assetType ENUM NO CASHMARGIN,只支持CASH
side ENUM YES BUYSELL
type ENUM YES 详见枚举定义:订单类型
timeInForce ENUM NO 详见枚举定义:有效方式
quantity DECIMAL YES 数量
price DECIMAL NO 价格
newClientOrderId STRING NO 一个自己给订单定义的ID,如果没有发送会自动生成。
stopPrice DECIMAL NO STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, 和TAKE_PROFIT_LIMIT 订单一起使用. 当前不可用
icebergQty DECIMAL NO LIMIT, STOP_LOSS_LIMIT, 和TAKE_PROFIT_LIMIT 来创建冰山订单. 当前不可用
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

基于订单 type不同,强制要求某些参数:

类型 额外强制参数
LIMIT quantity,price
MARKET quantity
STOP_LOSS quantity, stopPrice 当前不可用
STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice 当前不可用
TAKE_PROFIT quantity, stopPrice 当前不可用
TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice 当前不可用
LIMIT_MAKER quantity, price

批量下单 (TRADE)

权重:2

批量创建新订单,单次最多20条订单,必须为同一symbol

例子:

curl  -H "Content-Type:application/json" -H "X-BB-APIKEY: SRQGN9M8Sr87nbfKsaSxm33Y6CmGVtUu9Erz73g9vHFNn36VROOKSaWBQ8OSOtSq" -X POST -d '[   
{     "newClientOrderId": "pl12241234567898",     
      "orderId": 202212241234567898,     
      "symbol": "BTCUSDT",     
      "side": "SELL",     
      "type": "LIMIT",     
      "price": 17001,     
      "quantity": 1   
},   
{     "newClientOrderId": "pl12241234567899",     
      "orderId": 202212241234567899,     
      "symbol": "BTCUSDT",     
      "side": "SELL",     
      "type": "LIMIT",     
      "price": 17002,     
      "quantity": 1  
 } ]' 'https://api.toobit.com/api/v1/spot/batchOrders?timestamp=1671880913657&signature=7548b6834613afed3b7d3b0b9bfb0e0b3e3799c46db3ea6b952439fde35cb88f'

响应 成功返回: ``` json { "code": 0, "result": [{ "code": 0, "order": { "accountId": "1287091689761137921", "symbol": "BTCUSDT", "symbolName": "BTCUSDT", "clientOrderId": "pl12241234567898", "orderId": "202212241234567898", "transactTime": "1671880251836", "price": "17001", "origQty": "1", "executedQty": "0", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "SELL" } }, { "code": 0, "order": { "accountId": "1287091689761137921", "symbol": "BTCUSDT", "symbolName": "BTCUSDT", "clientOrderId": "pl12241234567899", "orderId": "202212241234567899", "transactTime": "1671880251853", "price": "17002", "origQty": "1", "executedQty": "0", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "SELL" } }] }


失败返回:
``` json
{
        "code": 0,
        "result": [{
                "code": -1149,
                "msg": "Create order failed"
        }, {
                "code": -1149,
                "msg": "Create order failed"
        }]
}

参数

参数名称 类型 是否必需 描述
list YES RequestBody 参数
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

其中RequestBody中batchOrders应以list of JSON格式填写订单参数

参数名称 类型 是否必需 描述
symbol STRING YES 交易对
side ENUM YES BUYSELL
type ENUM YES 详见枚举定义:订单类型
timeInForce ENUM NO 详见枚举定义:有效方式
quantity DECIMAL YES 数量
price DECIMAL NO 价格
newClientOrderId STRING YES 用户自定义订单ID。

基于订单 type不同,强制要求某些参数:

类型 额外强制参数
LIMIT quantity,price
MARKET quantity
STOP_LOSS quantity, stopPrice 当前不可用
STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice 当前不可用
TAKE_PROFIT quantity, stopPrice 当前不可用
TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice 当前不可用
LIMIT_MAKER quantity, price

撤销订单 (TRADE)

取消有效订单。

权重:1

响应

{
  "symbol": "LTCBTC",
  "orderId": "1",
  "clientOrderId": "9t1M2K0Ya092",
  "price": "0.1",
  "origQty": "1.0",
  "executedQty": "0.0",
  "status": "CANCELED",
  "timeInForce": "GTC",
  "type": "LIMIT",
  "side": "BUY",
  "transactTime": "1499827319559"
}

参数

参数名称 类型 是否必需 描述
orderId LONG NO 订单ID
clientOrderId STRING NO 客户订单ID
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

orderIdorigClientOrderId 必须至少发送一个

批量撤单 (TRADE)

权重:5

响应

{
  "success":true
}

参数

参数名称 类型 是否必需 描述
symbol STRING NO 现货名称(多个用,隔开)
side ENUM NO BUY或SELL
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

批量撤单 (TRADE)

根据订单id批量撤单,单次最多100条

权重:5

响应

取消全部成功: json { "code":0, // 0 代表执行成功 "result":[] //批量撤单结果 }

取消部分或全部失败: json { "code":0, "result":[ { "orderId":"202212231234567895", "code":-2013 // }, { "orderId":"202212231234567896", "code":-2013 } ] }

参数

参数名称 类型 是否必需 描述
ids STRING YES 订单id(多个用,隔开)
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

注意:code返回0代表撤单请求被执行,是否成功还需要看result里的结果,如果result为空代表全部成功,不为空orderId代表撤销失败的订单id,code代表撤销失败原因。

查询订单 (USER_DATA)

权重:1

响应

{
  "symbol": "LTCBTC",
  "orderId": "1",
  "clientOrderId": "9t1M2K0Ya092",
  "price": "0.1",
  "origQty": "1.0",
  "executedQty": "0.0",
  "cumulativeQuoteQty": "0.0",
  "status": "NEW",
  "timeInForce": "GTC",
  "type": "LIMIT",
  "side": "BUY",
  "stopPrice": "0.0",
  "icebergQty": "0.0",
  "time": "1499827319559",
  "updateTime": "1499827319559",
  "isWorking": true
}

参数

参数名称 类型 是否必需 描述
orderId LONG NO 订单ID
origClientOrderId STRING NO 客户订单ID
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

注意:

当前挂单 (USER_DATA)

获取交易对的所有当前挂单, 请小心使用不带交易对参数的调用。

权重 :1

响应

[
  {
    "symbol": "LTCBTC",
    "orderId": "1",
    "clientOrderId": "t7921223K12",
    "price": "0.1",
    "origQty": "1.0",
    "executedQty": "0.0",
    "cummulativeQuoteQty": "0.0",
    "status": "NEW",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY",
    "stopPrice": "0.0",
    "icebergQty": "0.0",
    "time": "1499827319559",
    "updateTime": "1499827319559",
    "isWorking": true
  }
]

参数

参数名称 类型 是否必需 描述
orderId LONG NO 订单ID
symbol STRING NO 交易对
limit INT NO 默认 500; 最多 1000.
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

注意:

查询所有订单 (USER_DATA)

获取所有帐户订单; 有效,已取消或已完成。

权重:5

响应

[
  {
    "symbol": "LTCBTC",
    "orderId": "1",
    "clientOrderId": "987yjj2Ym",
    "price": "0.1",
    "origQty": "1.0",
    "executedQty": "0.0",
    "cummulativeQuoteQty": "0.0",
    "status": "NEW",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY",
    "stopPrice": "0.0",
    "icebergQty": "0.0",
    "time": "1499827319559",
    "updateTime": "1499827319559",
    "isWorking": true
  }
]

参数

参数名称 类型 是否必需 描述
orderId LONG NO 订单ID
symbol STRING NO 交易对
startTime LONG NO 开始时间戳, 默认值:三天前
endTime LONG NO 结束时间戳
limit INT NO 默认 500; 最多 1000.
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

账户信息 (USER_DATA)

权重:5

响应

{
    "balances": [
        {
            "asset": "BTC", //资产
            "assetId": "BTC", //资产id
            "assetName": "BTC", //资产名称
            "total": "995.899", //总数量
            "free": "995.899", //可用数
            "locked": "0" //冻结数
        }
    ]
}

参数

参数名称 类型 是否必需 描述
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

账户成交历史 (USER_DATA)

权重:5

响应

[
    {
        "id": "1291291745779199489",
        "symbol": "BTCUSDT",
        "symbolName": "BTCUSDT",
        "orderId": "1290805676579237376",
        "price": "314",
        "qty": "0.71433122",
        "commission": "0.22430000308",
        "commissionAsset": "USDT",
        "time": "1668669971575",
        "isBuyer": false,
        "isMaker": true,
        "fee": {
            "feeCoinId": "USDT",
            "feeCoinName": "USDT",
            "fee": "0.22430000308"
        },
        "feeCoinId": "USDT",
        "feeAmount": "0.22430000308",
        "makerRebate": "0",
        "ticketId": "1185465136943458745" // ticketId
    }
]

参数

参数名称 类型 是否必需 描述
symbol STRING YES 交易对
startTime LONG NO 开始时间戳
endTime LONG NO 结束时间戳
fromId LONG NO 起始id
toId LONG NO 结束id
limit INT NO 每页显示条数
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

注意:

查询子账户 (USER_DATA)

权重:5

响应:

[
    {
        "accountId": "122216245228131",
        "nickName": "",
        "accountType": 1,
        "accountIndex": 0 // 账户index 0 默认账户 >0, 创建的子账户
    },
    {
        "accountId": "482694560475091200",
        "nickName": "createSubAccountByCurl", // 子账户名称
        "accountType": 1, // 子账户类型 1 币币账户 3 合约账户
        "accountIndex": 1
    }
]

参数

参数名称 类型 是否必需 描述
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

母子账户万能划转

支持的划转操作:

权重:1

响应:

{
    "code": 200, // 成功
    "msg": "success" // 响应消息
}

参数

名称 类型 是否必须 描述
fromUid LONG YES 源账户id
toUid LONG YES 目标账户id
fromAccountType String YES 源账户类型
toAccountType String YES 目标账户类型
asset String YES 币种
quantity DECIMAL YES 转账数量
timestamp LONG YES 时间戳
recvWindow LONG NO recv窗口

accountType: MAIN: 现货 FUTURES: U本位合约

查询账户流水 (USER_DATA)

权重: 5

响应

[
    {
        "id": "539870570957903104",
        "accountId": "122216245228131",
        "coin": "BTC",
        "coinId": "BTC",
        "coinName": "BTC",
        "flowTypeValue": 51, // 流水类型
        "flowType": "USER_ACCOUNT_TRANSFER", // 流水类型名称
        "flowName": "Transfer", // 流水类型说明
        "change": "-12.5", // 变动值
        "total": "379.624059937852365", // 变动后当前tokenId总资产
        "created": "1579093587214"
    }
]

参数

参数名称 类型 是否必需 描述
accountType INT NO 账户对应的account_type
coin STRING NO 资产
flowType INT NO 划转:3
fromId LONT NO 顺向查询数据
endId LONG NO 反向查询数据
startTime LONG NO 开始时间
endTime LONG NO 结束时间
limit INT NO 每页记录数
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

获取API KEY类型 (USER_DATA)

响应

{
    "accountType": "master"
}

参数

参数名称 类型 是否必需 描述
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

Websocket账户信息推送

Listen Key (现货账户)

生成 Listen Key (USER_STREAM)

开始一个新的数据流。除非发送 keepalive,否则数据流于60分钟后关闭。

权重:1

响应

{
  "listenKey": "1A9LWJjuMwKWYP4QQPw34GRm8gz3x5AephXSuqcDef1RnzoBVhEeGE963CoS1Sgj"
}

参数

参数名称 类型 是否必需 描述
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

延长 Listen Key 有效期 (USER_STREAM)

有效期延长至本次调用后60分钟,建议每30分钟发送一个 ping 。

权重:1

响应

{}

参数

参数名称 类型 是否必需 描述
listenKey STRING YES
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

关闭 Listen Key (USER_STREAM)

权重:1

响应

{}

参数

参数名称 类型 是否必需 描述
listenKey STRING YES
recvWindow LONG NO recv窗口
timestamp LONG YES 时间戳

Payload: 账户更新

Payload

[
  {
    "e": "outboundAccountInfo",   // Event type事件类型
    "E": 1499405658849,           // Event time事件时间
    "T": true,                    // Can trade 可否交易
    "W": true,                    // Can withdraw 可否提币
    "D": true,                    // Can deposit 可否充币
    "B": [                        // Balances changed 余额变更
      {
        "a": "LTC",               // Asset 资产
        "f": "17366.18538083",    // Free amount 可用金额
        "l": "0.00000000"         // Locked amount 冻结金额
      }
    ]
  }
]

每当帐户余额发生更改时,都会发送一个事件outboundAccountInfo,其中包含可能由生成余额变动的事件而变动的资产。

Payload: 订单更新

Payload

[
  {
    "e": "executionReport",        // Event type 事件类型
    "E": 1499405658658,            // Event time 事件时间
    "s": "ETHBTC",                 // Symbol 币对
    "c": 1000087761,               // Client order ID 客户订单id
    "S": "BUY",                    // Side 订单方向
    "o": "LIMIT",                  // Order type 订单类型
    "f": "GTC",                    // Time in force 有效方式
    "q": "1.00000000",             // Order quantity 数量
    "p": "0.10264410",             // Order price 价格
    "pt": "MARKET",                // price type 价格类型 INPUT:输入价格 MARKET: 市价
    "X": "NEW",                    // Current order status 订单状态
    "i": 4293153,                  // Order ID 订单id
    "l": "0.00000000",             // Last executed quantity 上次数量
    "z": "0.00000000",             // Cumulative filled quantity 交易数量
    "L": "0.00000000",             // Last executed price 上次价格
    "n": "0",                      // Commission amount 佣金
    "N": null,                     // Commission asset 佣金资产
    "u": true,                     // Is the trade normal, ignore for now 是否正常
    "w": true,                     // Is the order working? Stops will have
    "m": false,                    // Is this trade the maker side?
    "O": 1499405658657,            // Order creation time 创建时间
    "Z": "0.00000000"              // Cumulative quote asset transacted quantity 交易金额
  } 
]

订单更新会通过 executionReport 事件更新。查看API文档和下面的相关枚举定义。 平均价格可以通过Z除以z来找到。

执行类型

Payload: Ticket推送

响应

[
    {
        "e": "ticketInfo",                // Event type 事件类型
        "E": "1668693440976",             // Event time 事件时间
        "s": "BTCUSDT",                   // Symbol 币对
        "q": "0.205",                     // quantity 数量
        "t": "1668693440899",             // time 时间
        "p": "441.0",                     // price 价格
        "T": "1291488620385157122",       // ticketId
        "o": "1291488620167835136",       // orderId 订单id
        "c": "1668693440093",             // clientOrderId 客户订单id
        "a": "1286424214388204801",       // accountId 账户id
        "m": false,                       // isMaker 
        "S": "SELL"                       // side  SELL or BUY
    }
]

错误代码

错误由两部分组成:错误代码和消息。代码是通用的,但消息可以不同。

错误JSON格式

{  
  "code":-1121, 
  "msg":"Invalid symbol."
}

10xx-通用服务器或网络问题

-1000 UNKNOWN

-1001 DISCONNECTED

-1002 UNAUTHORIZED

-1003 TOO_MANY_REQUESTS

-1006 UNEXPECTED_RESP

-1007 TIMEOUT

-1014 UNKNOWN_ORDER_COMPOSITION

-1015 TOO_MANY_ORDERS

-1016 SERVICE_SHUTTING_DOWN

-1020 UNSUPPORTED_OPERATION

-1021 INVALID_TIMESTAMP

-1022 INVALID_SIGNATURE

11xx - 2xxx Request issues

-1100 ILLEGAL_CHARS

-1101 TOO_MANY_PARAMETERS

-1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED

-1103 UNKNOWN_PARAM

-1104 UNREAD_PARAMETERS

-1105 PARAM_EMPTY

-1106 PARAM_NOT_REQUIRED

-1111 BAD_PRECISION

-1112 NO_DEPTH

-1114 TIF_NOT_REQUIRED

-1115 INVALID_TIF

-1116 INVALID_ORDER_TYPE

-1117 INVALID_SIDE

-1118 EMPTY_NEW_CL_ORD_ID

-1119 EMPTY_ORG_CL_ORD_ID

-1120 BAD_INTERVAL

-1121 BAD_SYMBOL

-1125 INVALID_LISTEN_KEY

-1127 MORE_THAN_XX_HOURS

-1128 OPTIONAL_PARAMS_BAD_COMBO

-1130 INVALID_PARAMETER

-1132 ORDER_PRICE_TOO_HIGH

-1133 ORDER_PRICE_TOO_SMALL

-1134 ORDER_PRICE_PRECISION_TOO_LONG

-1135 ORDER_QUANTITY_TOO_BIG

-1136 ORDER_QUANTITY_TOO_SMALL

-1137 ORDER_QUANTITY_PRECISION_TOO_LONG

-1138 ORDER_PRICE_WAVE_EXCEED

-1139 ORDER_HAS_FILLED

-1140 ORDER_AMOUNT_TOO_SMALL

-1141 ORDER_DUPLICATED

-1142 ORDER_CANCELLED

-1143 ORDER_NOT_FOUND_ON_ORDER_BOOK

-1144 ORDER_LOCKED

-1145 ORDER_NOT_SUPPORT_CANCELLATION

-1146 ORDER_CREATION_TIMEOUT

-1147 ORDER_CANCELLATION_TIMEOUT

-1193 ORDER_COUNT_LIMIT

-1194 MARKET_ORDER_FORBIDDEN

-1195 LIMIT_ORDER_PRICE_TOO_SMALL

-1196 LIMIT_ORDER_PRICE_TOO_BIG

-1197 LIMIT_ORDER_BUY_PRICE_TOO_BIG

-1198 LIMIT_ORDER_SELL_PRICE_TOO_SMALL

-1199 ORDER_BUY_QUANTITY_TOO_SMALL

-1200 ORDER_BUY_QUANTITY_TOO_BIG

-1201 LIMIT_ORDER_SELL_PRICE_TOO_BIG

-1202 ORDER_SELL_QUANTITY_TOO_SMALL

-1203 ORDER_SELL_QUANTITY_TOO_BIG

-1206 ORDER_AMOUNT_TOO_BIG

-2010 NEW_ORDER_REJECTED

-2011 CANCEL_REJECTED

-2013 NO_SUCH_ORDER

-2014 BAD_API_KEY_FMT

-2015 REJECTED_MBX_KEY

-2016 NO_TRADING_WINDOW

过滤器故障

报错信息 描述
"Filter failure: PRICE_FILTER" 价格太高,太低,和/或不遵循交易品种的分时大小规则。
"Filter failure: LOT_SIZE" 数量太高、太低和/或未遵循符号的步长规则。
"Filter failure: MIN_NOTIONAL" 价格*数量太低,不能作为该品种的有效订单。
"Filter failure: MAX_NUM_ORDERS" 客户在交易对上有太多挂单。
"Filter failure: MAX_ALGO_ORDERS" 账户有太多未平仓止损和/或在交易对上执行获利指令。
"Filter failure: ICEBERG_PARTS" ICEBERG 订单会分成太多部分; icebergQty太小。

订单拒绝错误

报错信息 描述
"Unknown order sent." 找不到订单(通过"orderId","clientOrderId","origClientOrderId")
"Duplicate order sent." clientOrderId已经被使用
"Market is closed." 该交易对不在交易范围
"Account has insufficient balance for requested action." 没有足够的资金来完成行动
"Market orders are not supported for this symbol." 交易对上未启用MARKET
"Iceberg orders are not supported for this symbol." 交易对上未启用icebergQty
"Stop loss orders are not supported for this symbol." 交易对上未启用 STOP_LOSS
"Stop loss limit orders are not supported for this symbol." 交易对上未启 STOP_LOSS_LIMIT
"Take profit orders are not supported for this symbol." 交易对上未启用TAKE_PROFIT
"Take profit limit orders are not supported for this symbol." 交易对上未启用TAKE_PROFIT_LIMIT
"Price* QTY is zero or less." price * quantity太小
"IcebergQty exceeds QTY." icebergQty 必须少于订单数量
"This action disabled is on this account." 联系客户支持; 该帐户已禁用了某些操作。
"Unsupported order combination" 不允许组合orderType, timeInForce, stopPrice, 和/或 icebergQty
"Order would trigger immediately." 与最后交易价格相比,订单的止损价无效。
"Cancel order is invalid. Check origClOrdId and orderId." 未发送origClientOrderIdorderId
"Order would immediately match and take." LIMIT_MAKER订单类型将立即匹配并进行交易,而不是纯粹的生成订单。