REST API
General API information
- The base endpoint is: https://api.blocpal.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 return codes
- HTTP
4XXreturn codes are used for malformed requests; the issue is on the sender's side. - HTTP
403return code is used when the WAF Limit (Web Application Firewall) has been violated. - 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 BlocPalX's side. It is important to NOT treat this as a failure operation; the execution status is UNKNOWN and could have been a success.
Error Codes
- Any endpoint can return an ERROR
Sample Payload below:
{
"code": -1121,
"msg": "Invalid symbol."
}
- Specific error codes and messages are defined in Errors Codes.
General Information on Endpoints
- 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.
LIMITS
General Info on Limits
- The following
intervalLettervalues for headers:- SECOND => S
- MINUTE => M
- HOUR => H
- DAY => D
intervalNumdescribes the amount of the interval. For example,intervalNum5 withintervalLetterM means "Every 5 minutes".- The
/api/v3/exchangeInforateLimitsarray contains objects related to the exchange'sRAW_REQUEST,REQUEST_WEIGHT, andORDERrate limits. These are further defined in theENUM definitionssection underRate limiters (rateLimitType). - A 429 will be returned when either rate limit is violated.
IP limits
- Every request will contain
X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter)in the response headers which has the current used weight for the IP for all request rate limiters defined. - 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 received, 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.
- A
Retry-Afterheader is sent with a 418 or 429 responses and will give the number of seconds required to wait, in the case of a 418, to prevent a ban, or, in the case of a 429, until the ban is over. - The limits on the API are based on the IPs, not the API keys.
Order rate limits
- Every successful order response will contain a
X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)header which has the current order count for the IP for all order rate limiters defined. - Rejected/unsuccessful orders are not guaranteed to have
X-MBX-ORDER-COUNT-**headers in the response. - The order rate limit is counted against each account.
Endpoint security type
- Each endpoint has a security type that determines the how you will
interact with it. This is stated next to the NAME of the endpoint.
- If no security type is stated, assume the security type is NONE.
- 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.
SIGNED (TRADE and USER_DATA) endpoint security
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.
Timing security
- 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 specify 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.
It is recommended to use a small recvWindow of 5000 or less! The max cannot go beyond 60,000!
SIGNED endpoint examples for POST /api/v3/order
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 |
|---|---|
| symbol | LTCBTC |
| side | BUY |
| type | LIMIT |
| timeInForce | GTC |
| quantity | 1 |
| price | 0.1 |
| recvWindow | 5000 |
| timestamp | 1499827319559 |
Example 1: As a request body
requestBody: symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559
HMAC SHA256 signature:
[linux]$ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
(stdin)= c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71
curl command:
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.blocpal.com/api/v3/order' -d 'symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
Example 2: As a query string
queryString: symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559
HMAC SHA256 signature:
[linux]$ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
(stdin)= c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71
curl command:
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.blocpal.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
Example 3: Mixed query string and request body
queryString: symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC
requestBody: quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559
HMAC SHA256 signature:
[linux]$ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTCquantity=1&price=0.1&recvWindow=5000×tamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
(stdin)= 0fd168b8ddb4876a0358a8d14d0c9f3da0e9b20c5d52b2a00fcf7d1c602f9a77
curl command:
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.blocpal.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC' -d 'quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559&signature=0fd168b8ddb4876a0358a8d14d0c9f3da0e9b20c5d52b2a00fcf7d1c602f9a77'
Note that the signature is different in example 3. There is no & between "GTC" and "quantity=1".
Public API endpoints
Terminology
base assetrefers to the asset that is thequantityof a symbol.quote assetrefers to the asset that is thepriceof a symbol.
ENUM definitions
Symbol status (status):
- PRE_TRADING
- TRADING
- POST_TRADING
- END_OF_DAY
- HALT
- AUCTION_MATCH
- BREAK
Symbol type:
- SPOT
Order status (status):
- NEW
- PARTIALLY_FILLED
- FILLED
- CANCELED
- PENDING_CANCEL (currently unused)
- REJECTED
- EXPIRED
OCO Status (listStatusType):
- RESPONSE
- EXEC_STARTED
- ALL_DONE
OCO Order Status (listOrderStatus):
- EXECUTING
- ALL_DONE
- REJECT
ContingencyType
- OCO
Order types (orderTypes, type):
- LIMIT
- LIMIT_MAKER
- MARKET
- STOP_LOSS (not yet supported)
- STOP_LOSS_LIMIT (not yet supported)
- TAKE_PROFIT (note yet supported)
- TAKE_PROFIT_LIMIT (not yet supported)
Order side (side):
- BUY
- SELL
Time in force (timeInForce):
- GTC
- IOC
- FOK (not yet supported)
Kline/Candlestick chart intervals:
m → minutes; h → hours; d → days; w → weeks; M → months
- 1m
- 3m
- 5m
- 15m
- 30m
- 1h
- 2h
- 4h
- 6h
- 8h
- 12h
- 1d
- 3d
- 1w
- 1M
Rate limiters (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
}
Rate limit intervals (interval)
- SECOND
- MINUTE
- DAY
General endpoints
Test connectivity
GET /api/v3/ping
Test connectivity to the Rest API.
Weight: 1
Parameters: NONE
Response:
{}
Check server time
GET /api/v3/time
Test connectivity to the Rest API and get the current server time.
Weight: 1
Parameters: NONE
Response:
{
"serverTime": 1499827319559
}
Exchange information
GET /api/v3/exchangeInfo
Current exchange trading rules and symbol information
Weight: 1
Parameters: NONE
Response:
{
"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
]
}
]
}
Market Data endpoints
Order book
GET /api/v3/depth
Weight: Adjusted based on the limit:
| Limit | Weight |
|---|---|
| 5, 10, 20, 50, 100 | 1 |
| 500 | 5 |
| 1000 | 10 |
| 5000 | 50 |
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| limit | INT | NO | Default 100; max 5000. Valid limits:[5, 10, 20, 50, 100, 500, 1000, 5000] |
Response:
{
"lastUpdateId": 1027024,
"bids": [
[
"4.00000000", // PRICE
"431.00000000" // QTY
]
],
"asks": [
[
"4.00000200",
"12.00000000"
]
]
}
Recent trades list
GET /api/v3/trades
Get recent trades (up to last 500).
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| limit | INT | NO | Default 500; max 1000. |
Response:
[
{
"id": 28457,
"price": "4.00000100",
"qty": "12.00000000",
"quoteQty": "48.000012",
"time": 1499865549590,
"isBuyerMaker": true,
"isBestMatch": true
}
]
Old trade lookup (MARKET_DATA)
GET /api/v3/historicalTrades
Get older trades.
Weight: 5
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| limit | INT | NO | Default 500; max 1000. |
| fromId | LONG | NO | TradeId to fetch from. Default gets most recent trades. |
Response:
[
{
"id": 28457,
"price": "4.00000100",
"qty": "12.00000000",
"quoteQty": "48.000012",
"time": 1499865549590,
"isBuyerMaker": true,
"isBestMatch": true
}
]
Compressed/Aggregate trades list
GET /api/v3/aggTrades
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| fromId | LONG | NO | ID to get aggregate trades from INCLUSIVE. |
| startTime | LONG | NO | Timestamp in ms to get aggregate trades from INCLUSIVE. |
| endTime | LONG | NO | Timestamp in ms to get aggregate trades until INCLUSIVE. |
| limit | INT | NO | Default 500; max 1000. |
- If both startTime and endTime are sent, time between startTime and endTime must be less than 1 hour.
- If fromId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.
Response:
[
{
"a": 26129, // Aggregate tradeId
"p": "0.01633102", // Price
"q": "4.70443515", // Quantity
"f": 27781, // First tradeId
"l": 27781, // Last tradeId
"T": 1498793709153, // Timestamp
"m": true, // Was the buyer the maker?
"M": true // Was the trade the best price match?
}
]
Kline/Candlestick data
GET /api/v3/klines
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| interval | ENUM | YES | 1m 3m 5m 15m 30m 1h 2h 4h 6h 8h 12h 1d 3d 1w 1M |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| limit | INT | NO | Default 500; max 1000. |
- m -> minutes; h -> hours; d -> days; w -> weeks; M -> months
- If startTime and endTime are not sent, the most recent klines are returned.
Response:
[
[
1499040000000, // Open time
"0.01634790", // Open
"0.80000000", // High
"0.01575800", // Low
"0.01577100", // Close
"148976.11427815", // Volume
1499644799999, // Close time
"2434.19055334", // Quote asset volume
308, // Number of trades
"1756.87402397", // Taker buy base asset volume
"28.46694368", // Taker buy quote asset volume
"17928899.62484339" // Ignore.
]
]
Current average price
Current average price for a symbol.
GET /api/v3/avgPrice
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES |
Response:
{
"mins": 5,
"price": "9.35751834"
}
24hr ticker price change statistics
GET /api/v3/ticker/24hr
24 hour rolling window price change statistics. Careful when accessing this with no symbol.
Weight: 1 for a single symbol; 40 when the symbol parameter is omitted
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | NO |
- If the symbol is not sent, tickers for all symbols will be returned in an array.
Response:
{
"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, // First tradeId
"lastId": 28460, // Last tradeId
"count": 76 // Trade count
}
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, // First tradeId
"lastId": 28460, // Last tradeId
"count": 76 // Trade count
}
]
Symbol price ticker
GET /api/v3/ticker/price
Latest price for a symbol or symbols.
Weight: 1 for a single symbol; 2 when the symbol parameter is omitted
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | NO |
- If the symbol is not sent, prices for all symbols will be returned in an array.
Response:
{
"symbol": "LTCBTC",
"price": "4.00000200"
}
OR
[
{
"symbol": "LTCBTC",
"price": "4.00000200"
},
{
"symbol": "ETHBTC",
"price": "0.07946600"
}
]
Symbol order book ticker
GET /api/v3/ticker/bookTicker
Best price/qty on the order book for a symbol or symbols.
Weight: 1 for a single symbol; 2 when the symbol parameter is omitted
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | NO |
- If the symbol is not sent, bookTickers for all symbols will be returned in an array.
Response:
{
"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"
}
]
Account endpoints
New order (TRADE)
POST /api/v3/order (HMAC SHA256)
Send in a new order.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| side | ENUM | YES | |
| type | ENUM | YES | |
| timeInForce | ENUM | NO | |
| quantity | DECIMAL | YES | |
| price | DECIMAL | NO | |
| newClientOrderId | STRING | NO | A unique id for the order. Automatically generated if not sent. |
| stopPrice | DECIMAL | NO | Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders. |
| icebergQty | DECIMAL | NO | Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order. |
| newOrderRespType | ENUM | NO | Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Additional mandatory parameters based on type:
| Type | Additional mandatory parameters |
|---|---|
LIMIT | timeInForce, quantity, price |
MARKET | quantity |
STOP_LOSS | quantity, stopPrice |
STOP_LOSS_LIMIT | timeInForce, quantity, price, stopPrice |
TAKE_PROFIT | quantity, stopPrice |
TAKE_PROFIT_LIMIT | timeInForce, quantity, price, stopPrice |
LIMIT_MAKER | quantity, price |
Other info:
LIMIT_MAKERareLIMITorders that will be rejected if they would immediately match and trade as a taker.STOP_LOSSandTAKE_PROFITwill execute aMARKETorder when thestopPriceis reached.- Any
LIMITorLIMIT_MAKERtype order can be made an iceberg order by sending anicebergQty. - Any order with an
icebergQtyMUST havetimeInForceset toGTC.
Trigger order price rules against market price for both MARKET and LIMIT versions:
- Price above market price:
STOP_LOSSBUY,TAKE_PROFITSELL - Price below market price:
STOP_LOSSSELL,TAKE_PROFITBUY
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"
}
]
}
Test new order (TRADE)
POST /api/v3/order/test (HMAC SHA256)
Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
Weight: 1
Parameters:
Same as POST /api/v3/order
Response:
{}
Query order (USER_DATA)
GET /api/v3/order (HMAC SHA256)
Check an order's status.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| orderId | LONG | NO | |
| origClientOrderId | STRING | NO | |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Notes:
- Either
orderIdororigClientOrderIdmust be sent. - For some historical orders
cummulativeQuoteQtywill be < 0, meaning the data is not available at this time.
Response:
{
"symbol": "LTCBTC",
"orderId": 1,
"orderListId": -1 //Unless part of an 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,
"commission: "0.00001",
"commissionAsset: "LTC"
}
Cancel order (TRADE)
DELETE /api/v3/order (HMAC SHA256)
Cancel an active order.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| orderId | LONG | NO | |
| origClientOrderId | STRING | NO | |
| newClientOrderId | STRING | NO | Used to uniquely identify this cancel. Automatically generated by default. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Either orderId or origClientOrderId must be sent.
Response:
{
"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"
}
Current open orders (USER_DATA)
GET /api/v3/openOrders (HMAC SHA256)
Get all open orders on a symbol. Careful when accessing this with no symbol.
Weight: 1 for a single symbol; 40 when the symbol parameter is omitted
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | NO | |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
- If the symbol is not sent, orders for all symbols will be returned in an array.
Response:
[
{
"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,
"commission: "0.00001",
"commissionAsset: "LTC"
}
]
All orders (USER_DATA)
GET /api/v3/allOrders (HMAC SHA256)
Get all account orders; active, canceled, or filled.
Weight: 5 with symbol
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| orderId | LONG | NO | |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| limit | INT | NO | Default 500; max 1000. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Notes:
- If
orderIdis set, it will get orders >= thatorderId. Otherwise most recent orders are returned. - For some historical orders
cummulativeQuoteQtywill be < 0, meaning the data is not available at this time.
Response:
[
{
"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,
"commission: "0.00001",
"commissionAsset: "LTC"
}
]
New OCO (TRADE)
(Not yet implemented - coming soon)
POST /api/v3/order/oco (HMAC SHA256)
Weight: 1
Send in a new OCO
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| listClientOrderId | STRING | NO | A unique Id for the entire orderList |
| side | ENUM | YES | |
| quantity | DECIMAL | YES | |
| limitClientOrderId | STRING | NO | A unique Id for the limit order |
| price | DECIMAL | YES | |
| limitIcebergQty | DECIMAL | NO | Used to make the LIMIT_MAKER leg an iceberg order. |
| stopClientOrderId | STRING | NO | A unique Id for the stop loss/stop loss limit leg |
| stopPrice | DECIMAL | YES | |
| stopLimitPrice | DECIMAL | NO | If provided, stopLimitTimeInForce is required. |
| stopIcebergQty | DECIMAL | NO | Used with STOP_LOSS_LIMIT leg to make an iceberg order. |
| stopLimitTimeInForce | ENUM | NO | Valid values are GTC/FOK/IOC |
| newOrderRespType | ENUM | NO | Set the response JSON. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Additional Info:
- Price Restrictions:
SELL: Limit Price > Last Price > Stop PriceBUY: Limit Price < Last Price < Stop Price
- Quantity Restrictions:
- Both legs must have the same quantity.
ICEBERGquantities however do not have to be the same
Response:
{
"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"
}
]
}
Cancel OCO (TRADE)
(Not yet implemented - coming soon)
DELETE /api/v3/orderList (HMAC SHA256)
Weight: 1
Cancel an entire Order List
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| orderListId | LONG | NO | Either orderListId or listClientOrderId must be provided |
| listClientOrderId | STRING | NO | Either orderListId or listClientOrderId must be provided |
| newClientOrderId | STRING | NO | Used to uniquely identify this cancel. Automatically generated by default |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Additional notes:
- Canceling an individual leg will cancel the entire OCO
Query OCO (USER_DATA)
(Not yet implemented - coming soon)
GET /api/v3/orderList (HMAC SHA256)
Weight: 1
Retrieves a specific OCO based on provided optional parameters
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| orderListId | LONG | NO | Either orderListId or listClientOrderId must be provided |
| origClientOrderId | STRING | NO | Either orderListId or listClientOrderId must be provided |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
{
"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"
}
]
}
Query all OCO (USER_DATA)
(Not yet implemented - coming soon)
GET /api/v3/allOrderList (HMAC SHA256)
Weight: 10
Retrieves all OCO based on provided optional parameters
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| fromId | LONG | NO | If supplied, neither startTime or endTime can be provided |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| limit | INT | NO | Default Value: 500; Max Value: 1000 |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
[
{
"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"
}
]
}
]
Query Open OCO (USER_DATA)
(Not yet implemented - coming soon)
GET /api/v3/openOrderList (HMAC SHA256)
Weight: 2
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
[
{
"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"
}
]
}
]
Account information (USER_DATA)
GET /api/v3/account (HMAC SHA256)
Get current account information.
Weight: 5
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
{
"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"
}
]
}
Account trade list (USER_DATA)
GET /api/v3/myTrades (HMAC SHA256)
Get trades for a specific account and symbol.
Weight: 5 with symbol
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| fromId | LONG | NO | TradeId to fetch from. Default gets most recent trades. |
| limit | INT | NO | Default 500; max 1000. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Notes:
- If
fromIdis set, it will get orders >= thatfromId. Otherwise most recent orders are returned.
Response:
[
{
"symbol": "BNBBTC",
"id": 28457,
"orderId": 100234,
"orderListId": -1,
"price": "4.00000100",
"qty": "12.00000000",
"quoteQty": "48.000012",
"commission": "10.10000000",
"commissionAsset": "BNB",
"time": 1499865549590,
"isBuyer": true,
"isMaker": false,
"isBestMatch": true
}
]
User data stream endpoints
Specifics on how user data streams work is in another document.
Start user data stream (USER_STREAM)
POST /api/v3/userDataStream
Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent.
Weight: 1
Parameters: NONE
Response:
{
"listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}
Keepalive user data stream (USER_STREAM)
PUT /api/v3/userDataStream
Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 30 minutes.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| listenKey | STRING | YES |
Response:
{}
Close user data stream (USER_STREAM)
DELETE /api/v3/userDataStream
Close out a user data stream.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| listenKey | STRING | YES |
Response:
{}
Filters
Filters define trading rules on a symbol or an exchange.
Filters come in two forms: symbol filters and exchange filters.
Symbol filters
PRICE_FILTER
The PRICE_FILTER defines the price rules for a symbol. There are 3 parts:
minPricedefines the minimumprice/stopPriceallowed; disabled onminPrice== 0.maxPricedefines the maximumprice/stopPriceallowed; disabled onmaxPrice== 0.tickSizedefines the intervals that aprice/stopPricecan be increased/decreased by; disabled ontickSize== 0.
Any of the above variables can be set to 0, which disables that rule in the price filter. In order to pass the price filter, the following must be true for price/stopPrice of the enabled rules:
price>=minPriceprice<=maxPrice- (
price-minPrice) %tickSize== 0
/exchangeInfo format:
{
"filterType": "PRICE_FILTER",
"minPrice": "0.00000100",
"maxPrice": "100000.00000000",
"tickSize": "0.00000100"
}
PERCENT_PRICE
The PERCENT_PRICE filter defines valid range for a price based on the average of the previous trades.
avgPriceMins is the number of minutes the average price is calculated over. 0 means the last price is used.
In order to pass the percent price, the following must be true for price:
price<=weightedAveragePrice*multiplierUpprice>=weightedAveragePrice*multiplierDown
/exchangeInfo format:
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "1.3000",
"multiplierDown": "0.7000",
"avgPriceMins": 5
}
LOT_SIZE
The LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for a symbol. There are 3 parts:
minQtydefines the minimumquantity/icebergQtyallowed.maxQtydefines the maximumquantity/icebergQtyallowed.stepSizedefines the intervals that aquantity/icebergQtycan be increased/decreased by.
In order to pass the lot size, the following must be true for quantity/icebergQty:
quantity>=minQtyquantity<=maxQty- (
quantity-minQty) %stepSize== 0
/exchangeInfo format:
{
"filterType": "LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
}
MIN_NOTIONAL
The MIN_NOTIONAL filter defines the minimum notional value allowed for an order on a symbol.
An order's notional value is the price * quantity.
applyToMarket determines whether or not the MIN_NOTIONAL filter will also be applied to MARKET orders.
Since MARKET orders have no price, the average price is used over the last avgPriceMins minutes.
avgPriceMins is the number of minutes the average price is calculated over. 0 means the last price is used.
/exchangeInfo format:
{
"filterType": "MIN_NOTIONAL",
"minNotional": "0.00100000",
"applyToMarket": true,
"avgPriceMins": 5
}
ICEBERG_PARTS
The ICEBERG_PARTS filter defines the maximum parts an iceberg order can have. The number of ICEBERG_PARTS is defined as CEIL(qty / icebergQty).
/exchangeInfo format:
{
"filterType": "ICEBERG_PARTS",
"limit": 10
}
MARKET_LOT_SIZE
The MARKET_LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for MARKET orders on a symbol. There are 3 parts:
minQtydefines the minimumquantityallowed.maxQtydefines the maximumquantityallowed.stepSizedefines the intervals that aquantitycan be increased/decreased by.
In order to pass the market lot size, the following must be true for quantity:
quantity>=minQtyquantity<=maxQty- (
quantity-minQty) %stepSize== 0
/exchangeInfo format:
{
"filterType": "MARKET_LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
}
MAX_NUM_ORDERS
The MAX_NUM_ORDERS filter defines the maximum number of orders an account is allowed to have open on a symbol.
Note that both "algo" orders and normal orders are counted for this filter.
/exchangeInfo format:
{
"filterType": "MAX_NUM_ORDERS",
"limit": 25
}
MAX_NUM_ALGO_ORDERS
The MAX_NUM_ALGO_ORDERS filter defines the maximum number of "algo" orders an account is allowed to have open on a symbol.
"Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
/exchangeInfo format:
{
"filterType": "MAX_NUM_ALGO_ORDERS",
"maxNumAlgoOrders": 5
}
MAX_NUM_ICEBERG_ORDERS
The MAX_NUM_ICEBERG_ORDERS filter defines the maximum number of ICEBERG orders an account is allowed to have open on a symbol.
An ICEBERG order is any order where the icebergQty is > 0.
/exchangeInfo format:
{
"filterType": "MAX_NUM_ICEBERG_ORDERS",
"maxNumIcebergOrders": 5
}
Exchange filters
EXCHANGE_MAX_NUM_ORDERS
The MAX_NUM_ORDERS filter defines the maximum number of orders an account is allowed to have open on the exchange.
Note that both "algo" orders and normal orders are counted for this filter.
/exchangeInfo format:
{
"filterType": "EXCHANGE_MAX_NUM_ORDERS",
"maxNumOrders": 1000
}
EXCHANGE_MAX_NUM_ALGO_ORDERS
The MAX_ALGO_ORDERS filter defines the maximum number of "algo" orders an account is allowed to have open on the exchange.
"Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
/exchangeInfo format:
{
"filterType": "EXCHANGE_MAX_ALGO_ORDERS",
"maxNumAlgoOrders": 200
}