Navbar
简体中文

更新日志

2019-11-13

Rest API

    {
      "code": -1128,
      "msg": "Combination of optional parameters invalid. Recommendation: 'stopLimitTimeInForce' should also be sent."
    }

v1 接口将被弃用:

2020年一季度末,以下接口将被移除。目前文档已经将这些接口更新为v3版本。

以下接口将不会移植到v3版本,请使用新接口予以替换

旧的 V1 接口 新的 V3 接口
GET api/v1/ticker/allPrices GET api/v3/ticker/price
GET api/v1/ticker/allBookTickers GET api/v3/ticker/bookTicker

USER DATA STREAM

WEB SOCKET STREAM


2019-11-08


2019-11-04


2019-10-29


2019-10-14


2019-10-11


2019-09-09


2019-09-03


2019-08-16


2019-09-15

Rest API

用户数据流

新的错误码

新的-2011错误内容


2019-03-12

Rest API

Websocket 流

系统改进


2018-11-13

Rest API

平均价格的计算规则解释:

1.前5分钟的所有交易/数量交易的(数量*价格)。

2.如果最近5分钟内没有交易,则以5分钟窗口外发生的第一笔交易为准。     例如,如果最后一次交易是在20分钟前,则该交易的价格为5分钟的平均值。

3.如果代码上没有交易,则没有平均价格,因此无法下达市价单。     对于在MIN_NOTIONAL过滤器上启用了applyToMarket的新交易对,除非有至少一笔交易,才能下达市价单。

4.当前的平均价格可以在这里查看:https://api.binance.com/api/v3/avgPrice?symbol=<symbol> 例如: https://api.binance.com/api/v3/avgPrice?symbol=BNBUSDT

用户数据流


2018-07-18

Rest API

用户数据流


2018-01-23


2018-01-20


2018-01-14

基本信息

API 基本信息

HTTP 返回代码

错误代码

API 与 SAPI 的错误代码返回形式如下:

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

WAPI 的错误代码返回形式如下:

{
  "success": false,
  "msg": "Invalid symbol."
}

接口的基本信息


访问限制

访问限制基本信息

IP 访问限制

下单频率限制


接口鉴权类型

鉴权类型 描述
NONE 不需要鉴权的接口
TRADE 需要有效的 API-Key 和签名
USER_DATA 需要有效的 API-Key 和签名
USER_STREAM 需要有效的 API-Key
MARKET_DATA 需要有效的 API-Key

SIGNED (TRADE、USER_DATA AND MARGIN) Endpoint security

时间同步安全

逻辑伪代码如下:

  if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow)
  {
    // process request
  } 
  else 
  {
    // reject request
  }

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

POST /api/v3/order 的示例

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

Key Value
apiKey vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A
secretKey NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j
参数 取值
symbol LTCBTC
side BUY
type LIMIT
timeInForce GTC
quantity 1
price 0.1
recvWindow 5000
timestamp 1499827319559

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

Example 1

HMAC SHA256 signature:

    $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
    (stdin)= c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71

curl command:

    (HMAC SHA256)
    $ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order' -d 'symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'

symbol=LTCBTC
&side=BUY
&type=LIMIT
&timeInForce=GTC
&quantity=1
&price=0.1
&recvWindow=5000
&timestamp=1499827319559

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

Example 2

HMAC SHA256 signature:

    $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
    (stdin)= c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71

curl command:

    (HMAC SHA256)
   $ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'

symbol=LTCBTC
&side=BUY
&type=LIMIT
&timeInForce=GTC
&quantity=1
&price=0.1
&recvWindow=5000
&timestamp=1499827319559

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

Example 3

HMAC SHA256 signature:

   $ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTCquantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
    (stdin)= 0fd168b8ddb4876a0358a8d14d0c9f3da0e9b20c5d52b2a00fcf7d1c602f9a77

curl command:

    (HMAC SHA256)
    $ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC' -d 'quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=0fd168b8ddb4876a0358a8d14d0c9f3da0e9b20c5d52b2a00fcf7d1c602f9a77'

symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC

quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559

请注意,签名与示例3不同。 “ GTC”和“ quantity = 1”之间没有&。

POST的签名接口示例/wapi/v3/withdraw.html

这是一个分步示例,说明如何从 使用echoopensslcurl的Linux命令行。

Key Value
apiKey vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A
secretKey NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j
参数 取值
asset ETH
address 0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b
addressTag 1 (Secondary address identifier for coins like XRP,XMR etc.)
amount 1
recvWindow 5000
name addressName (Description of the address)
timestamp 1508396497000
signature 157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320

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

HMAC SHA256 signature:

    $ echo -n "asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&timestamp=1510903211000" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
    (stdin)= 157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320

curl command:

    (HMAC SHA256)
    $ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://www.binance.com/wapi/v3/withdraw.html?asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=addressName&timestamp=1510903211000&signature=157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320'

asset=ETH
&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b &amount=1&recvWindow=5000&name=test&timestamp=1510903211000

注意,对于wapi,参数必须以查询字符串的形式发送。


公开 API 参数

术语

枚举定义

交易对状态 (状态):

交易对类型:

订单状态 (状态):

OCO 状态 (状态类型集):

OCO 订单状态 (订单状态集):

指定订单的类型

订单类型 (orderTypes, type):

订单方向 (方向):

Time in force (timeInForce):

K线间隔:

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

限制种类 (rateLimitType)

REQUEST_WEIGHT

    {
      "rateLimitType": "REQUEST_WEIGHT",
      "interval": "MINUTE",
      "intervalNum": 1,
      "limit": 1200
    }

ORDERS

    {
      "rateLimitType": "ORDERS",
      "interval": "SECOND",
      "intervalNum": 1,
      "limit": 10
    }

RAW_REQUESTS

    {
      "rateLimitType": "RAW_REQUESTS",
      "interval": "MINUTE",
      "intervalNum": 5,
      "limit": 5000
    }

限制间隔 (interval)


过滤器

过滤器,即Filter,定义了一系列交易规则。 共有两类,分别是针对交易对的过滤器symbol filters,和针对整个交易所的过滤器 exchange filters

交易对过滤器

PRICE_FILTER 价格过滤器

/exchangeInfo 响应中的格式:

  {
    "filterType": "PRICE_FILTER",
    "minPrice": "0.00000100",
    "maxPrice": "100000.00000000",
    "tickSize": "0.00000100"
  }

价格过滤器 用于检测订单中 price 参数的合法性。包含以下三个部分:

以上每一项均可为0,为0时代表这一项不再做限制。

逻辑伪代码如下:

PERCENT_PRICE 价格振幅过滤器

/exchangeInfo 响应中的格式:

  {
    "filterType": "PERCENT_PRICE",
    "multiplierUp": "5",
    "multiplierDown": "0.2",
    "avgPriceMins": 5
  }

PERCENT_PRICE过滤器基于先前交易的平均值来定义价格的有效范围。
avgPriceMins是计算平均价格的分钟数。 0表示使用最后的价格。

为了通过“价格百分比”,“价格”必须符合以下条件:

LOT_SIZE 订单尺寸

/exchangeInfo 响应中的格式:

  {
    "filterType": "LOT_SIZE",
    "minQty": "0.00100000",
    "maxQty": "100000.00000000",
    "stepSize": "0.00100000"
  }

Lots是拍卖术语,LOT_SIZE 过滤器对订单中的 quantity 也就是数量参数进行合法性检查。包含三个部分:

逻辑伪代码如下:

MIN_NOTIONAL 最小名义价值(成交额)

/exchangeInfo 响应中的格式:

  {
    "filterType": "MIN_NOTIONAL",
    "minNotional": "0.00100000",
    "applyToMarket": true,
    "avgPriceMins": 5
  }

MIN_NOTIONAL过滤器定义了交易对订单所允许的最小名义价值(成交额)。 订单的名义价值是价格*数量
applyToMarket确定 MIN_NOTIONAL过滤器是否也将应用于MARKET订单。
由于MARKET订单没有价格,因此会在最后avgPriceMins分钟内使用平均价格。
avgPriceMins是计算平均价格的分钟数。 0表示使用最后的价格。

ICEBERG_PARTS 冰山订单拆分数

/exchangeInfo 响应中的格式:

  {
    "filterType": "ICEBERG_PARTS",
    "limit": 10
  }

ICEBERG_PARTS 代表冰山订单最多可以拆分成多少个小订单。
计算方法为 向上取整(qty / icebergQty)

MARKET_LOT_SIZE 市价订单尺寸

**/exchangeInfo 响应中的格式:*

  {
    "filterType": "MARKET_LOT_SIZE",
    "minQty": "0.00100000",
    "maxQty": "100000.00000000",
    "stepSize": "0.00100000"
  }

MARKET_LOT_SIZE过滤器为交易对上的MARKET订单定义了数量(即拍卖中的“手数”)规则。 共有3部分:

为了通过market lot sizequantity必须满足以下条件:

MAX_NUM_ORDERS 最多订单数

/exchangeInfo 响应中的格式:

  {
    "filterType": "MAX_NUM_ORDERS",
    "limit": 25
  }

定义了某个交易对最多允许的挂单数量(不包括已关闭的订单)
普通订单与条件订单均计算在内

MAX_NUM_ALGO_ORDERS 最多条件单数

/exchangeInfo 响应中的格式:

  {
    "filterType": "MAX_NUM_ALGO_ORDERS",
    "maxNumAlgoOrders": 5
  }

MAX_NUM_ALGO_ORDERS过滤器定义允许账户在交易对上开设的“algo”订单的最大数量。
"Algo”订单是STOP_LOSSSTOP_LOSS_LIMITTAKE_PROFITTAKE_PROFIT_LIMIT止盈止损单。

MAX_NUM_ICEBERG_ORDERS 最多冰山单数

MAX_NUM_ICEBERG_ORDERS过滤器定义了允许在交易对上开设账户的ICEBERG订单的最大数量。
ICEBERG订单是icebergQty大于0的任何订单。.

/exchangeInfo 响应中的格式:

  {
    "filterType": "MAX_NUM_ICEBERG_ORDERS",
    "maxNumIcebergOrders": 5
  }

交易所级别过滤器

EXCHANGE_MAX_NUM_ORDERS 最多订单数

/exchangeInfo 响应中的格式:

  {
    "filterType": "EXCHANGE_MAX_NUM_ORDERS",
    "maxNumOrders": 1000
  }

MAX_NUM_ORDERS过滤器定义了允许在交易对上开设账户的最大订单数。
请注意,此过滤器同时计算“algo”订单和常规订单。

EXCHANGE_MAX_NUM_ALGO_ORDERS 交易最大ALGO订单数

/exchangeInfo 响应中的格式:

  {
    "filterType": "EXCHANGE_MAX_ALGO_ORDERS",
    "maxNumAlgoOrders": 200
  }

MAX_ALGO_ORDERS过滤器定义了允许在交易上开设账户的“algo”订单的最大数量。
“Algo”订单是STOP_LOSSSTOP_LOSS_LIMITTAKE_PROFITTAKE_PROFIT_LIMIT订单。

钱包接口

系统状态 (System)

响应

{ 
    "status": 0,              // 0: 正常,1:系统维护
    "msg": "normal"           // normal|system maintenance
}

GET /wapi/v3/systemStatus.html

获取系统状态。

获取所有币信息 (USER_DATA)

响应

[
    {
        "coin": "BTC",
        "depositAllEnable": True,
        "free": "0.08074558",
        "freeze": "0.00000000",
        "ipoable": "0.00000000",
        "ipoing": "0.00000000",
        "isLegalMoney": False,
        "locked": "0.00000000",
        "name": "Bitcoin",
        "networkList": [
            {
                "addressRegex": "^(bnb1)[0-9a-z]{38}$",
                "coin": "BTC",
                "depositDesc": "Wallet Maintenance, Deposit Suspended",
                "depositEnable": True,
                "isDefault": False,        
                "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
                "name": "BEP2",
                "network": "BNB",            
                "resetAddressStatus": False,
                "specialTips": "Both a MEMO and an Address are required to successfully deposit your BEP2-BTCB tokens to Binance.",
                "withdrawDesc": "Wallet Maintenance, Withdrawal Suspended",
                "withdrawEnable": True,
                "withdrawFee": "0.00000220",
                "withdrawMin": "0.00000440"
            },
            {
                "addressRegex": "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$",
                "coin": "BTC",
                "depositDesc": "",
                "depositEnable": True,
                "insertTime": 1563532929000,
                "isDefault": True,
                "memoRegex": "",
                "name": "BTC",
                "network": "BTC",
                "resetAddressStatus": False,
                "specialTips": "",
                "updateTime": 1571014804000,
                "withdrawDesc": "System Maintenance, Withdraw Suspended",
                "withdrawEnable": True,
                "withdrawFee": "0.00050000",
                "withdrawIntegerMultiple": "0.00000001",
                "withdrawMin": "0.00100000"
            }
        ],
        "storage": "0.00000000",
        "trading": True,
        "withdrawAllEnable": True,
        "withdrawing": "0.00000000"
    }
]

GET /sapi/v1/capital/config/getall (HMAC SHA256)

获取针对用户的所有币种信息。

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES

提币[SAPI]

响应

{
    "id":"7213fea8e94b4a5593d507237e5a555b"
}

POST /sapi/v1/capital/withdraw/apply (HMAC SHA256)

Submit a withdraw request.

权重: 1

参数:

名称 类型 是否必需 描述
coin STRING YES
network STRING NO 提币网络
address STRING YES 提币地址
addressTag STRING NO 某些币种例如 XRP,XMR 允许填写次级地址标签
amount DECIMAL YES 数量
name STRING NO 地址的备注,填写该参数后会加入该币种的提现地址簿。地址簿上限为20,超出后会造成提现失败。
recvWindow LONG NO
timestamp LONG YES

提币

响应

{
    "msg": "success",
    "success": true,
    "id":"7213fea8e94b4a5593d507237e5a555b"
}

POST /wapi/v3/withdraw.html (HMAC SHA256)

提交提现请求。

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING YES
network STRING NO 提币网络
address STRING YES 提币地址
addressTag STRING NO 某些币种例如 XRP,XMR 允许填写次级地址标签
amount DECIMAL YES
name STRING NO 地址的备注,填写该参数后会加入该币种的提现地址簿。地址簿上限为20,超出后会造成提现失败。
recvWindow LONG NO
timestamp LONG YES

获取充值历史(支持多网络) (USER_DATA)

响应

[
    {
        "address": "0xddc66e4313fd6c737b6cae67cad90bb4e0ac7092",
        "addressTag": "",
        "amount": "139.04370000",
        "coin": "USDT",
        "insertTime": 1566791463000,
        "network": "ETH",
        "status": 1,
        "txId": "0x5759dfe9983a4c7619bce9bc736bb6c26f804091753bf66fa91e7cd5cfeebafd"
    }
]

GET /sapi/v1/capital/deposit/hisrec (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
coin STRING NO
status INT NO 0(0:pending,6: credited but cannot withdraw, 1:success)
startTime LONG NO
endTime LONG NO
offset INT NO default:0
recvWindow LONG NO
timestamp LONG YES

获取充值历史 (USER_DATA)

响应

{
    "depositList": [
        {
            "insertTime": 1508198532000,   //币安系统记录该笔充值的时间
            "amount": 0.04670582,   //充值金额
            "asset": "ETH",   //充值资产
            "address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",   //充值来源地址
            "txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1",   //充值交易id
            "status": 1
        },
        {
            "insertTime": 1508298532000,
            "amount": 1000,
            "asset": "XMR",
            "address": "463tWEBn5XZJSxLU34r6g7h8jtxuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ",
            "addressTag": "342341222",
            "txId": "b3c6219639c8ae3f9cf010cdc24fw7f7yt8j1e063f9b4bd1a05cb44c4b6e2509",
            "status": 1
        }
    ],
    "success": true
}

GET /wapi/v3/depositHistory.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING NO
status INT NO 0(0:充值进行中,1:充值已经成功)
startTime LONG NO
endTime LONG NO
recvWindow LONG NO
timestamp LONG YES

获取提币历史 (支持多网络) (USER_DATA)

响应

[
    {
        "address": "0x94df8b352de7f46f64b01d3666bf6e936e44ce60",
        "amount": "8.91000000",   // 提现转出金额
        "applyTime": "2019-10-12 11:12:02",  // UTC 时间
        "coin": "USDT",
        "id": "b6ae22b3aa844210a7041aee7589627c",  // 该笔提现在币安的id
        "network": "ETH",    
        "status": 6,
        "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268"   // 提现交易id
    },
    {
        "address": "1FZdVHtiBqMrWdjPyRPULCUceZPJ2WLCsB",
        "amount": "0.00150000",
        "applyTime": "2019-09-24 12:43:45",
        "coin": "BTC",
        "id": "156ec387f49b41df8724fa744fa82719",
        "network": "BTC",
        "status": 6,
        "txId": "60fd9007ebfddc753455f95fafa808c4302c836e4d1eebc5a132c36c1d8ac354"
    }
]

Get /sapi/v1/capital/withdraw/history (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
coin STRING NO
status INT NO 0(0:已发送确认Email,1:已被用户取消 2:等待确认 3:被拒绝 4:处理中 5:提现交易失败 6 提现完成)
offset INT NO
limit ING NO
startTime LONG NO
endTime LONG NO
recvWindow LONG NO
timestamp LONG YES

获取提币历史 (USER_DATA)

响应

{
    "withdrawList": [
        {
            "id":"7213fea8e94b4a5593d507237e5a555b",   
            "amount": 0.99,   
            "transactionFee": 0.01,   
            "address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",   
            "asset": "ETH",
            "txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1",
            "applyTime": 1508198532000,
            "status": 4
        },
        {
            "id":"7213fea8e94b4a5534ggsd237e5a555b",   //该笔提现在币安的id
            "amount": 999.9999,   //提现转出金额
            "transactionFee": 0.0001,   //提现手续费
            "address": "463tWEBn5XZJSxLU34r6g7h8jtxuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ",   //提现目的地址
            "addressTag": "342341222",   //提现备注 只对某些币种存在
            "txId": "b3c6219639c8ae3f9cf010cdc24fw7f7yt8j1e063f9b4bd1a05cb44c4b6e2509",   //提现交易id
            "asset": "XMR",
            "applyTime": 1508198532000,
            "status": 4
        }
    ],
    "success": true
}

GET /wapi/v3/withdrawHistory.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING NO
status INT NO 0(0:已发送确认Email,1:已被用户取消 2:等待确认 3:被拒绝 4:处理中 5:提现交易失败 6 提现完成)
startTime LONG NO
endTime LONG NO
recvWindow LONG NO
timestamp LONG YES

获取充值地址 (支持多网络) (USER_DATA)

响应

{
    "address": "1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv",
    "coin": "BTC",
    "tag": "",
    "url": "https://btc.com/1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv"
}

GET /sapi/v1/capital/deposit/address (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
coin STRING YES
network STRING NO
recvWindow LONG NO
timestamp LONG YES

获取充值地址 (USER_DATA)

响应

{
    "address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
    "success": true,
    "addressTag": "1231212",
    "asset": "BNB"
}

GET /wapi/v3/depositAddress.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING YES
status Boolean NO
recvWindow LONG NO
timestamp LONG YES

账户状态 (USER_DATA)

响应

{
    "msg": "Order failed:Low Order fill rate! Will be reactivated after 5 minutes.",    //msg中给出了账户状态,左边的例子表示由于成交率过低被暂停交易权限。
    "success": true,
    "objs": [
        "5"
    ]
}

GET /wapi/v3/accountStatus.html

获取账户状态详情。

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES

账户API交易状态(USER_DATA)

响应

{
    "success": true,     // 查询结果
    "status": {          // 账户API交易状态详情
        "isLocked": false,   // API交易功能是否被锁
        "plannedRecoverTime": 0,  // API交易功能被锁情况下的预计恢复时间
        "triggerCondition": { 
            "GCR": 150,  // Number of GTC orders
            "IFER": 150, // Number of FOK/IOC orders
            "UFR": 300   // Number of orders
        },
        "indicators": {  // The indicators updated every 30 seconds
           "BTCUSDT": [  // The symbol
            {
            "i": "UFR",  // Unfilled Ratio (UFR)
            "c": 20,     // Count of all orders
            "v": 0.05,   // Current UFR value
            "t": 0.995   // Trigger UFR value
            },
            {
            "i": "IFER", // IOC/FOK Expiration Ratio (IFER)
            "c": 20,     // Count of FOK/IOC orders
            "v": 0.99,   // Current IFER value
            "t": 0.99    // Trigger IFER value
            },
            {
            "i": "GCR",  // GTC Cancellation Ratio (GCR)
            "c": 20,     // Count of GTC orders
            "v": 0.99,   // Current GCR value
            "t": 0.99    // Trigger GCR value
            }
            ],
            "ETHUSDT": [ 
            {
            "i": "UFR",
            "c": 20,
            "v": 0.05,
            "t": 0.995
            },
            {
            "i": "IFER",
            "c": 20,
            "v": 0.99,
            "t": 0.99
            },
            {
            "i": "GCR",
            "c": 20,
            "v": 0.99,
            "t": 0.99
            }
            ]
        },
        "updateTime": 1547630471725   
    }
}

GET /wapi/v3/apiTradingStatus.html

获取 api 账户交易状态详情。 更多api交易规则详情, 请参考链接: https://support.binance.com/hc/en-us/articles/115003235691

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES

小额资产转换BNB历史 (USER_DATA)

响应

{
    "success": true, 
    "results": {
        "total": 2,   //共计发生过的转换笔数
        "rows": [
            {
                "transfered_total": "0.00132256",   //本次转换所得BNB
                "service_charge_total": "0.00002699",   //本次转换手续费(BNB)
                "tran_id": 4359321,
                "logs": [           //本次转换的细节
                    {
                        "tranId": 4359321,
                        "serviceChargeAmount": "0.000009",
                        "uid": "10000015",
                        "amount": "0.0009",
                        "operateTime": "2018-05-03 17:07:04",
                        "transferedAmount": "0.000441",
                        "fromAsset": "USDT"
                    },
                    {
                        "tranId": 4359321,
                        "serviceChargeAmount": "0.00001799",
                        "uid": "10000015",
                        "amount": "0.0009",
                        "operateTime": "2018-05-03 17:07:04",
                        "transferedAmount": "0.00088156",
                        "fromAsset": "ETH"
                    }
                ],
                "operate_time": "2018-05-03 17:07:04" //The time of this exchange.
            },
            {
                "transfered_total": "0.00058795",
                "service_charge_total": "0.000012",
                "tran_id": 4357015,
                "logs": [       
                    {
                        "tranId": 4357015,
                        "serviceChargeAmount": "0.00001",
                        "uid": "10000015",
                        "amount": "0.001",
                        "operateTime": "2018-05-02 13:52:24",
                        "transferedAmount": "0.00049",
                        "fromAsset": "USDT"
                    },
                    {
                        "tranId": 4357015,
                        "serviceChargeAmount": "0.000002",
                        "uid": "10000015",
                        "amount": "0.0001",
                        "operateTime": "2018-05-02 13:51:11",
                        "transferedAmount": "0.00009795",
                        "fromAsset": "ETH"
                    }
                ],
                "operate_time": "2018-05-02 13:51:11"
            }
        ]
    }
}

GET /wapi/v3/userAssetDribbletLog.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES

交易手续费率查询 (USER_DATA)

响应

{
    "tradeFee": [{
        "symbol": "ADABNB",
        "maker": 0.9000,
        "taker": 1.0000
    }, {
        "symbol": "BNBBTC",
        "maker": 0.3000,
        "taker": 0.3000
    }],
    "success": true
}

GET /wapi/v3/tradeFee.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES
symbol STRING NO

上架资产详情 (USER_DATA)

响应

{
    "success": true,
    "assetDetail": {
        "CTR": {
            "minWithdrawAmount": "70.00000000",   //最小提现数量
            "depositStatus": false,   //是否可以充值
            "withdrawFee": 35,   // 提现手续费
            "withdrawStatus": true,    //是否开放提现
            "depositTip": "Delisted, Deposit Suspended"   //暂停充值的原因(如果暂停才有这一项)
        },
        "SKY": {
            "minWithdrawAmount": "0.02000000",
            "depositStatus": true,
            "withdrawFee": 0.01,
            "withdrawStatus": true
        }   
    }
}

GET /wapi/v3/assetDetail.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES

查询子账户列表(适用主账户)

响应

{
    "success":true,
    "subAccounts":[
        {
            "email":"123@test.com",
            "status":"enabled",
            "activated":true,
            "mobile":"91605290",
            "gAuth":true,
            "createTime":1544433328000
        },
        {
            "email":"321@test.com",
            "status":"disabled",
            "activated":true,
            "mobile":"22501238",
            "gAuth":true,
            "createTime":1544433328000
        }
    ]
}

GET /wapi/v3/sub-account/list.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING NO 子账户详情
status STRING NO 子账户状态: 启用或禁用
page INT NO 默认值: 1
limit INT NO 默认值: 500
recvWindow LONG NO
timestamp LONG YES

查询子账户划转历史(适用主账户)

响应

{
    "success":true,
    "transfers":[
        {
            "from":"aaa@test.com",
            "to":"bbb@test.com",
            "asset":"BTC",
            "qty":"1",
            "time":1544433328000
        },
        {
            "from":"bbb@test.com",
            "to":"ccc@test.com",
            "asset":"ETH",
            "qty":"2",
            "time":1544433328000
        }
    ]
}

GET /wapi/v3/sub-account/transfer/history.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES 子账户邮箱地址
startTime LONG NO 默认返回100天内历史记录
endTime LONG NO 默认返回100天内历史记录
page INT NO 默认值: 1
limit INT NO 默认值: 500
recvWindow LONG NO
timestamp LONG YES

执行子账户划转(适用主账户)

响应

{
    "success":true,
    "txnId":"2966662589"
}

POST /wapi/v3/sub-account/transfer.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
fromEmail STRING YES 发送者邮箱地址
toEmail STRING YES 接收者邮箱地址
asset STRING YES
amount DECIMAL YES
recvWindow LONG NO
timestamp LONG YES

查询子账户资产(适用主账户)

响应

{

    "success":true,
    "balances":[
        {
            "asset":"ADA",
            "free":10000,
            "locked":0
        },
        {
            "asset":"BNB",
            "free":10003,
            "locked":0
        },
        {
            "asset":"BTC",
            "free":11467.6399,
            "locked":0
        },
        {
            "asset":"ETH",
            "free":10004.995,
            "locked":0
        },
        {
            "asset":"USDT",
            "free":11652.14213,
            "locked":0
        }
    ]
}

GET /wapi/v3/sub-account/assets.html (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES 子账户邮件
recvWindow LONG NO
timestamp LONG YES
symbol STRING NO

获取子账户充值地址(适用主账户)

响应

{
    "address":"TDunhSa7jkTNuKrusUTU1MUHtqXoBPKETV",
    "coin":"USDT",
    "tag":"",
    "url":"https://tronscan.org/#/address/TDunhSa7jkTNuKrusUTU1MUHtqXoBPKETV"
}

GET /sapi/v1/capital/deposit/subAddress (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES Sub account email
coin STRING YES
network STRING NO
recvWindow LONG NO
timestamp LONG YES

获取子账户充值记录 (适用主账户)

响应

[
    {
        "address":"0x1cc9380c0027b3a1dc603ee369f3fa23464e2d0c",
        "addressTag":"",
        "amount":"3.13000000",
        "coin":"POA",
        "insertTime":1555320696000,
        "status":1,
        "txId":"0x0dd033de5b1531ea463cbd9aae492bafca4daad497a733a48f8ea75cad15b93b"
    },
    {
        "address":"QSNnvmH8GfLt9eCeVqgQdjmDYp3qGA5o6j",
        "addressTag":"",
        "amount":"0.99000000",
        "coin":"QTUM",
        "insertTime":1555299491000,
        "status":1,
        "txId":"fd9bc013d37c82ebcd5fb0bba6727c12e8649c541e57d85a4a142a0b7fd19183"
    },
    {
        "address":"hx9995931e4ac4cafe0da5a0e0fe22ff2397ae8604",
        "addressTag":"",
        "amount":"1.98000000",
        "coin":"ICX",
        "insertTime":1555078384000,
        "status":1,
        "txId":"0xbe6de043d8f26b1f21ce9345fc7e8346013d22001095dedc7939633990783ffa"
    }
]

GET /sapi/v1/capital/deposit/subHisrec (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES Sub account email
coin STRING NO
status INT NO 0(0:pending,6: credited but cannot withdraw, 1:success)
startTime LONG NO
endTime LONG NO
limit INT NO
offset INT NO default:0
recvWindow LONG NO
timestamp LONG YES

查询子账户Margin/Futures状态 (适用主账户)

响应

[
    {
        "email":"123@test.com",         // user email
        "isSubUserEnabled":"true",      // true or false
        "isUserActive":true,            // true or false
        "insertTime": 1570791523523     // sub account create time
        "isMarginEnabled": "true",      //true or false for margin
        "isFutureEnabled": "true"       //true or false for futures.
        "mobile": 1570791523523         // user mobile number
    }
]

GET /sapi/v1/sub-account/status (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING NO Sub-account email
recvWindow LONG NO
timestamp LONG YES

为子账户开通Margin (适用主账户)

响应

{

    "email":"123@test.com",

    "isMarginEnabled": "true"

}

POST /sapi/v1/sub-account/margin/enable (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES Sub-account email
recvWindow LONG NO
timestamp LONG YES

查询子账户Margin账户详情 (适用主账户)

响应

{
      "email":"123@test.com",
      "marginLevel": "11.64405625",
      "totalAssetOfBtc": "6.82728457",
      "totalLiabilityOfBtc": "0.58633215",
      "totalNetAssetOfBtc": "6.24095242",
      "marginUserAssetVoList": [
          {
              "asset": "BTC",
              "borrowed": "0.00000000",
              "free": "0.00499500",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00499500"
          },
          {
              "asset": "BNB",
              "borrowed": "201.66666672",
              "free": "2346.50000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "2144.83333328"
          },
          {
              "asset": "ETH",
              "borrowed": "0.00000000",
              "free": "0.00000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00000000"
          },
          {
              "asset": "USDT",
              "borrowed": "0.00000000",
              "free": "0.00000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00000000"
          }
      ]
}

GET /sapi/v1/sub-account/margin/account (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES Sub-account email
recvWindow LONG NO

timestamp LONG YES

查询子账户Margin账户汇总 (适用主账户)

响应

{
    "totalAssetOfBtc": "4.33333333", 
    "totalLiabilityOfBtc": "2.11111112", 
    "totalNetAssetOfBtc": "2.22222221",
    "subAccountList":[
        {
            "email":"123@test.com",
            "totalAssetOfBtc": "2.11111111",
            "totalLiabilityOfBtc": "1.11111111",
            "totalNetAssetOfBtc": "1.00000000"
        },
        { 
            "email":"345@test.com",
            "totalAssetOfBtc": "2.22222222", 
            "totalLiabilityOfBtc": "1.00000001", 
            "totalNetAssetOfBtc": "1.22222221"
        }
    ]
}

GET /sapi/v1/sub-account/margin/accountSummary (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES

为子账户开通Futures (适用主账户)

响应

{

    "email":"123@test.com",

    "isFuturesEnabled": "true"// true or false

}

POST /sapi/v1/sub-account/futures/enable (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES Sub-account email
recvWindow LONG NO
timestamp LONG YES

查询子账户Futures账户详情 (适用主账户)

响应

{
    "email": 123@test.com",
    "assets": [
        {
            "asset": "USDT",
            "initialMargin": "9.00000000",
            "maintMargin": "0.00000000",
            "marginBalance": "22.12659734",
            "maxWithdrawAmount": "13.12659734",
            "openOrderInitialMargin": "9.00000000",
            "positionInitialMargin": "0.00000000",
            "unrealizedProfit": "0.00000000",
            "walletBalance": "22.12659734"
        }
    ],
    "canDeposit": True,
    "canTrade": True,
    "canWithdraw": True,
    "feeTier": 0,
    "maxWithdrawAmount": "13.12659734",
    "totalInitialMargin": "9.00000000",
    "totalMaintMargin": "0.00000000",
    "totalMarginBalance": "22.12659734",
    "totalOpenOrderInitialMargin": u"9.00000000",
    "totalPositionInitialMargin": u"0.00000000",
    "totalUnrealizedProfit": u"0.00000000",
    "totalWalletBalance": u"22.12659734",
    "asset": "USDT",
    "updateTime": 0

}

GET /sapi/v1/sub-account/futures/account (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email STRING YES Sub-account email
recvWindow LONG NO
timestamp LONG YES

查询子账户Futures账户汇总 (适用主账户)

响应

{
    "totalInitialMargin": "9.83137400", 
    "totalMaintMargin": "0.41568700", 
    "totalMarginBalance": "23.03235621", 
    "totalOpenOrderInitialMargin": u"9.00000000", 
    "totalPositionInitialMargin": u"0.83137400", 
    "totalUnrealizedProfit": u"0.03219710", 
    "totalWalletBalance": u"22.15879444",
    "asset": "USDT",
    "subAccount":[
        {
            "email": 123@test.com",
            "totalInitialMargin": "9.00000000", 
            "totalMaintMargin": "0.00000000", 
            "totalMarginBalance": "22.12659734", 
            "totalOpenOrderInitialMargin": u"9.00000000", 
            "totalPositionInitialMargin": u"0.00000000", 
            "totalUnrealizedProfit": u"0.00000000", 
            "totalWalletBalance": u"22.12659734",
            "asset": "USDT"
        },
        { 
            "email": 345@test.com",
            "totalInitialMargin": "0.83137400", 
            "totalMaintMargin": "0.41568700", 
            "totalMarginBalance": "0.90575887", 
            "totalOpenOrderInitialMargin": u"0.00000000",  
            "totalPositionInitialMargin": u"0.83137400", 
            "totalUnrealizedProfit": u"0.03219710", 
            "totalWalletBalance": u"0.87356177",
            "asset": "USDT"
        }
    ]
}

GET /sapi/v1/sub-account/futures/accountSummary (HMAC SHA256)

权重: 20

参数:

名称 类型 是否必需 描述
recvWindow LONG NO
timestamp LONG YES

查询子账户合约持仓信息 (仅适用主账户)

响应

[
    {
        "entryPrice": "9975.12000",
        "leverage": "50",                   // current initial leverage
        "maxNotional": "1000000",      // notional value limit of current initial leverage
        "liquidationPrice": "7963.54",
        "markPrice": "9973.50770517",
        "positionAmt": "0.010",
        "symbol": "BTCUSDT",
        "unRealizedProfit": "-0.01612295"
    }
]

GET /sapi/v1/sub-account/futures/positionRisk (HMAC SHA256)

权重: 1

参数:

名称 类型 是否必需 描述
email String YES Sub-account email
recvWindow LONG NO
timestamp LONG YES

小额资产转换 (USER_DATA)

响应

{
    "totalServiceCharge":"0.02102542",
    "totalTransfered":"1.05127099",
    "transferResult":[
        {
            "amount":"0.03000000",
            "fromAsset":"ETH",
            "operateTime":1563368549307,
            "serviceChargeAmount":"0.00500000",
            "tranId":2970932918,
            "transferedAmount":"0.25000000"
        },
        {
            "amount":"0.09000000",
            "fromAsset":"LTC",
            "operateTime":1563368549404,
            "serviceChargeAmount":"0.01548000",
            "tranId":2970932918,
            "transferedAmount":"0.77400000"
        },
        {
            "amount":"248.61878453",
            "fromAsset":"TRX",
            "operateTime":1563368549489,
            "serviceChargeAmount":"0.00054542",
            "tranId":2970932918,
            "transferedAmount":"0.02727099"
        }
    ]
}

Post /sapi/v1/asset/dust (HMAC SHA256)

把小额资产转换成 BNB.

权重: 1

参数:

名称 类型 是否必需 描述
asset ARRAY YES 正在转换的资产。 例如:asset = BTC&asset = USDT
recvWindow LONG NO
timestamp LONG YES

资产利息记录 (USER_DATA)

响应

{
    "rows":[
        {
            "amount":"10.00000000",
            "asset":"BHFT",
            "divTime":1563189166000,
            "enInfo":"BHFT distribution",
            "tranId":2968885920
        },
        {
            "amount":"10.00000000",
            "asset":"BHFT",
            "divTime":1563189165000,
            "enInfo":"BHFT distribution",
            "tranId":2968885920
        }
    ],
    "total":2
}

Get /sapi/v1/asset/assetDividend (HMAC SHA256)

获取资产利息记录。

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING NO
startTime LONG NO
endTime LONG NO
recvWindow LONG NO
timestamp LONG YES

行情接口

测试服务器连通性

响应

{}

GET /api/v3/ping

测试能否联通 Rest API。

权重:

1

参数:

NONE

获取服务器时间

响应

{
  "serverTime": 1499827319559
}

GET /api/v3/time

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

权重: 1

参数:

NONE

交易规范信息

响应

{
    "timezone": "UTC",
    "serverTime": 1565246363776,
    "rateLimits": [
        {
            //These are defined in the `ENUM definitions` section under `Rate Limiters (rateLimitType)`.
            //All limits are optional
        }
    ],
    "exchangeFilters": [
            //These are the defined filters in the `Filters` section.
            //All filters are optional.
    ],
    "symbols": [
        {
            "symbol": "ETHBTC",
            "status": "TRADING",
            "baseAsset": "ETH",
            "baseAssetPrecision": 8,
            "quoteAsset": "BTC",
            "quotePrecision": 8,
            "orderTypes": [
                "LIMIT",
                "LIMIT_MAKER",
                "MARKET",
                "STOP_LOSS",
                "STOP_LOSS_LIMIT",
                "TAKE_PROFIT",
                "TAKE_PROFIT_LIMIT"
            ],
            "icebergAllowed": true,
            "ocoAllowed": true,
            "isSpotTradingAllowed": true,
            "isMarginTradingAllowed": false,
            "filters": [
            //These are defined in the Filters section.
            //All filters are optional
            ]
        }
    ]
}

GET /api/v3/exchangeInfo

获取交易规则和交易对信息。

权重: 1

参数:

NONE

深度信息

响应

{
  "lastUpdateId": 1027024,
  "bids": [
    [
      "4.00000000",     // 价位
      "431.00000000"    // 挂单量
    ]
  ],
  "asks": [
    [
      "4.00000200",
      "12.00000000"
    ]
  ]
}

GET /api/v3/depth

权重:

基于限制调整:

限制 权重
5, 10, 20, 50, 100 1
500 5
1000 10
5000 50

参数:

名称 类型 是否必需 描述
symbol STRING YES
limit INT NO 默认 100; 最大 1000. 可选值:[5, 10, 20, 50, 100, 500, 1000, 5000]

近期成交列表

响应

[
  {
    "id": 28457,
    "price": "4.00000100",
    "qty": "12.00000000",
    "time": 1499865549590,
    "isBuyerMaker": true,
    "isBestMatch": true
  }
]

GET /api/v3/trades

获取近期成交

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
limit INT NO 默认 500; 最大值 1000.

查询历史成交

响应

[
  {
    "id": 28457,
    "price": "4.00000100",
    "qty": "12.00000000",
    "time": 1499865549590,
    "isBuyerMaker": true,
    "isBestMatch": true
  }
]

GET /api/v3/historicalTrades

获取历史成交。

权重: 5

参数:

名称 类型 是否必需 描述
symbol STRING YES
limit INT NO 默认 500; 最大值 1000.
fromId LONG NO 从哪一条成交id开始返回. 缺省返回最近的成交记录。

近期成交(归集)

响应

[
  {
    "a": 26129,         // 归集成交ID
    "p": "0.01633102",  // 成交价
    "q": "4.70443515",  // 成交量
    "f": 27781,         // 被归集的首个成交ID
    "l": 27781,         // 被归集的末个成交ID
    "T": 1498793709153, // 成交时间
    "m": true,          // 是否为主动卖出单
    "M": true           // 是否为最优撮合单(可忽略,目前总为最优撮合)
  }
]

GET /api/v3/aggTrades

归集交易与逐笔交易的区别在于,同一价格、同一方向、同一时间的trade会被聚合为一条

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
fromId LONG NO 从包含fromId的成交id开始返回结果
startTime LONG NO 从该时刻之后的成交记录开始返回结果
endTime LONG NO 返回该时刻为止的成交记录
limit INT NO 默认 500; 最大 1000.

K线数据

响应

[
  [
    1499040000000,      // 开盘时间
    "0.01634790",       // 开盘价
    "0.80000000",       // 最高价
    "0.01575800",       // 最低价
    "0.01577100",       // 收盘价(当前K线未结束的即为最新价)
    "148976.11427815",  // 成交量
    1499644799999,      // 收盘时间
    "2434.19055334",    // 成交额
    308,                // 成交笔数
    "1756.87402397",    // 主动买入成交量
    "28.46694368",      // 主动买入成交额
    "17928899.62484339" // 请忽略该参数
  ]
]

GET /api/v3/klines

每根K线代表一个交易对。
每根K线的开盘时间可视为唯一ID

权重: 1

参数:

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

当前平均价格

响应

{
  "mins": 5,
  "price": "9.35751834"
}

GET /api/v3/avgPrice

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES

24hr 价格变动情况

响应

{
  "symbol": "BNBBTC",
  "priceChange": "-94.99999800",
  "priceChangePercent": "-95.960",
  "weightedAvgPrice": "0.29628482",
  "prevClosePrice": "0.10002000",
  "lastPrice": "4.00000200",
  "lastQty": "200.00000000",
  "bidPrice": "4.00000000",
  "askPrice": "4.00000200",
  "openPrice": "99.00000000",
  "highPrice": "100.00000000",
  "lowPrice": "0.10000000",
  "volume": "8913.30000000",
  "quoteVolume": "15.30000000",
  "openTime": 1499783499040,
  "closeTime": 1499869899040,
  "firstId": 28385,   // 首笔成交id
  "lastId": 28460,    // 末笔成交id
  "count": 76         // 成交笔数
}

OR

[
  {
    "symbol": "BNBBTC",
    "priceChange": "-94.99999800",
    "priceChangePercent": "-95.960",
    "weightedAvgPrice": "0.29628482",
    "prevClosePrice": "0.10002000",
    "lastPrice": "4.00000200",
    "lastQty": "200.00000000",
    "bidPrice": "4.00000000",
    "askPrice": "4.00000200",
    "openPrice": "99.00000000",
    "highPrice": "100.00000000",
    "lowPrice": "0.10000000",
    "volume": "8913.30000000",
    "quoteVolume": "15.30000000",
    "openTime": 1499783499040,
    "closeTime": 1499869899040,
    "firstId": 28385,  
    "lastId": 28460,   
    "count": 76      
  }
]

GET /api/v3/ticker/24hr

24 小时滚动窗口价格变动数据。 请注意,不携带symbol参数会返回全部交易对数据,不仅数据庞大,而且权重极高

权重:

1 单一交易对;
40 交易对参数缺失

参数:

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

最新价格

响应

{
  "symbol": "LTCBTC",
  "price": "4.00000200"
}

OR

[
  {
    "symbol": "LTCBTC",
    "price": "4.00000200"
  },
  {
    "symbol": "ETHBTC",
    "price": "0.07946600"
  }
]

GET /api/v3/ticker/price

获取交易对最新价格

权重:

1 单一交易对;
2 交易对参数缺失

参数:

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

当前最优挂单

响应

{
  "symbol": "LTCBTC",
  "bidPrice": "4.00000000",
  "bidQty": "431.00000000",
  "askPrice": "4.00000200",
  "askQty": "9.00000000"
}

OR

[
  {
    "symbol": "LTCBTC",
    "bidPrice": "4.00000000",
    "bidQty": "431.00000000",
    "askPrice": "4.00000200",
    "askQty": "9.00000000"
  },
  {
    "symbol": "ETHBTC",
    "bidPrice": "0.07946700",
    "bidQty": "9.00000000",
    "askPrice": "100000.00000000",
    "askQty": "1000.00000000"
  }
]

GET /api/v3/ticker/bookTicker

返回当前最优的挂单(最高买单,最低卖单)

权重:

1 单一交易对;
2 交易对参数缺失

参数:

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

Websocket 行情推送

实时订阅/取消数据流

订阅一个信息流

响应

  {
    "result": null,
    "id": 1
  }

取消订阅一个信息流

响应

  {
    "result": null,
    "id": 312
  }

{
"method": "UNSUBSCRIBE",
"params":
[
"btcusdt@depth"
],
"id": 312
}

已订阅信息流

响应

  {
    "result": [
      "btcusdt@aggTrade"
    ],
    "id": 3
  }

{
"method": "LIST_SUBSCRIPTIONS",
"id": 3
}

设定属性

当前,唯一可以设置的属性是设置是否启用combined(“组合”)信息流。
当使用/ws/(“原始信息流”)进行连接时,combined属性设置为false,而使用 /stream/进行连接时则将属性设置为true

响应

{
  "result": null,
  "id": 5
}

{
"method": "SET_PROPERTY",
"params":
[
"combined",
true
],
"id": 5
}

检索属性

响应

  {
    "result": true, // Indicates that combined is set to true.
    "id": 2
  }

{
"method": "GET_PROPERTY",
"params":
[
"combined"
],
"id": 2
}

错误信息

错误信息 描述
{"code": 0, "msg": "Unknown property"} SET_PROPERTYGET_PROPERTY中应用的参数无效
{"code": 1, "msg": "Invalid value type: expected Boolean"} 仅接受truefalse
{"code": 2, "msg": "Invalid request: property name must be a string"} 提供的属性名无效
{"code": 2, "msg": "Invalid request: request ID must be an unsigned integer"} 参数id未提供或id值是无效类型
{"code": 2, "msg": "Invalid request: unknown variant %s, expected one of SUBSCRIBE, UNSUBSCRIBE, LIST_SUBSCRIPTIONS, SET_PROPERTY, GET_PROPERTY at line 1 column 28"} 错字提醒,或提供的值不是预期类型
{"code": 2, "msg": "Invalid request: too many parameters"} 数据中提供了不必要参数
{"code": 2, "msg": "Invalid request: property name must be a string"} 未提供属性名
{"code": 2, "msg": "Invalid request: missing field method at line 1 column 73"} 数据未提供method
{"code":3,"msg":"Invalid JSON: expected value at line %s column %s"} JSON 语法有误.

归集交易流

Payload:

{
  "e": "aggTrade",  // 事件类型
  "E": 123456789,   // 事件时间
  "s": "BNBBTC",    // 交易对
  "a": 12345,       // 归集交易ID
  "p": "0.001",     // 成交价格
  "q": "100",       // 成交数量
  "f": 100,         // 被归集的首个交易ID
  "l": 105,         // 被归集的末次交易ID
  "T": 123456785,   // 成交时间
  "m": true,        // 买方是否是做市方。如true,则此次成交是一个主动卖出单,否则是一个主动买入单。
  "M": true         // 请忽略该字段
}

归集交易 stream 推送交易信息,是对单一订单的集合。

Stream 名称: <symbol>@aggTrade
Update Speed: 实时

逐笔交易

Payload:

{
  "e": "trade",     // 事件类型
  "E": 123456789,   // 事件时间
  "s": "BNBBTC",    // 交易对
  "t": 12345,       // 交易ID
  "p": "0.001",     // 成交价格
  "q": "100",       // 成交数量
  "b": 88,          // 买方的订单ID
  "a": 50,          // 卖方的订单ID
  "T": 123456785,   // 成交时间
  "m": true,        // 买方是否是做市方。如true,则此次成交是一个主动卖出单,否则是一个主动买入单。
  "M": true         // 请忽略该字段
}

Stream Name: <symbol>@trade

逐笔交易推送每一笔成交的信息。成交,或者说交易的定义是仅有一个吃单者与一个挂单者相互交易

K线 Streams

Payload:

{
  "e": "kline",     // 事件类型
  "E": 123456789,   // 事件时间
  "s": "BNBBTC",    // 交易对
  "k": {
    "t": 123400000, // 这根K线的起始时间
    "T": 123460000, // 这根K线的结束时间
    "s": "BNBBTC",  // 交易对
    "i": "1m",      // K线间隔
    "f": 100,       // 这根K线期间第一笔成交ID
    "L": 200,       // 这根K线期间末一笔成交ID
    "o": "0.0010",  // 这根K线期间第一笔成交价
    "c": "0.0020",  // 这根K线期间末一笔成交价
    "h": "0.0025",  // 这根K线期间最高成交价
    "l": "0.0015",  // 这根K线期间最低成交价
    "v": "1000",    // 这根K线期间成交量
    "n": 100,       // 这根K线期间成交数量
    "x": false,     // 这根K线是否完结(是否已经开始下一根K线)
    "q": "1.0000",  // 这根K线期间成交额
    "V": "500",     // 主动买入的成交量
    "Q": "0.500",   // 主动买入的成交额
    "B": "123456"   // 忽略此参数
  }
}

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

Stream Name: <symbol>@kline_<interval>

Update Speed: 2000ms

K线图间隔参数:

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

按 Symbol 的精简Ticker

Payload:

  {
    "e": "24hrMiniTicker",  // 事件类型
    "E": 123456789,         // 事件时间
    "s": "BNBBTC",          // 交易对
    "c": "0.0025",          // 最新成交价格
    "o": "0.0010",          // 24小时前开始第一笔成交价格
    "h": "0.0025",          // 24小时内最高成交价
    "l": "0.0010",          // 24小时内最低成交加
    "v": "10000",           // 成交量
    "q": "18"               // 成交额
  }

按Symbol刷新的最近24小时精简ticker信息

Stream 名称: <symbol>@miniTicker

Update Speed: 1000ms

全市场所有Symbol的精简Ticker

Payload: javascript [ { // 数组每一个元素对应一个交易对,内容与 \<symbol\>@miniTicker相同 } ]

同上,只是推送所有交易对.需要注意的是,只有更新的ticker才会被推送.

Stream名称: !miniTicker@arr

Update Speed: 1000ms

按Symbol的完整Ticker

Payload:

{
  "e": "24hrTicker",  // 事件类型
  "E": 123456789,     // 事件时间
  "s": "BNBBTC",      // 交易对
  "p": "0.0015",      // 24小时价格变化
  "P": "250.00",      // 24小时价格变化(百分比)
  "w": "0.0018",      // 平均价格
  "x": "0.0009",      // 整整24小时之前,向前数的最后一次成交价格
  "c": "0.0025",      // 最新成交价格
  "Q": "10",          // 最新成交交易的成交量
  "b": "0.0024",      // 目前最高买单价
  "B": "10",          // 目前最高买单价的挂单量
  "a": "0.0026",      // 目前最低卖单价
  "A": "100",         // 目前最低卖单价的挂单量
  "o": "0.0010",      // 整整24小时前,向后数的第一次成交价格
  "h": "0.0025",      // 24小时内最高成交价
  "l": "0.0010",      // 24小时内最低成交加
  "v": "10000",       // 24小时内成交量
  "q": "18",          // 24小时内成交额
  "O": 0,             // TODO 0 ??? 统计开始时间???
  "C": 86400000,      // TODO 3600*24*1000,24小时的毫秒数 ??? 统计关闭时间???
  "F": 0,             // 24小时内第一笔成交交易ID
  "L": 18150,         // 24小时内最后一笔成交交易ID
  "n": 18151          // 24小时内成交数
}

每秒推送单个交易对的过去24小时滚动窗口标签统计信息。

Stream 名称: <symbol>@ticker

Update Speed: 1000ms

全市场所有交易对的完整Ticker

Payload:

[
  {
    // Same as <symbol>@ticker payload
  }
]

Stream Name: !ticker@arr

Update Speed: 1000ms

推送全市场所有交易对刷新的24小时完整ticker信息。需要注意的是,没有更新的ticker不会被推送。

按Symbol的最优挂单信息

Payload:

{
  "u":400900217,     // order book updateId
  "s":"BNBUSDT",     // 交易对
  "b":"25.35190000", // 买单最优挂单价格
  "B":"31.21000000", // 买单最优挂单数量
  "a":"25.36520000", // 卖单最优挂单价格
  "A":"40.66000000"  // 卖单最优挂单数量
}

实时推送指定交易对最优挂单信息

Stream Name: <symbol>@bookTicker

Update Speed: 实时

全市场最优挂单信息

Payload:

{
  // Same as <symbol>@bookTicker payload
}

实时推送所有交易对交易对最优挂单信息

Stream Name: !bookTicker

Update Speed: 实时

有限档深度信息

Payload:

{
  "lastUpdateId": 160,  // Last update ID
  "bids": [             // Bids to be updated
    [
      "0.0024",         // Price level to be updated
      "10"              // Quantity
    ]
  ],
  "asks": [             // Asks to be updated
    [
      "0.0026",         // Price level to be updated
      "100"            // Quantity
    ]
  ]
}

每秒或每100毫秒推送有限档深度信息。levels表示几档买卖单信息, 可选 5/10/20档

Stream Names: <symbol>@depth<levels><symbol>@depth<levels>@100ms.

Update Speed: 1000ms 或 100ms

增量深度信息

Payload:

{
  "e": "depthUpdate", // 事件类型
  "E": 123456789,     // 事件时间
  "s": "BNBBTC",      // 交易对
  "U": 157,           // 从上次推送至今新增的第一个 update Id
  "u": 160,           // 从上次推送至今新增的最后一个 update Id
  "b": [              // 变动的买单深度
    [
      "0.0024",       // 变动的价格档位
      "10"            // 数量
    ]
  ],
  "a": [              // 变动的卖单深度
    [
      "0.0026",       // 变动的价格档位
      "100"           // 数量
    ]
  ]
}

每秒或每100毫秒推送orderbook的变化部分(如果有)

Stream Name: <symbol>@depth<symbol>@depth@100ms

Update Speed: 1000ms 或 100ms

如何正确在本地维护一个orderbook副本

  1. 订阅 wss://stream.binance.com:9443/ws/bnbbtc@depth
  2. 开始缓存收到的更新。同一个价位,后收到的更新覆盖前面的。
  3. 访问Rest接口 https://www.binance.com/api/v1/depth?symbol=BNBBTC&limit=1000 获得一个1000档的深度快照
  4. 将目前缓存到的信息中u <= 步骤3中获取到的快照中的lastUpdateId的部分丢弃(丢弃更早的信息,已经过期)。
  5. 将深度快照中的内容更新到本地orderbook副本中,并从websocket接收到的第一个U <= lastUpdateId+1 u >= lastUpdateId+1 的event开始继续更新本地副本。
  6. 每一个新event的U应该恰好等于上一个event的u+1,否则可能出现了丢包,请从step3重新进行初始化。
  7. 每一个event中的挂单量代表这个价格目前的挂单量绝对值,而不是相对变化。
  8. 如果某个价格对应的挂单量为0,表示该价位的挂单已经撤单或者被吃,应该移除这个价位。

现货账户和交易接口

测试下单 (TRADE)

响应

{}

POST /api/v3/order/test (HMAC SHA256)

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

权重: 1

参数:

同于 POST /api/v3/order

下单 (TRADE)

Response ACK:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "orderListId": -1, //Unless OCO, value will be -1
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595
}

Response RESULT:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "orderListId": -1, //Unless OCO, value will be -1
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595,
  "price": "1.00000000",
  "origQty": "10.00000000",
  "executedQty": "10.00000000",
  "cummulativeQuoteQty": "10.00000000",
  "status": "FILLED",
  "timeInForce": "GTC",
  "type": "MARKET",
  "side": "SELL"
}

Response FULL:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "orderListId": -1, //Unless OCO, value will be -1
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595,
  "price": "1.00000000",
  "origQty": "10.00000000",
  "executedQty": "10.00000000",
  "cummulativeQuoteQty": "10.00000000",
  "status": "FILLED",
  "timeInForce": "GTC",
  "type": "MARKET",
  "side": "SELL",
  "fills": [
    {
      "price": "4000.00000000",
      "qty": "1.00000000",
      "commission": "4.00000000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3999.00000000",
      "qty": "5.00000000",
      "commission": "19.99500000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3998.00000000",
      "qty": "2.00000000",
      "commission": "7.99600000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3997.00000000",
      "qty": "1.00000000",
      "commission": "3.99700000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3995.00000000",
      "qty": "1.00000000",
      "commission": "3.99500000",
      "commissionAsset": "USDT"
    }
  ]
}

POST /api/v3/order (HMAC SHA256)

发送下单。

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
side ENUM YES
type ENUM YES
timeInForce ENUM NO
quantity DECIMAL NO
quoteOrderQty DECIMAL NO
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 创建新的 iceberg 订单时需要此参数
newOrderRespType ENUM NO 设置响应JSON。 ACK,RESULT或FULL; “MARKET”和“ LIMIT”订单类型默认为“FULL”,所有其他订单默认为“ACK”。
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

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

类型 强制要求的参数
LIMIT timeInForce, quantity, price
MARKET quantity or quoteOrderQty
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

其他信息:

MARKET版本和LIMIT版本针对市场价格触发订单价格规则:

关于 newOrderRespType的三种选择

撤销订单 (TRADE)

响应

{
  "symbol": "LTCBTC",
  "origClientOrderId": "myOrder1",
  "orderId": 4,
  "orderListId": -1, //Unless part of an OCO, the value will always be -1.
  "clientOrderId": "cancelMyOrder1",
  "price": "2.00000000",
  "origQty": "1.00000000",
  "executedQty": "0.00000000",
  "cummulativeQuoteQty": "0.00000000",
  "status": "CANCELED",
  "timeInForce": "GTC",
  "type": "LIMIT",
  "side": "BUY"
}

DELETE /api/v3/order (HMAC SHA256)

取消有效订单。

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
orderId LONG NO
origClientOrderId STRING NO
newClientOrderId STRING NO 用户自定义的本次撤销操作的ID(注意不是被撤销的订单的自定义ID)。如无指定会自动赋值。
recvWindow LONG NO 赋值不得大于 60000
timestamp LONG YES

orderIdorigClientOrderId 必须至少发送一个

查询订单 (USER_DATA)

响应

{
  "symbol": "LTCBTC",
  "orderId": 1,
  "orderListId": -1, //Unless OCO, value will be -1
  "clientOrderId": "myOrder1",
  "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,
  "origQuoteOrderQty": "0.000000"
}

GET /api/v3/order (HMAC SHA256)

查询订单状态。

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
orderId LONG NO
origClientOrderId STRING NO
recvWindow LONG NO 赋值不得大于 60000
timestamp LONG YES

注意:

当前挂单 (USER_DATA)

响应

[
  {
    "symbol": "LTCBTC",
    "orderId": 1,
    "orderListId": -1, //Unless OCO, the value will always be -1
    "clientOrderId": "myOrder1",
    "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,
    "origQuoteOrderQty": "0.000000"
  }
]

GET /api/v3/openOrders (HMAC SHA256)

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

权重: 1 单一交易对;
2交易对参数缺失

参数:

名称 类型 是否必需 描述
symbol STRING NO
recvWindow LONG NO 赋值不得大于 60000
timestamp LONG YES

查询所有订单 (USER_DATA)

响应

[
  {
    "symbol": "LTCBTC",
    "orderId": 1,
    "orderListId": -1, //Unless OCO, the value will always be -1
    "clientOrderId": "myOrder1",
    "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,
    "origQuoteOrderQty": "0.000000"
  }
]

GET /api/v3/allOrders (HMAC SHA256)

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

权重: 5 带有symbol

参数:

名称 类型 是否必需 描述
symbol STRING YES
orderId LONG NO
startTime LONG NO
endTime LONG NO
limit INT NO 默认 500; 最大 1000.
recvWindow LONG NO 赋值不得大于 60000
timestamp LONG YES

注意:

OCO下单(TRADE)

响应

{
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
  "transactionTime": 1563417480525,
  "symbol": "LTCBTC",
  "orders": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl"
    }
  ],
  "orderReports": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "orderListId": 0,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos",
      "transactTime": 1563417480525,
      "price": "0.000000",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "STOP_LOSS",
      "side": "BUY",
      "stopPrice": "0.960664"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "orderListId": 0,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl",
      "transactTime": 1563417480525,
      "price": "0.036435",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "LIMIT_MAKER",
      "side": "BUY"
    }
  ]
}

POST /api/v3/order/oco (HMAC SHA256)

权重: 1

发送新 OCO 订单

参数:

名称 类型 是否必需 描述
symbol STRING YES
listClientOrderId STRING NO 整个orderList的唯一ID
side ENUM YES
quantity DECIMAL YES
limitClientOrderId STRING NO 限价单的唯一ID
price DECIMAL YES
limitIcebergQty DECIMAL NO
stopClientOrderId STRING NO 止损/止损限价单的唯一ID
stopPrice DECIMAL YES
stopLimitPrice DECIMAL NO 如果提供,须配合提交stopLimitTimeInForce
stopIcebergQty DECIMAL NO
stopLimitTimeInForce ENUM NO 有效值 GTC/FOK/IOC
newOrderRespType ENUM NO Set the response JSON.
recvWindow LONG NO 不能大于 60000
timestamp LONG YES

其他信息:

取消 OCO 订单(TRADE)

DELETE /api/v3/orderList (HMAC SHA256)

权重: 1

取消整个订单列表。

参数

名称 类型 是否必需 描述
symbol STRING YES
orderListId LONG NO orderListIdlistClientOrderId 必须被提供
listClientOrderId STRING NO orderListIdlistClientOrderId 必须被提供
newClientOrderId STRING NO 用户自定义的本次撤销操作的ID(注意不是被撤销的订单的自定义ID)。如无指定会自动赋值。
recvWindow LONG NO 不能大于 60000
timestamp LONG YES

其他注意点:

查询 OCO (USER_DATA)

响应

{
    "orderListId": 27,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "h2USkA5YQpaXHPIrkd96xE",
    "transactionTime": 1565245656253,
    "symbol": "LTCBTC",
    "orders": [
        {
            "symbol": "LTCBTC",
            "orderId": 4,
            "clientOrderId": "qD1gy3kc3Gx0rihm9Y3xwS"
        },
        {
            "symbol": "LTCBTC",
            "orderId": 5,
            "clientOrderId": "ARzZ9I00CPM8i3NhmU9Ega"
        }
    ]
}

GET /api/v3/orderList (HMAC SHA256)

权重: 1

根据提供的可选参数检索特定的OCO。

参数:

名称 类型 是否必需 描述
orderListId LONG NO orderListIdlistClientOrderId 必须提供一个。
origClientOrderId STRING NO orderListIdlistClientOrderId 必须提供一个。
recvWindow LONG NO 赋值不得大于 60000
timestamp LONG YES

查询所有 OCO (USER_DATA)

响应

[
  {
    "orderListId": 29,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "amEEAXryFzFwYF1FeRpUoZ",
    "transactionTime": 1565245913483,
    "symbol": "LTCBTC",
    "orders": [
      {
        "symbol": "LTCBTC",
        "orderId": 4,
        "clientOrderId": "oD7aesZqjEGlZrbtRpy5zB"
      },
      {
        "symbol": "LTCBTC",
        "orderId": 5,
        "clientOrderId": "Jr1h6xirOxgeJOUuYQS7V3"
      }
    ]
  },
  {
    "orderListId": 28,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "hG7hFNxJV6cZy3Ze4AUT4d",
    "transactionTime": 1565245913407,
    "symbol": "LTCBTC",
    "orders": [
      {
        "symbol": "LTCBTC",
        "orderId": 2,
        "clientOrderId": "j6lFOfbmFMRjTYA7rRJ0LP"
      },
      {
        "symbol": "LTCBTC",
        "orderId": 3,
        "clientOrderId": "z0KCjOdditiLS5ekAFtK81"
      }
    ]
  }
]

GET /api/v3/allOrderList (HMAC SHA256)

权重: 10

根据提供的可选参数检索所有的OCO。

参数

名称 类型 是否必需 描述
fromId LONG NO 提供该项后, startTimeendTime 都不可提供
startTime LONG NO
endTime LONG NO
limit INT NO 默认值: 500; 最大值: 1000
recvWindow LONG NO 赋值不能超过 60000
timestamp LONG YES

查询 OCO 挂单 (USER_DATA)

响应

[
  {
    "orderListId": 31,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "wuB13fmulKj3YjdqWEcsnp",
    "transactionTime": 1565246080644,
    "symbol": "1565246079109",
    "orders": [
      {
        "symbol": "LTCBTC",
        "orderId": 4,
        "clientOrderId": "r3EH2N76dHfLoSZWIUw1bT"
      },
      {
        "symbol": "LTCBTC",
        "orderId": 5,
        "clientOrderId": "Cv1SnyPD3qhqpbjpYEHbd2"
      }
    ]
  }
]

GET /api/v3/openOrderList (HMAC SHA256)

权重: 2

参数

名称 类型 是否必需 描述
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

账户信息 (USER_DATA)

响应

{
  "makerCommission": 15,
  "takerCommission": 15,
  "buyerCommission": 0,
  "sellerCommission": 0,
  "canTrade": true,
  "canWithdraw": true,
  "canDeposit": true,
  "updateTime": 123456789,
  "accountType": "SPOT",
  "balances": [
    {
      "asset": "BTC",
      "free": "4723846.89208129",
      "locked": "0.00000000"
    },
    {
      "asset": "LTC",
      "free": "4763368.68006011",
      "locked": "0.00000000"
    }
  ]
}

GET /api/v3/account (HMAC SHA256)

获取当前账户信息。

权重: 5

参数:

名称 类型 是否必需 描述
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

账户成交历史 (USER_DATA)

响应

[
  {
    "symbol": "BNBBTC",
    "id": 28457,
    "orderId": 100234,
    "orderListId": -1, //Unless OCO, the value will always be -1
    "price": "4.00000100",
    "qty": "12.00000000",
    "quoteQty": "48.000012",
    "commission": "10.10000000",
    "commissionAsset": "BNB",
    "time": 1499865549590,
    "isBuyer": true,
    "isMaker": false,
    "isBestMatch": true
  }
]

GET /api/v3/myTrades (HMAC SHA256)

获取账户指定交易对的成交历史

权重: 5

参数:

名称 类型 是否必需 描述
symbol STRING YES
startTime LONG NO
endTime LONG NO
fromId LONG NO 起始Trade id。 默认获取最新交易。
limit INT NO 默认 500; 最大 1000.
recvWindow LONG NO 赋值不能超过 60000
timestamp LONG YES

注意:

杠杆账户和交易接口

杠杆账户划转 (MARGIN)

响应

{
    //transaction id
    "tranId": 100000001
}

Post /sapi/v1/margin/transfer 执行现货账户与杠杆账户之间的划转

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING YES 被划转的资产, 比如, BTC
amount DECIMAL YES 划转数量
type INT YES 1: 主账户向杠杆账户划转 2: 杠杆账户向主账户划转
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

杠杆账户借贷 (MARGIN)

响应

{
    //transaction id
    "tranId": 100000001
}

Post /sapi/v1/margin/loan 申请借贷。

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING YES
amount DECIMAL YES
recvWindow LONG NO 赋值不能超过 60000
timestamp LONG YES

杠杆账户归还借贷 (MARGIN)

响应

{
    //transaction id
    "tranId": 100000001
}

Post /sapi/v1/margin/repay 获取杠杆账户归还借贷。

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING YES
amount DECIMAL YES
recvWindow LONG NO 赋值不能超过 60000
timestamp LONG YES

查询杠杆资产 (MARKET_DATA)

响应

{
    "assetFullName": "Binance Coin",
    "assetName": "BNB",
    "isBorrowable": false,
    "isMortgageable": true,
    "userMinBorrow": "0.00000000",
    "userMinRepay": "0.00000000"
}

Get /sapi/v1/margin/asset

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING YES

查询杠杆交易对 (MARKET_DATA)

响应

{
   "id":323355778339572400,
   "symbol":"BTCUSDT",
   "base":"BTC",
   "quote":"USDT",
   "isMarginTrade":true,
   "isBuyAllowed":true,
   "isSellAllowed":true
}

Get /sapi/v1/margin/pair

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES

获取所有杠杆资产信息 (MARKET_DATA)

响应

  [
      {
          "assetFullName": "USD coin",
          "assetName": "USDC",
          "isBorrowable": true,
          "isMortgageable": true,
          "userMinBorrow": "0.00000000",
          "userMinRepay": "0.00000000"
      },
      {
          "assetFullName": "BNB-coin",
          "assetName": "BNB",
          "isBorrowable": true,
          "isMortgageable": true,
          "userMinBorrow": "1.00000000",
          "userMinRepay": "0.00000000"
      },
      {
          "assetFullName": "Tether",
          "assetName": "USDT",
          "isBorrowable": true,
          "isMortgageable": true,
          "userMinBorrow": "1.00000000",
          "userMinRepay": "0.00000000"
      },
      {
          "assetFullName": "etherum",
          "assetName": "ETH",
          "isBorrowable": true,
          "isMortgageable": true,
          "userMinBorrow": "0.00000000",
          "userMinRepay": "0.00000000"
      },
      {
          "assetFullName": "Bitcoin",
          "assetName": "BTC",
          "isBorrowable": true,
          "isMortgageable": true,
          "userMinBorrow": "0.00000000",
          "userMinRepay": "0.00000000"
      }
  ]

Get /sapi/v1/margin/allAssets

权重: 1

参数:
None

获取所有杠杆交易对(MARKET_DATA)

响应

[
    {
        "base": "BNB",
        "id": 351637150141315861,
        "isBuyAllowed": True,
        "isMarginTrade": True,
        "isSellAllowed": True,
        "quote": "BTC",
        "symbol": "BNBBTC"
    },
    {
        "base": "TRX",
        "id": 351637923235429141,
        "isBuyAllowed": True,
        "isMarginTrade": True,
        "isSellAllowed": True,
        "quote": "BTC",
        "symbol": "TRXBTC"
    },
    {
        "base": "XRP",
        "id": 351638112213990165,
        "isBuyAllowed": True,
        "isMarginTrade": True,
        "isSellAllowed": True,
        "quote": "BTC",
        "symbol": "XRPBTC"
    },
    {
        "base": "ETH",
        "id": 351638524530850581,
        "isBuyAllowed": True,
        "isMarginTrade": True,
        "isSellAllowed": True,
        "quote": "BTC",
        "symbol": "ETHBTC"
    },
    {
        "base": "BNB",
        "id": 376870400832855109,
        "isBuyAllowed": True,
        "isMarginTrade": True,
        "isSellAllowed": True,
        "quote": "USDT",
        "symbol": "BNBUSDT"
  }
]

Get /sapi/v1/margin/allPairs

权重: 1

参数:

None

查询杠杆价格指数 (MARKET_DATA)

响应

{
   "calcTime": 1562046418000,
   "price": "0.00333930",
   "symbol": "BNBBTC"
}

Get /sapi/v1/margin/priceIndex

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES

杠杆账户下单 (TRADE)

Response ACK:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595
}

Response RESULT:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595,
  "price": "1.00000000",
  "origQty": "10.00000000",
  "executedQty": "10.00000000",
  "cummulativeQuoteQty": "10.00000000",
  "status": "FILLED",
  "timeInForce": "GTC",
  "type": "MARKET",
  "side": "SELL"
}

Response FULL:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595,
  "price": "1.00000000",
  "origQty": "10.00000000",
  "executedQty": "10.00000000",
  "cummulativeQuoteQty": "10.00000000",
  "status": "FILLED",
  "timeInForce": "GTC",
  "type": "MARKET",
  "side": "SELL",
  "fills": [
    {
      "price": "4000.00000000",
      "qty": "1.00000000",
      "commission": "4.00000000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3999.00000000",
      "qty": "5.00000000",
      "commission": "19.99500000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3998.00000000",
      "qty": "2.00000000",
      "commission": "7.99600000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3997.00000000",
      "qty": "1.00000000",
      "commission": "3.99700000",
      "commissionAsset": "USDT"
    },
    {
      "price": "3995.00000000",
      "qty": "1.00000000",
      "commission": "3.99500000",
      "commissionAsset": "USDT"
    }
  ]
}

Post /sapi/v1/margin/order

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
side ENUM YES BUY
SELL
type ENUM YES
quantity DECIMAL YES
price DECIMAL NO
stopPrice DECIMAL NO STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, 和 TAKE_PROFIT_LIMIT 订单一起使用.
newClientOrderId STRING NO 订单唯一识别。若未发送自动生成。
icebergQty DECIMAL NO LIMIT, STOP_LOSS_LIMIT, 和 TAKE_PROFIT_LIMIT 一起使用创建 iceberg 订单.
newOrderRespType ENUM NO 设置响应: JSON. ACK, RESULT, 或 FULL; MARKET 和 LIMIT 订单类型默认为 FULL, 所有其他订单默认为 ACK.
timeInForce ENUM NO GTC,IOC,FOK
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

杠杆账户撤销订单 (TRADE)

响应

{
  "symbol": "LTCBTC",
  "orderId": 28,
  "origClientOrderId": "myOrder1",
  "clientOrderId": "cancelMyOrder1",
  "transactTime": 1507725176595,
  "price": "1.00000000",
  "origQty": "10.00000000",
  "executedQty": "8.00000000",
  "cummulativeQuoteQty": "8.00000000",
  "status": "CANCELED",
  "timeInForce": "GTC",
  "type": "LIMIT",
  "side": "SELL"
}

Delete /sapi/v1/margin/order 杠杆账户撤销有效订单。

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
orderId LONG NO
origClientOrderId STRING NO
newClientOrderId STRING NO 用于唯一识别此撤销订单,默认自动生成。
recvWindow LONG NO T赋值不能大于 60000
timestamp LONG YES

获取划转历史 (USER_DATA)

响应

{
    "rows": [
    {
        "amount: "0.10000000",
        "asset": "BNB",
        "status": "CONFIRMED",
        "timestamp": 1566898617,
        "txId": 5240372201,
        "type": "ROLL_IN"
    },
    {
        "amount": "5.00000000",
        "asset": "USDT",
        "status": "CONFIRMED",
        "timestamp": 1566888436,
        "txId": 5239810406,
        "type": "ROLL_OUT"
    },
    {
        "amount": "1.00000000",
        "asset": "EOS,
        "status": "CONFIRMED",
        "timestamp": 1566888403,
        "txId": 5239808703,
        "type": "ROLL_IN"
    }
    "total": 3
} 

Get /sapi/v1/margin/transfer

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING NO
type STRING YES 划转类型: ROLL_IN, ROLL_OUT
startTime LONG NO
endTime LONG NO
current LONG NO 当前查询页。 从 1开始。 默认:1
size LONG NO 默认:10 最大:100
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

查询借贷记录 (USER_DATA)

响应

{
  "rows": [
    {
      "asset": "BNB",
      "principal": "0.84624403",
      "timestamp": 1555056425000,
      "status": "CONFIRMED"   //one of PENDING (pending to execution), CONFIRMED (successfully loaned), FAILED (execution failed, nothing happened to your account);
    }
  ],
  "total": 1
}

Get /sapi/v1/margin/loan

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING YES
txId LONG NO tranId in POST /sapi/v1/margin/loan
startTime LONG NO
endTime LONG NO
current LONG NO 当前查询页。 开始值 1。 默认:1
size LONG NO 默认:10 最大:100
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

查询还贷记录 (USER_DATA)

响应

{
     "rows": [
         {
             "amount": "14.00000000",   //Total amount repaid
             "asset": "BNB",   
             "interest": "0.01866667",    //Interest repaid
             "principal": "13.98133333",   //Principal repaid
             "status": "CONFIRMED",   //one of PENDING (pending to execution), CONFIRMED (successfully loaned), FAILED (execution failed, nothing happened to your account)
             "timestamp": 1563438204000,
             "txId": 2970933056
         }
     ],
     "total": 1
}

Get /sapi/v1/margin/repay

权重 1

参数:

名称 类型 是否必需 描述
asset STRING YES
txId LONG NO 返回 /sapi/v1/margin/repay
startTime LONG NO
endTime LONG NO
current LONG NO 当前查询页。开始值 1. 默认:1
size LONG NO 默认:10 最大:100
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

获取利息历史 (USER_DATA)

响应

  {
      "rows": [
          {
              "asset": "BNB",
              "interest": "0.02414667",
              "interestAccuredTime": 1566813600,
              "interestRate": "0.01600000",
              "principal": "36.22000000",
              "type": "ON_BORROW"
          },
          {
              "asset": "BNB",
              "interest": "0.02019334",
              "interestAccuredTime": 1566813600,
              "interestRate": "0.01600000",
              "principal": "30.29000000",
              "type": "ON_BORROW"
          },
          {
              "asset": "BNB",
              "interest": "0.02098667",
              "interestAccuredTime": 1566813600,
              "interestRate": "0.01600000",
              "principal": "31.48000000",
              "type": "ON_BORROW"
          },
          {
              "asset": "BNB",
              "interest": "0.02483334",
              "interestAccuredTime": 1566806400,
              "interestRate": "0.01600000",
              "principal": "37.25000000",
              "type": "ON_BORROW"
          },
          {
              "asset": "BNB",
              "interest": "0.02165334",
              "interestAccuredTime": 1566806400,
              "interestRate": "0.01600000",
              "principal": "32.48000000",
              "type": "ON_BORROW"
          }
      ],
      "total": 5
  }

Get /sapi/v1/margin/interestHistory

权重: 1

参数:

名称 类型 是否必需 描述
asset STRING No
startTime LONG NO
endTime LONG NO
current LONG NO 当前查询页。 开始值 1. 默认:1
size LONG NO 默认:10 最大:100
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

获取账户强制平仓记录(USER_DATA)

响应

  {
      "rows": [
          {
              "avgPrice": "0.00388359",
              "executedQty": "31.39000000",
              "orderId": 180015097,
              "price": "0.00388110",
              "qty": "31.39000000",
              "side": "SELL",
              "symbol": "BNBBTC",
              "timeInForce": "GTC",
              "updatedTime": 1558941374745
          }
      ],
      "total": 1
  }

Get /sapi/v1/margin/forceLiquidationRec

权重: 1

参数:

名称 类型 是否必需 描述
startTime LONG NO
endTime LONG NO
current LONG NO 当前查询页。 开始值 1. 默认:1
size LONG NO 默认:10 最大:100
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

查询杠杆账户详情 (USER_DATA)

响应

{
      "borrowEnabled": true,
      "marginLevel": "11.64405625",
      "totalAssetOfBtc": "6.82728457",
      "totalLiabilityOfBtc": "0.58633215",
      "totalNetAssetOfBtc": "6.24095242",
      "tradeEnabled": true,
      "transferEnabled": true,
      "userAssets": [
          {
              "asset": "BTC",
              "borrowed": "0.00000000",
              "free": "0.00499500",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00499500"
          },
          {
              "asset": "BNB",
              "borrowed": "201.66666672",
              "free": "2346.50000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "2144.83333328"
          },
          {
              "asset": "ETH",
              "borrowed": "0.00000000",
              "free": "0.00000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00000000"
          },
          {
              "asset": "USDT",
              "borrowed": "0.00000000",
              "free": "0.00000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00000000"
          }
      ]
}

Get /sapi/v1/margin/account

权重: 1

参数:

名称 类型 是否必需 描述
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

查询杠杆账户订单 (USER_DATA)

响应

{
   "clientOrderId": "ZwfQzuDIGpceVhKW5DvCmO",
   "cummulativeQuoteQty": "0.00000000",
   "executedQty": "0.00000000",
   "icebergQty": "0.00000000",
   "isWorking": true,
   "orderId": 213205622,
   "origQty": "0.30000000",
   "price": "0.00493630",
   "side": "SELL",
   "status": "NEW",
   "stopPrice": "0.00000000",
   "symbol": "BNBBTC",
   "time": 1562133008725,
   "timeInForce": "GTC",
   "type": "LIMIT",
   "updateTime": 1562133008725
}

Get /sapi/v1/margin/order

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
orderId STRING NO
origClientOrderId STRING NO
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

查询杠杆账户挂单记录 (USER_DATA)

响应

[
   {
       "clientOrderId": "qhcZw71gAkCCTv0t0k8LUK",
       "cummulativeQuoteQty": "0.00000000",
       "executedQty": "0.00000000",
       "icebergQty": "0.00000000",
       "isWorking": true,
       "orderId": 211842552,
       "origQty": "0.30000000",
       "price": "0.00475010",
       "side": "SELL",
       "status": "NEW",
       "stopPrice": "0.00000000",
       "symbol": "BNBBTC",
       "time": 1562040170089,
       "timeInForce": "GTC",
       "type": "LIMIT",
       "updateTime": 1562040170089
    }
]

Get /sapi/v1/margin/openOrders

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING NO
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

查询杠杆账户的所有订单 (USER_DATA)

响应

[
      {
          "clientOrderId": "D2KDy4DIeS56PvkM13f8cP",
          "cummulativeQuoteQty": "0.00000000",
          "executedQty": "0.00000000",
          "icebergQty": "0.00000000",
          "isWorking": false,
          "orderId": 41295,
          "origQty": "5.31000000",
          "price": "0.22500000",
          "side": "SELL",
          "status": "CANCELED",
          "stopPrice": "0.18000000",
          "symbol": "BNBBTC",
          "time": 1565769338806,
          "timeInForce": "GTC",
          "type": "TAKE_PROFIT_LIMIT",
          "updateTime": 1565769342148
      },
      {
          "clientOrderId": "gXYtqhcEAs2Rn9SUD9nRKx",
          "cummulativeQuoteQty": "0.00000000",
          "executedQty": "0.00000000",
          "icebergQty": "1.00000000",
          "isWorking": true,
          "orderId": 41296,
          "origQty": "6.65000000",
          "price": "0.18000000",
          "side": "SELL",
          "status": "CANCELED",
          "stopPrice": "0.00000000",
          "symbol": "BNBBTC",
          "time": 1565769348687,
          "timeInForce": "GTC",
          "type": "LIMIT",
          "updateTime": 1565769352226
      },
      {
          "clientOrderId": "duDq1BqohhcMmdMs9FSuDy",
          "cummulativeQuoteQty": "0.39450000",
          "executedQty": "2.63000000",
          "icebergQty": "0.00000000",
          "isWorking": true,
          "orderId": 41297,
          "origQty": "2.63000000",
          "price": "0.00000000",
          "side": "SELL",
          "status": "FILLED",
          "stopPrice": "0.00000000",
          "symbol": "BNBBTC",
          "time": 1565769358139,
          "timeInForce": "GTC",
          "type": "MARKET",
          "updateTime": 1565769358139
      }

]

Get /sapi/v1/margin/allOrders

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
orderId LONG NO
startTime LONG NO
endTime LONG NO
limit INT NO 默认 500;最大 1000.
recvWindow LONG NO 赋值不能大于 60000
timestamp LONG YES

查询杠杆账户交易历史 (USER_DATA)

响应

[
    {
        "commission": "0.00006000",
        "commissionAsset": "BTC",
        "id": 34,
        "isBestMatch": true,
        "isBuyer": false,
        "isMaker": false,
        "orderId": 39324,
        "price": "0.02000000",
        "qty": "3.00000000",
        "symbol": "BNBBTC",
        "time": 1561973357171
    },
    {
        "commission": "0.00002950",
        "commissionAsset": "BTC",
        "id": 32,
        "isBestMatch": true,
        "isBuyer": false,
        "isMaker": true,
        "orderId": 39319,
        "price": "0.00590000",
        "qty": "5.00000000",
        "symbol": "BNBBTC",
        "time": 1561964645345
    }
]

Get /sapi/v1/margin/myTrades

权重: 1

参数:

名称 类型 是否必需 描述
symbol STRING YES
startTime LONG NO
endTime LONG NO
fromId LONG NO 获取TradeId,默认获取近期交易历史。
limit INT NO 默认 500; 最大 1000.
recvWindow LONG NO 默认值不能大于 60000
timestamp LONG YES

查询账户最大可借贷额(USER_DATA)

响应

{
    "amount": "1.69248805"
}

Get /sapi/v1/margin/maxBorrowable

权重: 5

参数:

名称 类型 是否必需 描述
asset STRING YES
recvWindow LONG NO 默认值不能大于 60000
timestamp LONG YES

查询最大可转出额 (USER_DATA)

响应

 {
      "amount": "3.59498107"
 }

Get /sapi/v1/margin/maxTransferable

权重: 5

参数:

名称 类型 是否必需 描述
asset STRING YES
recvWindow LONG NO 默认值不能大于 60000
timestamp LONG YES

Websocket账户信息推送

Listen Key(现货账户)

生成 Listen Key

响应

{
  "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}

POST /api/v3/userDataStream

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

参数:

NONE

延长 Listen Key 有效期

响应

{}

PUT /api/v3/userDataStream

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

权重: 1

参数:

名称 类型 是否必需 描述
listenKey STRING YES

关闭 Listen Key

响应

{}

DELETE /api/v3/userDataStream

关闭用户数据流。

权重: 1

参数:

名称 类型 是否必需 描述
listenKey STRING YES

Listen Key(杠杆账户)

生成 Listen Key

响应

{"listenKey":  "T3ee22BIYuWqmvne0HNq2A2WsFlEtLhvWCtItw6ffhhdmjifQ2tRbuKkTHhr"}

POST /sapi/v1/userDataStream

权重: 1

参数:

NONE

延长 Lisen Key 有效期

响应

{}

PUT /sapi/v1/userDataStream

权重: 1

参数:

名称 类型 是否必需 描述
listenKey STRING YES

关闭 ListenKey

响应

{}

DELETE /sapi/v1/userDataStream

权重: 1

参数:

名称 类型 是否必需 描述
listenKey STRING YES

Payload: 账户更新

使用 outboundAccountInfo event进行账户更新。

Payload

{
  "e": "outboundAccountInfo",   // 事件类型
  "E": 1499405658849,           // 事件时间
  "m": 0,                       // 挂单费率 (基点)
  "t": 0,                       // 吃单费率 (基点)
  "b": 0,                       // 买单费率(基点)
  "s": 0,                       // 卖单费率(基点)
  "T": true,                    // 是否允许交易
  "W": true,                    // 是否允许提现
  "D": true,                    // 是否允许充值
  "u": 1499405658848,           // 账户末次更新时间戳
  "B": [                        // 余额
    {
      "a": "LTC",               // 资产名称
      "f": "17366.18538083",    // 可用余额
      "l": "0.00000000"         // 冻结余额
    },
    {
      "a": "BTC",
      "f": "10537.85314051",
      "l": "2.19464093"
    },
    {
      "a": "ETH",
      "f": "17902.35190619",
      "l": "0.00000000"
    },
    {
      "a": "BNC",
      "f": "1114503.29769312",
      "l": "0.00000000"
    },
    {
      "a": "NEO",
      "f": "0.00000000",
      "l": "0.00000000"
    }
  ]
}

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

Payload

{
  "e": "outboundAccountPosition", // 事件类型
  "E": 1564034571105,             // 事件时间
  "u": 1564034571073,             // 账户末次更新时间戳
  "B": [                          // 余额
    {
      "a": "ETH",                 // 资产名称
      "f": "10000.000000",        // 可用余额
      "l": "0.000000"             // 冻结余额
    }
  ]
}

Payload: 余额更新

Payload

{
  "e": "balanceUpdate",         //Event Type
  "E": 1573200697110,           //Event Time
  "a": "ABC",                   //Asset
  "d": "100.00000000",          //Balance Delta
  "T": 1573200697068            //Clear Time
}

当下列情形发生时更新:

Payload: 订单更新

订单通过executionReport事件进行更新。 请查阅API文档以及以下文档,以获取相关的枚举定义。 通过将Z除以z可以找到平均价格。

Payload

{
  "e": "executionReport",        // 事件类型
  "E": 1499405658658,            // 事件时间
  "s": "ETHBTC",                 // 交易对
  "c": "mUvoqJxFIILMdfAW5iGSOW", // clientOrderId
  "S": "BUY",                    // 订单方向
  "o": "LIMIT",                  // 订单类型
  "f": "GTC",                    // Time in force
  "q": "1.00000000",             // 订单原始数量
  "p": "0.10264410",             // 订单原始价格
  "P": "0.00000000",             // 止盈止损单触发价格
  "F": "0.00000000",             // 冰山订单数量
  "g": -1,                       // OCO订单 OrderListId
  "C": null,                     // 原始订单自定义ID(原始订单,指撤单操作的对象。撤单本身被视为另一个订单)
  "x": "NEW",                    // 本次事件的具体执行类型
  "X": "NEW",                    // 订单的当前状态
  "r": "NONE",                   // 订单被拒绝的原因
  "i": 4293153,                  // orderId
  "l": "0.00000000",             // 订单末次成交数量
  "z": "0.00000000",             // 订单累计已成交数量
  "L": "0.00000000",             // 订单末次成交价格
  "n": "0",                      // 手续费数量
  "N": null,                     // 手续费资产类别
  "T": 1499405658657,            // 成交时间
  "t": -1,                       // 成交ID
  "I": 8641984,                  // 请忽略
  "w": true,                     // 订单是否仍然有效(对止盈/止损生效)
  "m": false,                    // 该成交是作为挂单成交吗?
  "M": false,                    // 请忽略
  "O": 1499405658657,            // 订单创建时间
  "Z": "0.00000000",             // 订单累计已成交金额
  "Y": "0.00000000"              // 订单末次成交金额
}

执行类型:

如果订单是OCO,则除了显示“ executionReport”事件外,还将显示一个名为“ ListStatus”的事件。

Payload

{
  "e": "listStatus",                // 事件类型
  "E": 1564035303637,               // 事件时间
  "s": "ETHBTC",                    // 交易对
  "g": 2,                           // OrderListId
  "c": "OCO",                       // Contingency Type
  "l": "EXEC_STARTED",              // List Status Type
  "L": "EXECUTING",                 // List Order Status
  "r": "NONE",                      // List 被拒绝的原因
  "C": "F4QN4G8DlFATFlIUQ0cjdD",    // List Client Order ID
  "T": 1564035303625,               // 成交时间
  "O": [                           
    {
      "s": "ETHBTC",                // 交易对
      "i": 17,                      // orderId
      "c": "AJYsMjErWJesZvqlJCTUgL" // clientOrderId
    },
    {
      "s": "ETHBTC",
      "i": 18,
      "c": "bfYPSQdLoqAJeNrOr9adzq"
    }
  ]
}

错误代码

错误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

-1099 Not found, authenticated, or authorized

11xx - 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

-1131 BAD_RECV_WINDOW

-2010 NEW_ORDER_REJECTED

-2011 CANCEL_REJECTED

-2013 NO_SUCH_ORDER

-2014 BAD_API_KEY_FMT

-2015 REJECTED_MBX_KEY

-2016 NO_TRADING_WINDOW

Messages for -1010 ERROR_MSG_RECEIVED, -2010 NEW_ORDER_REJECTED, and -2011 CANCEL_REJECTED

匹配引擎返回错误后,将发送此代码。 以下消息将指示特定的错误:

Error message Description
"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 origClientOrderId and orderId." 未发送origClientOrderIdorderId
"Order would immediately match and take." LIMIT_MAKER 订单类型将立即匹配并进行交易,而不是纯粹的生成订单。
"The relationship of the prices for the orders is not correct." OCO订单中设置的价格不符合报价规则:
The rules are:
SELL Orders: Limit Price > Last Price > Stop Price
BUY Orders: Limit Price < Last Price < Stop Price
"OCO orders are not supported for this symbol" OCO订单不支持该交易对

-9xxx 过滤器故障

报错信息 描述
"Filter failure: PRICE_FILTER" “价格”过高,过低和/或不遵循交易对的最小价格规则。
"Filter failure: PERCENT_PRICE" “价格”比最近Y分钟的平均加权价格高X%或X%太低。
"Filter failure: LOT_SIZE" “数量”太高,太低和/或不遵循该交易对的步长规则。
"Filter failure: MIN_NOTIONAL" 价格*数量太低,无法成为该交易对的有效订单。
"Filter failure: ICEBERG_PARTS" ICEBERG 订单会分成太多部分; icebergQty太小。
"Filter failure: MARKET_LOT_SIZE" “ MARKET”订单的“数量”过高,过低和/或未遵循交易对的步长规则。
"Filter failure: MAX_NUM_ORDERS" 客户在交易对上有太多挂单。
"Filter failure: MAX_ALGO_ORDERS" 账户有太多未平仓止损和/或在交易对上执行获利指令。
"Filter failure: MAX_NUM_ICEBERG_ORDERS" 客户在交易对上有太多 iceberg 挂单。
"Filter failure: EXCHANGE_MAX_NUM_ORDERS" 帐户上的交易所有太多挂单。
"Filter failure: EXCHANGE_MAX_ALGO_ORDERS" 帐户有太多止损挂单和/或在交易所收取获利指令。