- The base endpoint is: https://api.binance.com
- All endpoints return either a JSON object or array.
- Data is returned in ascending order. Oldest first, newest last.
- All time and timestamp related fields are in milliseconds.
- HTTP
4XXreturn codes are used for for malformed requests; the issue is on the sender's side. - HTTP
429return code is used when breaking a request rate limit. - HTTP
418return code is used when an IP has been auto-banned for continuing to send requests after receiving429codes. - HTTP
5XXreturn codes are used for internal errors; the issue is on Binance's side. - HTTP
504return code is used when the API successfully sent the message but not get a response within the timeout period. It is important to NOT treat this as a failure; the execution status is UNKNOWN and could have been a success. - Any endpoint can retun an ERROR; the error payload is as follows:
{
"success": false,
"msg": "Invalid symbol."
}- Specific error codes and messages defined in another document.
- For
GETendpoints, parameters must be sent as aquery string. - For
POST,PUT, andDELETEendpoints, the parameters may be sent as aquery stringor in therequest bodywith content typeapplication/x-www-form-urlencoded. You may mix parameters between both thequery stringandrequest bodyif you wish to do so. - Parameters may be sent in any order.
- If a parameter sent in both the
query stringandrequest body, thequery stringparameter will be used.
- The
/wapi/v3rateLimitsarray contains objects related to the exchange'sREQUESTSandORDERrate limits. - A 429 will be returned when either rather limit is violated.
- Each route has a
weightwhich determines for the number of requests each endpoint counts for. Heavier endpoints and endpoints that do operations on multiple symbols will have a heavierweight. - When a 429 is recieved, it's your obligation as an API to back off and not spam the API.
- Repeatedly violating rate limits and/or failing to back off after receiving 429s will result in an automated IP ban (http status 418).
- IP bans are tracked and scale in duration for repeat offenders, from 2 minutes to 3 days.
- Each endpoint has a security type that determines the how you will interact with it.
- API-keys are passed into the Rest API via the
X-MBX-APIKEYheader. - API-keys and secret-keys are case sensitive.
- API-keys can be configured to only access certain types of secure endpoints. For example, one API-key could be used for TRADE only, while another API-key can access everything except for TRADE routes.
- By default, API-keys can access all secure routes.
| Security Type | Description |
|---|---|
| NONE | Endpoint can be accessed freely. |
| TRADE | Endpoint requires sending a valid API-Key and signature. |
| USER_DATA | Endpoint requires sending a valid API-Key and signature. |
| USER_STREAM | Endpoint requires sending a valid API-Key. |
| MARKET_DATA | Endpoint requires sending a valid API-Key. |
TRADEandUSER_DATAendpoints areSIGNEDendpoints.
SIGNEDendpoints require an additional parameter,signature, to be sent in thequery stringorrequest body.- Endpoints use
HMAC SHA256signatures. TheHMAC SHA256 signatureis a keyedHMAC SHA256operation. Use yoursecretKeyas the key andtotalParamsas the value for the HMAC operation. - The
signatureis not case sensitive. totalParamsis defined as thequery stringconcatenated with therequest body.
- A
SIGNEDendpoint also requires a parameter,timestamp, to be sent which should be the millisecond timestamp of when the request was created and sent. - An additional parameter,
recvWindow, may be sent to specific the number of milliseconds aftertimestampthe request is valid for. IfrecvWindowis not sent, it defaults to 5000. - The logic is as follows:
if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow) { // process request } else { // reject request }
Serious trading is about timing. Networks can be unstable and unreliable,
which can lead to requests taking varying amounts of time to reach the
servers. With recvWindow, you can specify that the request must be
processed within a certain number of milliseconds or be rejected by the
server.
Tt recommended to use a small recvWindow of 5000 or less!
Here is a step-by-step example of how to send a vaild signed payload from the
Linux command line using echo, openssl, and curl.
| Key | Value |
|---|---|
| apiKey | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A |
| secretKey | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j |
| Parameter | Value |
|---|---|
| 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 |
-
queryString: asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=test×tamp=1510903211000
-
HMAC SHA256 signature:
[linux]$ echo -n "asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000×tamp=1510903211000" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" (stdin)= 157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320 -
curl command:
(HMAC SHA256) [linux]$ 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×tamp=1510903211000&signature=157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320'
-
requestBody: asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=test×tamp=1510903211000
-
HMAC SHA256 signature:
[linux]$ echo -n "asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000×tamp=1510903211000" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" (stdin)= 157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320 -
curl command:
(HMAC SHA256) [linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://www.binance.com/wapi/v3/withdraw.html' -d 'asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000&name=addressName×tamp=1510903211000&signature=157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320'
-
queryString: asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b
-
requestBody: amount=1&recvWindow=5000&name=test×tamp=1510903211000
-
HMAC SHA256 signature:
[linux]$ echo -n "asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b&amount=1&recvWindow=5000×tamp=1510903211000" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j" (stdin)= 157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320 -
curl command:
(HMAC SHA256) [linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://www.binance.com/wapi/v3/withdraw.html?asset=ETH&address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b' -d 'amount=1&recvWindow=5000&name=addressName×tamp=1510903211000&signature=157fb937ec848b5f802daa4d9f62bea08becbf4f311203bda2bd34cd9853e320'
Note that the signature is different in example 3. There is no & between "address=0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b" and "amount=1".
POST /wapi/v3/withdraw.html (HMAC SHA256)
Submit a withdraw request.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | YES | |
| address | STRING | YES | |
| addressTag | STRING | NO | Secondary address identifier for coins like XRP,XMR etc. |
| amount | DECIMAL | YES | |
| name | STRING | NO | Description of the address |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
| Response: |
[
{
"msg": "success",
"success": true,
"id":"7213fea8e94b4a5593d507237e5a555b"
}
]GET /wapi/v3/depositHistory.html (HMAC SHA256)
Fetch deposit history.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | NO | |
| status | INT | NO | 0(0:pending,1:success) |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
{
"depositList": [
{
"insertTime": 1508198532000,
"amount": 0.04670582,
"asset": "ETH",
"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
"txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1",
"status": 1
},
{
"insertTime": 1508298532000,
"amount": 1000,
"asset": "XMR",
"address": "463tWEBn5XZJSxLU34r6g7h8jtxuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ",
"addressTag": "342341222",
"txId": "b3c6219639c8ae3f9cf010cdc24fw7f7yt8j1e063f9b4bd1a05cb44c4b6e2509",
"status": 1
}
],
"success": true
}GET /wapi/v3/withdrawHistory.html (HMAC SHA256)
Fetch withdraw history.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | NO | |
| status | INT | NO | 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6Completed) |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
{
"withdrawList": [
{
"id":"7213fea8e94b4a5593d507237e5a555b"
"amount": 1,
"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
"asset": "ETH",
"txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1",
"applyTime": 1508198532000
"status": 4
},
{
"id":"7213fea8e94b4a5534ggsd237e5a555b"
"amount": 1000,
"address": "463tWEBn5XZJSxLU34r6g7h8jtxuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ",
"addressTag": "342341222",
"txId": "b3c6219639c8ae3f9cf010cdc24fw7f7yt8j1e063f9b4bd1a05cb44c4b6e2509",
"asset": "XMR",
"applyTime": 1508198532000,
"status": 4
}
],
"success": true
}GET /wapi/v3/depositAddress.html (HMAC SHA256)
Fetch deposit address.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | YES | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
[
{
"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
"success": true,
"addressTag": "1231212",
"asset": "BNB"
}
]GET /wapi/v3/accountStatus.html
Fetch account status detail.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
{
"msg": "Order failed:Low Order fill rate! Will be reactivated after 5 minutes.",
"success": true,
"objs": [
"5"
]
}