Skip to content

Commit e7d0cc7

Browse files
committed
first commit, add API documents
0 parents  commit e7d0cc7

16 files changed

+7968
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.swp

CHANGELOG.md

+362
Large diffs are not rendered by default.

CHANGELOG_CN.md

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# 更新日志 (2020-11-27)
2+
3+
## 2020-11-27
4+
5+
为了优化性能,除了当前的`api.binance.com`,新加了一些API的集群。如果访问`api.binance.com`有性能问题,也可以尝试访问:
6+
7+
* https://api1.binance.com/api/v3/*
8+
* https://api2.binance.com/api/v3/*
9+
* https://api3.binance.com/api/v3/*
10+
11+
## 2020-09-09
12+
13+
用户数据 STREAM
14+
15+
* `outboundAccountInfo`事件不再推荐使用。
16+
* `outboundAccountInfo`事件以后会被删除(具体时间未定) **请使用 `outboundAccountPosition` 事件.**
17+
* `outboundAccountInfo`只推送余额不为0,以及余额刚变成0的资产。
18+
19+
---
20+
21+
## 2020-05-01
22+
* 从2020-05-01 UTC 00:00开始, 所有交易对都会有最多200个挂单的限制, 体现在过滤器[MAX_NUM_ORDERS](https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api_CN.md#max_num_orders-%E6%9C%80%E5%A4%9A%E8%AE%A2%E5%8D%95%E6%95%B0)上.
23+
* 已经存在的挂单不会被移除或者撤销。
24+
* 单交易对(`symbol`)的挂单数量达到或超过200的账号, 无法在此交易对上下新的订单, 除非挂单数量低于200。
25+
* OCO订单在被触发成`LIMIT`订单, 或者被触发成`STOP_LOSS`(或者`STOP_LOSS_LIMIT`)前, 被认为是2个挂单量. 一旦OCO订单被触发, 就只被算作一个挂单。
26+
27+
---
28+
29+
## 2020-04-23
30+
31+
WEB SOCKET 连接限制
32+
33+
* Websocket服务器每秒最多接受5个消息。消息包括:
34+
* PING帧
35+
* PONG帧
36+
* JSON格式的消息, 比如订阅, 断开订阅.
37+
* 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽。
38+
* 单个连接最多可以订阅 **1024** 个Streams。
39+
40+
---
41+
## 2020-03-24
42+
43+
* 添加过滤器 `MAX_POSITION`.
44+
* 这个过滤器定义账户允许的基于`base asset`的最大仓位。一个用户的仓位可以定义为如下资产的总和:
45+
* `base asset`的可用余额
46+
* `base asset`的锁定余额
47+
* 所有处于open的买单的数量总和
48+
49+
* 如果用户的仓位大于最大的允许仓位,买单会被拒绝。
50+
51+
---
52+
53+
## 2018-11-13
54+
### Rest API
55+
* 账户交易权限被禁时允许进行撤单操作。
56+
* 增加了新的过滤器: `PERCENT_PRICE`, `MARKET_LOT_SIZE`, `MAX_NUM_ICEBERG_ORDERS`
57+
* 增加了 `RAW_REQUST` 频率限制. 该限制仅统计请求次数,不统计请求权重。
58+
* /api/v3/ticker/price 无symbol参数时,权重增加到2。
59+
* /api/v3/ticker/bookTicker 无symbol参数时,权重增加到2。
60+
* DELETE /api/v3/order 现在会返回订单撤销前所处的末次状态。
61+
* `MIN_NOTIONAL` 新增两个参数: `applyToMarket` (是否对市价单生效) and `avgPriceMins` (对市价单生效时,估算金额时使用过去几分钟的平均价格?).
62+
* /api/v1/exchangeInfo 中的限制增加了`intervalNum`. `intervalNum`表示该限制针对多少时间间隔进行统计. 例如: `intervalNum`= 5, `interval` = minute, 表示该限制对每5分钟内的行为进行统计。
63+
64+
#### 如何计算过去n分钟平均价格:
65+
1. [对过去n分钟所有订单的数量\*价格求和] / 过去n分钟订单数
66+
2. 如果过去n分钟没有交易发生,则继续向前追溯,直到找到第一个交易,以此价格作为过去n分钟平均价格。
67+
3. 如果该交易对之前从未发生过交易,则无平均价格,亦即无法在该交易对下市价单,必须至少有一个(双方均未限价单)的交易成交后才可以下市价单。
68+
4. 当前系统使用的平均价格可以通过接口 `https://api.binance.com/api/v3/avgPrice?symbol=<symbol>`查询
69+
例如
70+
https://api.binance.com/api/v3/avgPrice?symbol=BNBUSDT
71+
72+
### User data stream
73+
* 成交报告中增加了 `末次成交金额` (`Y`),等于 `末次成交量` * `末次成交价格` (`L` * `l`).
74+
75+
## 2018-07-18
76+
### Rest API
77+
* 新过滤器: `ICEBERG_PARTS`
78+
* `POST api/v3/order``newOrderRespType` 参数的缺省值更改; `MARKET` `LIMIT` 默认为 `FULL`, 其他默认为 `ACK`.
79+
* POST api/v3/order `RESULT``FULL` 响应中增加 `cummulativeQuoteQty`
80+
* GET api/v3/openOrders 无symbol调用权重下降为 40.
81+
* GET api/v3/ticker/24hr 无symbol调用权重下降为 40.
82+
* GET /api/v1/trades amount最大可取到1000.
83+
* GET /api/v1/historicalTrades amount最大可取到1000.
84+
* GET /api/v1/aggTrades amount最大可取到1000.
85+
* GET /api/v1/klines amount最大可取到1000.
86+
* 订单查询结果返回中增加 `updateTime` 字段,代表该订单末次更新(创建、成交、过期、取消、拒绝等等)时间; `time` 仅表示创建时间.
87+
* 订单查询结果中增加 `cummulativeQuoteQty`字段. 负值表示尚无任何成交,该字段不可用.
88+
* `REQUESTS` 限制更名为 `REQUEST_WEIGHT`. 避免名字造成的误解。
89+
90+
### User data stream
91+
* 订单报告与成交报告中增加`cummulativeQuoteQty` 字段 (`Z`). 表示已经成交的金额, 即已经花费的金额(买入订单)或已经收到的金额(卖出订单),均未计算手续费. 此功能增加之前成交的订单在历史订单接口中查询到的该字段可能小于零.
92+
* `cummulativeQuoteQty`/`cummulativeQty` 可以用来计算该订单已经成交部分的平均价格。
93+
* 成交报告中增加了 `O`字段 (订单创建时间)
94+
95+
96+
## 2018-01-23
97+
* GET /api/v1/historicalTrades权重降为 5
98+
* GET /api/v1/aggTrades 权重降为 1
99+
* GET /api/v1/klines 权重降为 1
100+
* GET /api/v1/ticker/24hr 不带symbol参数的权重降为 symbols总数 / 2
101+
* GET /api/v3/allOrders 权重降为 5
102+
* GET /api/v3/myTrades 权重降为 5
103+
* GET /api/v3/account 权重降为 5
104+
* GET /api/v1/depth limit=500 权重降为 5
105+
* GET /api/v1/depth limit=1000 权重降为 10
106+
* websocket 用户增加 -1003 error code
107+
108+
## 2018-01-20
109+
* GET /api/v1/ticker/24hr 单symbol参数调用权重降为 1
110+
* GET /api/v3/openOrders 不带symbol参数的权重降为 symbols总数 / 2
111+
* GET /api/v3/allOrders 权重降为 15
112+
* GET /api/v3/myTrades 权重降为 15
113+
* GET /api/v3/order 权重降为 1
114+
* 自成交现在会在myTrades结果中有两条记录。
115+
116+
## 2018-01-14
117+
* GET /api/v1/aggTrades 权重改为 2
118+
* GET /api/v1/klines 权重改为 2
119+
* GET /api/v3/order 权重改为 2
120+
* GET /api/v3/allOrders 权重改为 20
121+
* GET /api/v3/account 权重改为 20
122+
* GET /api/v3/myTrades 权重改为 20
123+
* GET /api/v3/historicalTrades 权重改为 20

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Official Documentation for the Binance APIs and Streams.
2+
* Official Announcements regarding changes, downtime, etc. to the API and Streams will be reported here: **https://t.me/binance_api_announcements**
3+
* Streams, endpoints, parameters, payloads, etc. described in the documents in this repository are considered **official** and **supported**.
4+
* The use of any other streams, endpoints, parameters, or payloads, etc. is **not supported**; **use them at your own risk and with no guarantees.**
5+
6+
7+
Name | Description
8+
------------ | ------------
9+
[rest-api.md](./rest-api.md) | Details on the Rest API (/api)
10+
[errors.md](./errors.md) | Descriptions of possible error messages from the Rest API
11+
[web-socket-streams.md](./web-socket-streams.md) | Details on available streams and payloads
12+
[user-data-stream.md](./user-data-stream.md) | Details on the dedicated account stream
13+
[wapi-api.md](./wapi-api.md) | Details on the Withdrawal API (/wapi)
14+
[margin-api.md](./margin-api.md) | Details on the Margin Trade API (/sapi)
15+
[Futures-API](https://binance-docs.github.io/apidocs/futures/en/) | Details on the Futures API (/fapi)
16+

README_CN.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 关于本中文翻译版
2+
* 中文文档由英文文档翻译而来,当中文文档内容与英文文档冲突时,以英文文档为准
3+
# 币安API文档
4+
* 币安API英文Telegram群 **https://t.me/binance_api_english**
5+
* 币安API中文Telegram群 **https://t.me/binance_api_chinese**
6+
* 所有于本文档内给出定义的包括但不限于接口、数据流、参数、响应等,可认为是币安官方提供的内容。
7+
* 而所有未于本文档内给出的内容,币安均不承诺提供任何支持。
8+
9+
文档名 | 描述
10+
------------ | ------------
11+
[rest-api_CN.md](./rest-api_CN.md) | 通用Rest接口定义 (/api)
12+
[errors_CN.md](./errors_CN.md) | 错误代码及含义
13+
[web-socket-streams_CN.md](./web-socket-streams_CN.md) | 行情数据流接口的描述
14+
[user-data-stream_CN.md](./user-data-stream_CN.md) | 用户数据流接口的描述
15+
[wapi-api_CN.md](./wapi-api_CN.md) | 提现接口(及其他账户信息)的描述(/wapi)
16+
[Futures-API](https://binance-docs.github.io/apidocs/futures/cn/) | 币安合约API中文文档 (/fapi)

errors.md

+191
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# Error codes for Binance (2019-09-25)
2+
Errors consist of two parts: an error code and a message. Codes are universal,
3+
but messages can vary. Here is the error JSON payload:
4+
```javascript
5+
{
6+
"code":-1121,
7+
"msg":"Invalid symbol."
8+
}
9+
```
10+
11+
12+
## 10xx - General Server or Network issues
13+
#### -1000 UNKNOWN
14+
* An unknown error occured while processing the request.
15+
16+
#### -1001 DISCONNECTED
17+
* Internal error; unable to process your request. Please try again.
18+
19+
#### -1002 UNAUTHORIZED
20+
* You are not authorized to execute this request.
21+
22+
#### -1003 TOO_MANY_REQUESTS
23+
* Too many requests queued.
24+
* Too much request weight used; please use the websocket for live updates to avoid polling the API.
25+
* Too much request weight used; current limit is %s request weight per %s %s. Please use the websocket for live updates to avoid polling the API.
26+
* Way too much request weight used; IP banned until %s. Please use the websocket for live updates to avoid bans.
27+
28+
#### -1006 UNEXPECTED_RESP
29+
* An unexpected response was received from the message bus. Execution status unknown.
30+
31+
#### -1007 TIMEOUT
32+
* Timeout waiting for response from backend server. Send status unknown; execution status unknown.
33+
34+
#### -1014 UNKNOWN_ORDER_COMPOSITION
35+
* Unsupported order combination.
36+
37+
#### -1015 TOO_MANY_ORDERS
38+
* Too many new orders.
39+
* Too many new orders; current limit is %s orders per %s.
40+
41+
#### -1016 SERVICE_SHUTTING_DOWN
42+
* This service is no longer available.
43+
44+
#### -1020 UNSUPPORTED_OPERATION
45+
* This operation is not supported.
46+
47+
#### -1021 INVALID_TIMESTAMP
48+
* Timestamp for this request is outside of the recvWindow.
49+
* Timestamp for this request was 1000ms ahead of the server's time.
50+
51+
#### -1022 INVALID_SIGNATURE
52+
* Signature for this request is not valid.
53+
54+
55+
## 11xx - Request issues
56+
#### -1100 ILLEGAL_CHARS
57+
* Illegal characters found in a parameter.
58+
* Illegal characters found in parameter '%s'; legal range is '%s'.
59+
60+
#### -1101 TOO_MANY_PARAMETERS
61+
* Too many parameters sent for this endpoint.
62+
* Too many parameters; expected '%s' and received '%s'.
63+
* Duplicate values for a parameter detected.
64+
65+
#### -1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED
66+
* A mandatory parameter was not sent, was empty/null, or malformed.
67+
* Mandatory parameter '%s' was not sent, was empty/null, or malformed.
68+
* Param '%s' or '%s' must be sent, but both were empty/null!
69+
70+
#### -1103 UNKNOWN_PARAM
71+
* An unknown parameter was sent.
72+
73+
#### -1104 UNREAD_PARAMETERS
74+
* Not all sent parameters were read.
75+
* Not all sent parameters were read; read '%s' parameter(s) but was sent '%s'.
76+
77+
#### -1105 PARAM_EMPTY
78+
* A parameter was empty.
79+
* Parameter '%s' was empty.
80+
81+
#### -1106 PARAM_NOT_REQUIRED
82+
* A parameter was sent when not required.
83+
* Parameter '%s' sent when not required.
84+
85+
#### -1111 BAD_PRECISION
86+
* Precision is over the maximum defined for this asset.
87+
88+
#### -1112 NO_DEPTH
89+
* No orders on book for symbol.
90+
91+
#### -1114 TIF_NOT_REQUIRED
92+
* TimeInForce parameter sent when not required.
93+
94+
#### -1115 INVALID_TIF
95+
* Invalid timeInForce.
96+
97+
#### -1116 INVALID_ORDER_TYPE
98+
* Invalid orderType.
99+
100+
#### -1117 INVALID_SIDE
101+
* Invalid side.
102+
103+
#### -1118 EMPTY_NEW_CL_ORD_ID
104+
* New client order ID was empty.
105+
106+
#### -1119 EMPTY_ORG_CL_ORD_ID
107+
* Original client order ID was empty.
108+
109+
#### -1120 BAD_INTERVAL
110+
* Invalid interval.
111+
112+
#### -1121 BAD_SYMBOL
113+
* Invalid symbol.
114+
115+
#### -1125 INVALID_LISTEN_KEY
116+
* This listenKey does not exist.
117+
118+
#### -1127 MORE_THAN_XX_HOURS
119+
* Lookup interval is too big.
120+
* More than %s hours between startTime and endTime.
121+
122+
#### -1128 OPTIONAL_PARAMS_BAD_COMBO
123+
* Combination of optional parameters invalid.
124+
125+
#### -1130 INVALID_PARAMETER
126+
* Invalid data sent for a parameter.
127+
* Data sent for paramter '%s' is not valid.
128+
129+
#### -2010 NEW_ORDER_REJECTED
130+
* NEW_ORDER_REJECTED
131+
132+
#### -2011 CANCEL_REJECTED
133+
* CANCEL_REJECTED
134+
135+
#### -2013 NO_SUCH_ORDER
136+
* Order does not exist.
137+
138+
#### -2014 BAD_API_KEY_FMT
139+
* API-key format invalid.
140+
141+
#### -2015 REJECTED_MBX_KEY
142+
* Invalid API-key, IP, or permissions for action.
143+
144+
#### -2016 NO_TRADING_WINDOW
145+
* No trading window could be found for the symbol. Try ticker/24hrs instead.
146+
147+
148+
## Messages for -1010 ERROR_MSG_RECEIVED, -2010 NEW_ORDER_REJECTED, and -2011 CANCEL_REJECTED
149+
This code is sent when an error has been returned by the matching engine.
150+
The following messages which will indicate the specific error:
151+
152+
153+
Error message | Description
154+
------------ | ------------
155+
"Unknown order sent." | The order (by either `orderId`, `clOrdId`, `origClOrdId`) could not be found
156+
"Duplicate order sent." | The `clOrdId` is already in use
157+
"Market is closed." | The symbol is not trading
158+
"Account has insufficient balance for requested action." | Not enough funds to complete the action
159+
"Market orders are not supported for this symbol." | `MARKET` is not enabled on the symbol
160+
"Iceberg orders are not supported for this symbol." | `icebergQty` is not enabled on the symbol
161+
"Stop loss orders are not supported for this symbol." | `STOP_LOSS` is not enabled on the symbol
162+
"Stop loss limit orders are not supported for this symbol." | `STOP_LOSS_LIMIT` is not enabled on the symbol
163+
"Take profit orders are not supported for this symbol." | `TAKE_PROFIT` is not enabled on the symbol
164+
"Take profit limit orders are not supported for this symbol." | `TAKE_PROFIT_LIMIT` is not enabled on the symbol
165+
"Price * QTY is zero or less." | `price` * `quantity` is too low
166+
"IcebergQty exceeds QTY." | `icebergQty` must be less than the order quantity
167+
"This action disabled is on this account." | Contact customer support; some actions have been disabled on the account.
168+
"Unsupported order combination" | The `orderType`, `timeInForce`, `stopPrice`, and/or `icebergQty` combination isn't allowed.
169+
"Order would trigger immediately." | The order's stop price is not valid when compared to the last traded price.
170+
"Cancel order is invalid. Check origClOrdId and orderId." | No `origClOrdId` or `orderId` was sent in.
171+
"Order would immediately match and take." | `LIMIT_MAKER` order type would immediately match and trade, and not be a pure maker order.
172+
"The relationship of the prices for the orders is not correct." | The prices set in the `OCO` is breaking the Price rules. <br> The rules are: <br> `SELL Orders`: Limit Price > Last Price > Stop Price <br>`BUY Orders`: Limit Price < Last Price < Stop Price
173+
"OCO orders are not supported for this symbol" | `OCO` is not enabled on the symbol
174+
"Quote order qty market orders are not support for this symbol."| `MARKET` orders using the parameter `quoteOrderQty` are not enabled on the symbol.
175+
176+
## -9xxx Filter failures
177+
Error message | Description
178+
------------ | ------------
179+
"Filter failure: PRICE_FILTER" | `price` is too high, too low, and/or not following the tick size rule for the symbol.
180+
"Filter failure: PERCENT_PRICE" | `price` is X% too high or X% too low from the average weighted price over the last Y minutes.
181+
"Filter failure: LOT_SIZE" | `quantity` is too high, too low, and/or not following the step size rule for the symbol.
182+
"Filter failure: MIN_NOTIONAL" | `price` * `quantity` is too low to be a valid order for the symbol.
183+
"Filter failure: ICEBERG_PARTS" | `ICEBERG` order would break into too many parts; icebergQty is too small.
184+
"Filter failure: MARKET_LOT_SIZE" | `MARKET` order's `quantity` is too high, too low, and/or not following the step size rule for the symbol.
185+
"Filter failure: MAX_POSITION" | The account's position has reached the maximum defined limit. <br> This is composed of the sum of the balance of the base asset, and the sum of the quantity of all open `BUY` orders.
186+
"Filter failure: MAX_NUM_ORDERS" | Account has too many open orders on the symbol.
187+
"Filter failure: MAX_ALGO_ORDERS" | Account has too many open stop loss and/or take profit orders on the symbol.
188+
"Filter failure: MAX_NUM_ICEBERG_ORDERS" | Account has too many open iceberg orders on the symbol.
189+
"Filter failure: EXCHANGE_MAX_NUM_ORDERS" | Account has too many open orders on the exchange.
190+
"Filter failure: EXCHANGE_MAX_ALGO_ORDERS" | Account has too many open stop loss and/or take profit orders on the exchange.
191+

0 commit comments

Comments
 (0)