Change Log
Important Documentation Notice
Binance has launched its new API Documentation Portal. The existing GitHub API documentation is now deprecated(2024-06-17) and set to go offline in the upcoming few months following user migration; the exact date will be determined and communicated in due course.
During this transition phase, both sites will be maintained. However, any new services will only be published in the new portal moving forward.
Here's a reference table of the links for the current and new API documentation:
2024-07-24
REST API
New Endpoints to Query Account Information:
GET /fapi/v1/symbolConfig
: Query user symbol configuration.GET /fapi/v1/accountConfig
: Query user account configuration.GET /fapi/v3/account
: Compared toGET /fapi/v2/account
, this endpoint only returns symbols that the user has positions or open orders in. Configuration-related fields have been removed and can now be queried fromGET /fapi/v1/symbolConfig
andGET /fapi/v1/accountConfig
. The V3 endpoint also offers better performance.GET /fapi/v3/balance
: Query user account balance.
New Endpoints to Query Trade Information:
GET /fapi/v3/positionRisk
: Compared toGET /fapi/v2/positionRisk
, this endpoint only returns symbols that the user has positions or open orders in. Configuration-related fields have been removed and can now be queried fromGET /fapi/v1/symbolConfig
. The V3 endpoint also offers better performance.
WebSocket API
- New Endpoints to Query Account Information:
v2/account.status
: Compared toaccount.status
, this endpoint only returns symbols that the user has positions or open orders in. Configuration-related fields have been removed and can now be queried fromGET /fapi/v1/symbolConfig
andGET /fapi/v1/accountConfig
. The V2 endpoint also offers better performance.v2/account.balance
: Query user account balance.v2/account.position
: Compared toaccount.position
, this endpoint only returns symbols that the user has positions or open orders in. Configuration-related fields have been removed and can now be queried fromGET /fapi/v1/symbolConfig
. The V2 endpoint also offers better performance.
Deprecation Notice:
- The following endpoints will be deprecated in the coming months (exact date to be announced later). Please switch to the new endpoints listed above:
- REST API:
- GET /fapi/v2/balance
- GET /fapi/v2/account
- GET /fapi/v2/positionRisk
- Websocket API:
- account.status
- account.balance
- account.position
2024-06-19
- The response field
marginAsset
inGET /fapi/v1/userTrades
will be removed on 2024-06-25.
2024-05-28
- "The
autoAssetExchange
field inGET /fapi/v1/exchangeInfo
is exclusively applicable for users with VIP levels 2-9. For thresholds pertaining to VIP level 0-1 users, please refer to the relevant Binance announcement.
2024-05-24
- New endpoint to toggle BNB Burn:
POST /fapi/v1/feeBurn
to toggle BNB Burn on Futures Trade.GET /fapi/v1/feeBurn
to get BNB Burn status.
2024-04-19
{
"listenKey": "3HBntNTepshgEdjIwSUIBgB9keLyOCg5qv3n6bYAtktG8ejcaW5HXz9Vx1JgIieg"
}
- The new field
listenKey
will be integrated into the response received from thePUT /fapi/v1/listenKey
endpoint or Websocket ApiuserDataStream.ping
. This enhancement will allow users to view the key that has been kept alive. This update is scheduled to take effect on 2024-04-25.
2024-04-09
- Good-Till-Cancel (GTC) timeInForce will have a one-year validity period after order placement. GTC orders longer than one-year will be automatically canceled. This applies to all order types including reduceOnly but does not affect part-filled orders or strategy trading or copy-trading orders.
2024-04-01
WEBSOCKET API
- Websocket API is now available and can be accessed through this URL:
wss://ws-fapi.binance.com/ws-fapi/v1
- WebSocket API allows placing orders, canceling orders, etc. through a WebSocket connection.
- WebSocket API is a separate service from WebSocket Market Data streams. I.e., placing orders and listening to market data requires two separate WebSocket connections.
- WebSocket API is subject to the same Filter and Rate Limit rules as REST API.
- WebSocket API and REST API are functionally equivalent: they provide the same features, accept the same parameters, return the same status and error codes.
2024-03-11
REST
- Add new Account Endpoints:
GET /fapi/v1/rateLimit/order
: query user order rate limits
2024-02-09
Binance Future is doing Websocket Service upgrade and the upgrade impacts the following:
Before upgrade:
- The websocket server will send a ping frame every 3 minutes. If the websocket server does not receive a pong frame back from the connection within a 10 minute period, the connection will be disconnected. Unsolicited pong frames are allowed.
After upgrade:
- Websocket server will send a
ping frame
every 3 minutes.- If the websocket server does not receive a
pong frame
back from the connection within a 10 minute period, the connection will be disconnected. - When you receive a ping, you must send a pong with a copy of ping's payload as soon as possible.
- Unsolicited
pong frames
are allowed, but will not prevent disconnection. It is recommended that the payload for these pong frames are empty.
- If the websocket server does not receive a
- Websocket server will send a
2024-01-24
Testnet WEBSOCKET
- The Websocket baseurl for testnet is updated to "wss://fstream.binancefuture.com"
2024-01-08
REST
- Update endpoint for Account/Trade(Release date 2023-01-11):
PUT /fapi/v1/order
: add parameterpriceMatch
to support priceMatch for order modificationPUT /fapi/v1/batchOrders
: add parameterpriceMatch
to support priceMatch for order modification- Order modification will preserve the original
selfTradePreventionMode
of the order
2023-12-12
WEBSOCKET
- Update speed for stream
!bookTicker
will be modified from real-time to every 5 seconds on starting December 20, 2023. Individual Symbol Book Ticker Streams<symbol>@bookticker
will remain unaffected by this update
2023-11-15
REST
- Add new Market Data Endpoints:
GET /fapi/v2/ticker/price
: this is v2 endpoint for querying latest price. It has same parameters and response as theGET /fapi/v1/ticker/price
, and it offers lower latency and consume less of the IP rate limit. Please note that theGET /fapi/v1/ticker/price
will be deprecated in the future, with the exact timing to be determined.
WEBSOCKET
- Binance Futures will retire the
wss://fstream-auth.binance.com
domain at 2023-12-15 06:00. API users are advised to establish a new WebSocket connection towss://fstream.binance.com
. Please note that the connection method forwss://fstream.binance.com
is different from that ofwss://fstream-auth.binance.com
. For instance:wss://fstream-auth.binance.com/ws/<ListenKey>?listenKey=<ListenKey>
should change towss://fstream.binance.com/ws/<ListenKey>
2023-11-01
REST
Add new Market Data Endpoints:
GET /futures/data/basis
: query basis data
Update on
GET /fapi/v1/fundingRate
:- add response field
markPrice
to display mark price associated with a particular funding fee charge
- add response field
2023-10-19
REST
- New Market Data Endpoints
GET /futures/data/delivery-price
: query quarterly contract settlement price
- Update Rate Limit to 1000/5min/IP on Market Data Endpoints below:
GET /futures/data/openInterestHist
GET /futures/data/topLongShortAccountRatio
GET /futures/data/topLongShortPositionRatio
GET /futures/data/globalLongShortAccountRatio
GET /futures/data/takerlongshortRatio
- Update Rate Limit to 500/5min/IP on Market Data Endpoints below:
GET /fapi/v1/fundingRate
andGET /fapi/v1/fundingInfo
share 500/5min/IP rate limit
2023-10-16
REST
- New Market Data Endpoints
GET /fapi/v1/constituents
: query index constituents
2023-10-11
REST
- Account Endpoints IP Weight Update:
GET /fapi/v1/income/asyn
: 5->1000GET /fapi/v1/order/asyn
: 5->1000GET /fapi/v1/trade/asyn
: 5->1000GET /fapi/v1/income/asyn/id
: 5->10GET /fapi/v1/order/asyn/id
: 5->10GET /fapi/v1/trade/asyn/id
: 5->10
2023-09-25
REST
- New Market Data Endpoints Update
GET /fapi/v1/fundingInfo
: query adjusted funding info
2023-09-20
REST
- Update on
GET /fapi/v1/ticker/bookTicker
:- add response field
lastUpdateId
- add response field
2023-09-19
{
"code": -1008,
"msg": "Server is currently overloaded with other requests. Please try again in a few minutes."
}
- New error code message for http
503
return code, endpoints below might have this response during high traffic:POST /fapi/v1/order
PUT /fapi/v1/order
DELETE /fapi/v1/order
POST /fapi/v1/batchOrder
PUT /fapi/v1/batchOrder
DELETE /fapi/v1/batchOrder
POST /fapi/v1/order/test
DELETE /fapi/v1/allOpenOrders
- This is a failure API operation and you can resend your request if you need.
2023-09-05
- As per the announcement, Self Trade Prevention is enabled at 2023-09-05.
- Price Match/ Good Till Date TIF/ Breakeven Price(detail in 2023-08-29 changelog) are released at 2023-09-05
2023-08-31
Binance Future is doing Websocket Service upgrade and the upgrade impacts the following:
Before upgrade:
- The websocket server will send a ping frame every 5 minutes. If the websocket server does not receive a pong frame back from the connection within a 15 minute period, the connection will be disconnected. Unsolicited pong frames are allowed.
After upgrade:
- The websocket server will send a ping frame every 3 minutes. If the websocket server does not receive a pong frame back from the connection within a 10 minute period, the connection will be disconnected. Unsolicited pong frames are allowed.
2023-08-29
Self-Trade Prevention(Release Date TBD):
Self-Trade Prevention (aka STP) will be added to the system. This will prevent orders from matching with orders from the same account, or accounts under the same
tradeGroupId
. For more detail, please check FAQUser can set
selfTradePreventionMode
when placing new orders. All symbols support the following STP mode:- NONE: No Self-Trade Prevention
- EXPIRE_TAKER: expire taker order when STP trigger
- EXPIRE_BOTH: expire taker and maker order when STP trigger
- EXPIRE_MAKER: expire maker order when STP trigger
REST Update:
- New order status
EXPIRED_IN_MATCH
- This means that the order expired due to STP being triggered. GET /fapi/v2/account
: Add new fieldtradeGroupId
in response to show user's tradeGroupId- Add optional parameter
selfTradePreventionMode
in the endpoints below to set order's STP mode:POST /fapi/v1/order
POST /fapi/v1/batchOrders
- Add new field
selfTradePreventionMode
in response of the endpoints below to show order's STP mode:POST /fapi/v1/order
POST /fapi/v1/batchOrders
POST /fapi/v1/order
POST /fapi/v1/order
GET /fapi/v1/order
GET /fapi/v1/openOrders
GET /fapi/v1/allOrders
PUT /fapi/v1/order
PUT /fapi/v1/batchOrders
DELETE /fapi/v1/order
DELETE /fapi/v1/batchOrders
- New order status
WEBSOCKET User Data Stream:
- Add new field
V
inORDER_TRADE_UPDATE
to order STP mode.
- Add new field
Price Match(Release Date TBD)
USDⓈ margin future will support order price match function. This feature will allow users' LIMIT/STOP/TAKE_PROFIT orders to be placed without entering a price. The price match function will automatically determine the order price in real-time based on the price match mode and the order book.
The following
priceMatch
modes are supported on order level:- NONE: no price match
- OPPONENT: counterparty best price
- OPPONENT_5: counterparty 5th best price
- OPPONENT_10: counterparty 10th best price
- OPPONENT_20: counterparty 20th best price
- QUEUE: the best price on the same side of the order book
- QUEUE_5: the 5th best price on the same side of the order book
- QUEUE_10: the 10th best price on the same side of the order book
- QUEUE_20: the 20th best price on the same side of the order book
Example:
- User places buy order and set
priceMatch
asQUEUE_5
, the order price will be 5th best bid price of the orderbook - User places buy order and set
priceMatch
asOPPONENT
, the order price will be best ask price of the orderbook
- User places buy order and set
REST Update:
- Add optional parameter
priceMatch
in the endpoints below to set order's priceMatch mode:POST /fapi/v1/order
POST /fapi/v1/batchOrders
- Add new field
priceMatch
in response of the endpoints below to show order's priceMatch mode:POST /fapi/v1/order
POST /fapi/v1/batchOrders
POST /fapi/v1/order
POST /fapi/v1/order
GET /fapi/v1/order
GET /fapi/v1/openOrders
GET /fapi/v1/allOrders
PUT /fapi/v1/order
PUT /fapi/v1/batchOrders
DELETE /fapi/v1/order
DELETE /fapi/v1/batchOrders
- Add optional parameter
WEBSOCKET User Data Stream:
- Add new field
pm
inORDER_TRADE_UPDATE
to order's priceMatch mode.
- Add new field
Good Till Date TIF(Release Date TBD)
USDⓈ margin future will support Good To Date TIF. Orders with the TIF set to GTD will be automatically canceled. by the
goodTillDate
timeREST Update:
- Add optional parameter
goodTillDate
in the endpoints below to set order'sgoodTillDate
:POST /fapi/v1/order
POST /fapi/v1/batchOrders
- Add new field
goodTillDate
in response of the endpoints below to show order'sgoodTillDate
:POST /fapi/v1/order
POST /fapi/v1/batchOrders
POST /fapi/v1/order
POST /fapi/v1/order
GET /fapi/v1/order
GET /fapi/v1/openOrders
GET /fapi/v1/allOrders
PUT /fapi/v1/order
PUT /fapi/v1/batchOrders
DELETE /fapi/v1/order
DELETE /fapi/v1/batchOrders
- Add optional parameter
WEBSOCKET User Data Stream:
- Add new field
gtd
inORDER_TRADE_UPDATE
to order good till date.
- Add new field
Breakeven Price(Release Date TBD)
- REST Update
- Add new field
breakEvenPrice
in The following endpointGET /fapi/v2/account
GET /fapi/v2/positionRisk
- WEBSOCKET
- New field
bep
represents Break-Even Price in positionP
of payload to event: Balance and Position Update – "e": "ACCOUNT_UPDATE"
2023-08-19
- Binance Future is doing Websocket Service upgrade and the upgrade impacts the following:
- Connect websocket server without subscription:
- Before upgrade, user can connect by using:
wss://fstream.binance.com/ws
wss://fstream.binance.com/stream
wss://fstream.binance.com/ws/
wss://fstream.binance.com/stream/
- After upgrade, user can connect by using:
wss://fstream.binance.com/ws
wss://fstream.binance.com/stream
/
at the end is no longer supported
- Connect websocket server with subscription:
- Raw stream like
wss://fstream.binance.com/illegal_parameter/stream?steams=<streamName>
orwss://fstream.binance.com/illegal_parameter/ws/<streamName>
is not supported, please use removeillegal_parameter/
before/ws
and/stream
.
- Raw stream like
- Connect websocket server without subscription:
2023-08-14
- Update endpoint for Account/Trade:
GET /fapi/v1/income
: Add parameterpage
for pagination
2023-07-18
REST
- Add field
notionalCoef
inGET /fapi/v1/leverageBracket
to show the bracket multiplier comparing to default leverage bracket
2023-07-04
REST
- The following endpoints will be adjust to keep only recent three month data:
GET /fapi/v1/order
(effective 2023-07-27)GET /fapi/v1/allOrders
(effective 2023-07-27)GET /fapi/v1/userTrades
(exact time TBD)
- Please maintain and record old order/trade infomation or switch querying historical order/trade using new endpoint below:
- New endpoint
GET /fapi/v1/order/asyn
to get Download Id For Futures Order History - New endpoint
GET /fapi/v1/order/asyn/id
to get Futures Order History Download Link by Id - New endpoint
GET /fapi/v1/trade/asyn
to get Download Id For Futures Trade History - New endpoint
GET /fapi/v1/trade/asyn/id
to get Futures Trade History Download Link by Id
- New endpoint
2023-06-28
Notice:
REST
- The following endpoints will no longer be supported from 2023-07-15:
GET /fapi/v1/account
GET /fapi/v1/balance
GET /fapi/v1/positionRisk
- Please switch to corresponding v2 endpoints:
GET /fapi/v2/account
GET /fapi/v2/balance
GET /fapi/v2/positionRisk
2023-06-22
Notice:
WEBSOCKET
- Raw stream like /ws?<streamName> is not supported, for example
wss://fstream.binance.com/ws?btcusdt@depth
is invalid. - Sending websocket message with invalid JSON format will cause disconnection now, returning this error
{"error":{"code":3,"msg":"Invalid JSON: expected value at line 1 column 1"}}
2023-06-16
Notice:
It is recommended to use standard HTTP request formats, non-standard request formats will not be supported in fapi, below are some examples for correct code practice:
Escaping (") with '\x22' is no longer supported, please use the standard '%22' instead. It is necessary to URL encode the square brackets [] and the double quotes(")inside the square brackets.
DELETE /fapi/v1/batchOrders?origClientOrderIdList=
Unsupported:
[\x229151944646313025900\x22]
Suggest:
["9151944646313025900"]
--After URL encode--
DELETE /fapi/v1/batchOrders?origClientOrderIdList=%5B%229151944646313025900%22%5D
Non-standard nested JSON formats are not supported,
POST /fapi/v1/batchOrders?batchOrders=
Unsupported:
["{\"type\":\"LIMIT\",\"timeInForce\":\"GTC\"}"]
Suggest:
[{"type":"LIMIT","timeInForce":"GTC"}]
--After URL encode--
POST /fapi/v1/batchOrders?batchOrders=%5B%7B%22type%22%3A%22LIMIT%22%2C%22timeInForce%22%3A%22GTC%22%7D%5D
Using incorrect data type is not supported
DELETE /fapi/v1/batchOrders?orderIdList=
As the data type of the 'orderIdList' parameter is LIST<LONG> Unsupported:
["159856286502","159856313662"]
Suggest:
[159856286502,159856313662]
--After URL encode--
DELETE /fapi/v1/batchOrders?orderIdList=%5B159856286502%2C159856313662%5D
Invalid whitespace characters from the request parameters are not supported
Unsupported:
POST symbol=BTCUSDT& price= 40000.0 & signature=2d24a314
Suggest:
POST symbol=BTCUSDT&&price=40000.0&signature=2d24a314
Passing empty values in request parameters is not supported
Unsupported:
GET symbol=BTCUSDT&orderId=&signature=2d24a314
Suggest:
GET symbol=BTCUSDT&signature=2d24a314
2023-06-14
WEBSOCKET
- New WebSocket stream
!assetIndex@arr
OR<assetSymbol>@assetIndex
for multi-assets mode asset index update
2023-05-31
WEBSOCKET
- Add user data stream:
- new event
CONDITIONAL_ORDER_TRIGGER_REJECT
to the order reject reason for triggered TP/SL order
- new event
2023-05-24
REST
GET /fapi/v1/pmExchangeInfo
will be deprecated on 5/29 due to removingnotionalLimit
restriction.
2023-05-05
REST
- New endpoints
PUT /fapi/v1/order
andPUT /fapi/v1/batchOrders
to support limit order modify - New endpoint
GET /fapi/v1/orderAmendment
to get order modify history
WEBSOCKET
- New type "AMENDMENT" as order modify in Execution Type
x
of Order Update eventORDER_TRADE_UPDATE
2023-04-17
RELEASE DATE 2023-04-18
The recvWindow
check will also be performed when orders reach matching engine. The recvWindow
will be checked more precisely on order placing endpoints.
{
"code": -5028,
"msg": "Timestamp for this request is outside of the ME recvWindow"
}
recvWindow Logic Before Release:
- The order placing requests are valid if
recvWindow
+timestamp
=> REST API service servertimestamp
recvWindow Logic After Release:
Add new recwWindow check: the order placing requests are valid if
recvWindow
+timestamp
=> matching enginetimestamp
Impacted Endpoints:
- POST /fapi/v1/order
- PUT /fapi/v1/order
- POST /fapi/v1/batchOrders
- PUT /fapi/v1/batchOrders
2023-03-28
Referal Rebate Logic Before Release
- For every trade,the referal rebate balance change will be reflected in
ACCOUNT_UPDATE
event of USER-DATA-STREAM in real time:
{
"e": "ACCOUNT_UPDATE",
"T": 1679974782150,
"E": 1679974782155,
"a": {
"B": [
{
"a": "USDT",
"wb": "685.31478079",
"cw": "677.17212454",
"bc": "0.00258637"
}
],
"P": [],
"m": "ADMIN_DEPOSIT"
}
}
Referal Rebate Logic After Release
- Referral rebates are aggregated every 20 minutes and reflected as a single push in the
ACCOUNT_UPDATE
event of the USER-DATA-STREAM, showing the total sum of rebates earned from multiple referrals.
2023-03-08
RELEASE DATE 2023-03-22
Order Logic Before Release:
- When placing order with
timeInForce
FOK
orGTX
(Post-only), user will get order response withstatus
= “NEW“ and correspondingorder_trade_update
withx
= “NEW”,X
= “NEW”. If the orders can't meet execution criteria, user will receive another websocketorder_trade_update
messagex
= “EXPIRED”,X
= “EXPIRED”. The order can be found inGET /fapi/v1/order
orGET /fapi/v1/allOrders
.
{
"code": -5021,
"msg": "Due to the order could not be filled immediately, the FOK order has been rejected. The order will not be recorded in the order history"
}
Order Logic After Release:
- When placing order with
timeInForce
FOK
orGTX
(Post-only), if the order can't meet execution criteria, order will get rejected directly and receive error response, noorder_trade_update
message in websocket. The order can't be found inGET /fapi/v1/order
orGET /fapi/v1/allOrders
.
{
"code": -5022,
"msg": "Due to the order could not be executed as maker, the Post Only order will be rejected. The order will not be recorded in the order history"
}
- Impacted Endpoints:
- POST /fapi/v1/order
- POST /fapi/v1/batchOrders
- GET /fapi/v1/order
- GET /fapi/v1/allOrders
2023-01-04
WEBSOCKET
- Delete Order Status
NEW_INSURANCE
andNEW_ADL
in Order Update Event
2022-12-16
WEBSOCKET
- New WebSocket stream
!contractInfo
for symbol information update
2022-11-29
WEB SOCKET USER DATA STREAM
- New WebSocket stream
STRATEGY_UPDATE
in USER-DATA-STREAM: update when a strategy is created/cancelled/expired, ...etc. - New WebSocket stream
GRID_UPDATE
in USER-DATA-STREAM: update when a sub order of a grid is filled or partially filled.
2022-10-13
Note: This change will be effictive on 2022-10-17
REST RATE LIMIT WEIGHT
Endpoint GET /fapi/v1/ticker/bookTicker
Weight Update:
2 for a single symbol;
5 when the symbol parameter is omitted
2022-09-22
- Update endpoint for Account/Trade:
GET /fapi/v1/income
: Support more incomeType
- Add new endpoint for Portfolio Margin:
GET /fapi/v1/pmAccountInfo
: Get Portfolio Margin current account information.
2022-07-27
REST RATE LIMIT WEIGHT
- The weight of endpoint
GET /fapi/v1/trades
is updated to 5
2022-06-28
REST
- New endpoint
GET /fapi/v1/pmExchangeInfo
to get current Portfolio Margin exchange trading rules.
2022-03-01
REST
- New endpoint
GET /fapi/v1/income/asyn
to get Download Id For Futures Transaction History - New endpoint
GET /fapi/v1/income/asyn/id
to get Futures Transaction History Download Link by Id
2022-02-10
REST
- Update
GET /fapi/v2/account
endpoints:- If user is in multiAssetsMargin mode, all assets will be included in calculation for fields
totalInitialMargin
totalMaintMargin
totalWalletBalance
totalUnrealizedProfit
totalMarginBalance
totalPositionInitialMargin
totalOpenOrderInitialMargin
totalCrossWalletBalance
totalCrossUnPnl
availableBalance
maxWithdrawAmount
and the results will be show as value in USD - If user is in singleAssetsMargin mode, only USDT assets are included in the calculation(same as before)
- If user is in multiAssetsMargin mode, all assets will be included in calculation for fields
2021-12-30
WEBSOCKET
- New connection method for WEBSOCKET.
- Base Url is
wss://fstream-auth.binance.com
- Streams can be access either in a single raw stream or a combined stream
- Raw streams are accessed at
/ws/<streamName>?listenKey=<validateListenKey>
- Combined streams are accessed at
/stream?streams=<streamName1>/<streamName2>/<streamName3>&listenKey=<validateListenKey>
<validateListenKey>
must be a valid listenKey when you establish a connection.
- Base Url is
- More details: Websocket Market Streams and User Data Streams
2021-11-02
REST
- New endpoint
GET /fapi/v1/assetIndex
to get asset index for Multi-Assets mode margin asset
2021-07-06
REST
- New field
updateTime
as last update time of asset and position in response ofGET /fapi/v2/account
andGET /fapi/v2/positionRisk
- New fields in the response of
GET /fapi/v1/exchangeInfo
:- "liquidationFee" for liquidation fee rate
- "marketTakeBound" for he max price difference rate( from mark price) a market order can make
2021-06-15
WEBSOCKET
- New fields "q" and "i" for quote asset and index price added in stream
<symbol>@compositeIndex
REST
- Update endpoints:
- New fields
component
andquoteAsset
as component asset and quote asset added in response ofGET /fapi/v1/indexInfo
- New fields
2021-05-06
WEBSOCKET
- Update streams:
- Previous Leverage Update event
ACCOUNT_CONFIG_UPDATE
expanded as account configuration update event, including leverage update and Multi-Assets margin status update. - Balance and Position Update event
ACCOUNT_UPDATE
add new event reason typem
asAUTO_EXCHANGE
to represent Multi-Assets margin auto-exchange event
- Previous Leverage Update event
REST
New endpoints:
POST /fapi/v1/multiAssetsMargin
to change Multi-Assets margin modeGET /fapi/v1/multiAssetsMargin
to check Multi-Assets margin mode
Update endpoints:
- New object
assets
as asset information in response ofGET /fapi/v1/exchangeInfo
. - New field
marginAvailable
in response ofGET /fapi/v2/balance
andGET /fapi/v2/account
to indicate whether the asset can be used as margin in Multi-Assets mode.
- New object
2021-04-27
WEBSOCKET
- The following liquidation orders streams do not push realtime order data anymore. Instead, they push snapshot order data at a maximum frequency of 1 order push per second.:
<symbol>@forceOrder
!forceOrder@arr
REST
- The endpoint
GET /fapi/v1/allForceOrders
stop being maintained and no longer accepts request.
2021-04-22
WEBSOCKET
- New field "bc" for balance change in event "ACCOUNT_UPDATE"
2021-03-02
New endpoint
GET /fapi/v1/indexPriceKlines
to get index price kline/candlestick data.New endpoint
GET /fapi/v1/markPriceKlines
to get mark price kline/candlestick data.
2021-02-24
REST RATE LIMIT WEIGHT
- The weight of endpoint
GET /fapi/v2/balance
is updated to 5 - The weight of endpoint
GET /fapi/v2/positionRisk
is updated to 5
2021-02-22
REST RATE LIMIT WEIGHT
- The weight of endpoint
GET /fapi/v1/income
is updated to 30
REST
- The query time period for endpoint
GET /fapi/v1/allOrders
must be less than 7 days. - The query time period for endpoint
GET /fapi/v1/allForceOrders
must be within the recent 7 days.
2021-01-26
WEB SOCKET USER DATA STREAM
- New WebSocket stream
ACCOUNT_CONFIG_UPDATE
in USER-DATA-STREAM for leverage changed update
REST RATE LIMIT WEIGHT
- Following endpoints' weights will be updated to 20 with symbol and 50 without symbol:
GET /fapi/v1/allForceOrders
GET /fapi/v1/forceOrders
REST
- New filter "MIN_NOTIONAL" whicht defines the minimum notional value allowed for an order on a symbol, and shown in the
/fapi/v1/exchangeInfo
2021-01-21
The regular expression rule for newClientOrderId
updated as ^[\.A-Z\:/a-z0-9_-]{1,36}$
2021-01-04
REST RATE LIMIT WEIGHT
Following endpoints will use new weight rule based on the paremeter "LIMIT" in the request:
GET /fapi/v1/klines
GET /fapi/v1/continuousKlines
Following endpoints' weights will be updated to 20:
GET /fapi/v1/historicalTrades
GET /fapi/v1/allForceOrders
GET /fapi/v1/forceOrders
GET /fapi/v1/aggTrades
2020-12-08
WEBSOCKET
- New field
e
for event type in payload of streams<symbol>@bookTicker
and!bookTicker
- New field
P
for estimated settle price in payload of streams<symbol>@markPrice
,<symbol>@markPrice@1s
,!markPrice@arr
, and!markPrice@arr@1s
. - New stream
<pair>_<contractType>@continuousKline_<interval>
for continuous contract kline
REST API
- New field "estimatedSettlePrice" in response to
GET /fapi/v1/premiumIndex
New fields in response to
GET /fapi/v1/exchangeInfo
:- "pair"
- "contractType"
- "deliveryDate"
- "onboardDate"
New endpoint
GET /fapi/v1/continuousKlines
to get continuous contract kline data
ENUM
- Contract types:
- PERPETUAL
- CURRENT_MONTH
- NEXT_MONTH
- CURRENT_QUARTER
- NEXT_QUARTER
2020-11-27
- New endpoint
GET /fapi/v1/commissionRate
to get user commission rate.
2020-11-13
WEB SOCKET STREAM
- In order to provide users with more secure and stable services, the update time of
<symbol>depth@0ms
and<symbol>@depth<level>@0ms
is dynamically adjusted according to the total amount of data traffic and other objective conditions.
2020-11-10
- New field "marginAsset" for margin asset in the response to
GET /fapi/v1/exchangeInfo
. - New field "positionAmt" for position amount in the response to
GET /fapi/v2/account
.
2020-11-09
WEB SOCKET USER DATA STREAM
Please notice: new streamlined and optimized push rules on event ACCOUNT_UPDATE
in USER-DATA-STREAM
When an asset of a user is changed:
- Only this asset and its balance information will be pushed
- Other assets and information will no longer be pushed even the balances may not be 0
- If none of the open positions change, the position "P" will only return an empty
[]
When a position or the margin type of a symbol is changed:
- "P" will push the details in the "BOTH" position of this symbol
- If the change happens in "LONG" or "SHORT" position, the changed "LONG" or "SHORT" position of this symbol will be pushed
- Initialized "LONG" or "SHORT" isolated position of this symbol will also be pushed
- Position information of other symbols will no longer be pushed, even their positions may not be 0
In short, the full information of assets and positions should be obtained via the related RESTful endpoints(
GET /fapi/v2/account
andGET /fapi/v2/positionRisk
), and the locally cached asset or position data can be updated via the eventACCOUNT_UPDATE
in Websocket USER-DATA-STREAM with the information of changed asset or position.Please visit here to get examples for helping to understand the upgrade.
2020-10-27
WEB SOCKET STREAM
- The maximum stream number that a single connection can listen to changes as 200.
2020-10-10
WEBSOCKET
- New WebSocket streams
<symbol>@compositeIndex
for composite index symbol information.
2020-10-09
- New endpoint
GET /fapi/v1/indexInfo
to get information of composite index.
2020-09-18
- New endpoint
GET /fapi/v1/apiTradingStatus
to get futures API trading quantitative rules indicators
2020-09-09
- Some orders that were cancelled/expired will be removed gradually from API endpoints.
- Orders that meet criteria
- order status is
CANCELED
orEXPIRED
, AND - order has NO filled trade, AND
- created time + 7 days < current time
- order status is
- These endpoints are affected:
GET /fapi/v1/order
GET /fapi/v1/allOrders
- Orders that meet criteria
2020-08-14
- New field "indexPrice" in response to endpoint
GET /fapi/v1/premiumIndex
. - New field "i" for indexPrice in payload of ws streams:
<symbol>@markPrice
,<symbol>@markPrice@1s
,!markPrice@arr
,!markPrice@arr@1s
2020-08-12
- New endpoint
GET /fapi/v1/forceOrders
to get the user's force orderes.
2020-07-30
- New endpoint
GET /fapi/v1/adlQuantile
to get the positions' ADL quantile estimation values
2020-07-17
- Weights of endpoint
GET /fapi/v1/income
has been changed as 20
2020-07-02
WEBSOCKET
- New field "m" for event reason type in event "ACCOUNT_UPDATE"
- New field "rp" for the realized profit of the trade in event "ORDER_TRADE_UPDATE"
2020-06-15
- New fields in responses to
GET /fapi/v2/account
andGET /fapi/v2/balance
:availableBalance
maxWithdrawAmount
2020-06-04
- New endpoints of version 2 of fapi, having better performance than the v1 endpoints:
GET /fapi/v2/account
GET /fapi/v2/balance
2020-06-02
- New endpoint
GET /fapi/v2/positionRisk
in version 2 of fapi:- User can choose to send specific "symbol".
- All symbols in the market can be returned.
- Different responses for "One-way" or "Hedge" position mode.
- Better performance than the v1 endpoint.
2020-05-18
New parameter
closePosition
for endpointPOST /fapi/v1/order
:
If aSTOP_MARKET
orTAKE_PROFIT_MARKET
order withclosePosition=true
is triggered,all of the current long position( ifSELL
order) or current short position( ifBUY
order) will be closed.New field
closePosition
in response to endpoints:POST /fapi/v1/order
POST /fapi/v1/batchOrders
GET /fapi/v1/order
DELETE /fapi/v1/order
DELETE /fapi/v1/batchOrders
GET /fapi/v1/openOrder
GET /fapi/v1/openOrders
GET /fapi/v1/allOrders
2020-05-18
- Some orders that were cancelled/expired will be removed gradually from API endpoints, but they are still available from Web UI.
- Orders that meet criteria
- order status is
CANCELED
orEXPIRED
, AND - order has NO filled trade, AND
- created time + 30 days < current time
- order status is
- These endpoints are affected:
GET /fapi/v1/order
GET /fapi/v1/allOrders
- Orders that meet criteria
2020-05-15
- New fields in payloads of
<symbol>@bookTicker
and!bookTicker
:E
for event timeT
for transaction time
2020-05-14
- New field
time
for transaction time in response to endpoints:GET /fapi/v1/ticker/price
GET /fapi/v1/ticker/bookTicker
GET /fapi/v1/openInterest
2020-05-11
- New endpoint
POST /fapi/v1/countdownCancelAll
to cancel all open orders of the specified symbol at the end of the specified countdown.
This rest endpoint means to ensure your open orders are canceled in case of an outage. The endpoint should be called repeatedly as heartbeats so that the existing countdown time can be canceled and repalced by a new one.
2020-05-06
REST
- Endpoint
GET /fapi/v1/leverageBracket
is changed as "USER-DATA". It need to be signed, and timestamp is needed.
WEB SOCKET USER DATA STREAM
- Please notice: event
ACCOUNT_UPDATE
in USER-DATA-STREAM will be pushed with only account balance or relative position when "FUNDING FEE" occurs.- When "FUNDING FEE" occurs in a crossed position,
ACCOUNT_UPDATE
will be pushed with only the balanceB
(including the "FUNDING FEE" asset only), without any positionP
message. - When "FUNDING FEE" occurs in an isolated position,
ACCOUNT_UPDATE
will be pushed with only the balanceB
(including the "FUNDING FEE" asset only) and the relative position messageP
( including the isolated position on which the "FUNDING FEE" occurs only, without any other position message).
- When "FUNDING FEE" occurs in a crossed position,
2020-04-25
New fields in USER DATA STREAM event
ORDER_TRADE_UPDATE
:cp
stands for Close-All conditional orderAP
for Activation Price withTRAILING_STOP_MARKET
ordercr
for Callback Rate withTRAILING_STOP_MARKET
order
New USER DATA STREAM event
MARGIN_CALL
.
2020-04-17
- New parameter
newOrderRespType
for response type in endpointPOST /fapi/v1/order
.
ACK
andRESULT
are supported. And fornewOrderRespType= RESULT
:MARKET
order: the final FILLED result of the order will be return directly.LIMIT
order with specialtimeInForce
: the final status result of the order(FILLED or EXPIRED) will be returned directly.
2020-04-14
WEB SOCKET STREAM
- WebSocket connections have a limit of 10 incoming messages per second. A message is considered:
- A PING frame
- A PONG frame
- A JSON control message (e.g. subscribe, unsubscribe)
- A connection that goes beyond the limit will be disconnected; IPs that are repeatedly disconnected may be banned.
- A single connection can listen to a maximum of 200 streams.
2020-04-09
- New endpoint of futures trading data:
GET /futures/data/takerlongshortRatio
2020-04-08
- New endpoint
GET /fapi/v1/positionSide/dual
to get current position mode. - New endpoint
POST /fapi/v1/batchOrders
to place multiple orders.
2020-04-06
Please notice: event
ACCOUNT_UPDATE
in USER-DATA-STREAM will not be pushed without update of account balances or positions.ACCOUNT_UPDATE
will be pushed only when update happens on user's account, including changes on balances, positions, or margin type.- Unfilled orders or cancelled orders will not make the event
ACCOUNT_UPDATE
pushed, since there's no change on positions. - Only positions of symbols with non-zero isolatd wallet or non-zero position amount will be pushed in the "position" part of the event
ACCOUNT_UPDATE
.
New endpoint
POST /fapi/v1/positionSide/dual
to change position mode: Hedge Mode or One-way Mode.New parameter
positionSide
in the following endpoints:POST /fapi/v1/order
POST /fapi/v1/positionMargin
New field
positionSide
in the responses to the following endpoints:POST /fapi/v1/order
GET /fapi/v1/order
DELETE /fapi/v1/order
DELETE /fapi/v1/batchOrders
GET /fapi/v1/openOrder
GET /fapi/v1/openOrders
GET /fapi/v1/allOrders
GET /fapi/v1/account
GET /fapi/v1/positionMargin/history
GET /fapi/v1/positionRisk
GET /fapi/v1/userTrades
New field
ps
for "position side"in USER_DATA_STREAM eventsACCOUNT_UPDATE
andORDER_TRADE_UPDATE
.
2020-03-30
- New endpoints of futures trading data:
GET /futures/data/openInterestHist
GET /futures/data/topLongShortAccountRatio
GET /futures/data/topLongShortPositionRatio
GET /futures/data/globalLongShortAccountRatio
2020-02-26
- New order type:
TRAILING_STOP_MARKET
2020-02-20
- New endpoint to query specific current open order:
GET /fapi/v1/openOrder
2020-02-17
- Update time changed as 1000ms for streams
<symbol>@ticker
and!ticker@arr
- New diff depth data with 500ms updates:
<symbol>@depth@500ms
- New partial depth data with 500ms updates:
<symbol>@depth<level>@500ms
2020-02-12
New SDK and Code Demonstration on Java
Faster mark price websocket data with 1s updates:
<symbol>@markPrice@1s
and!markPrice@arr@1s
2020-02-05
- New market data endpoint
GET /fapi/v1/leverageBracket
to check notional and leverage brackets.
2020-01-19
- "cumQty" is going to be removed from the responses to
DELETE /fapi/v1/order
,DELETE /fapi/v1/batchOrders
and otherorder
relatived endpoints in the coming weeks.
Please use "executedQty" instead.
2020-01-17
- New SDK and Code Demonstration on Python
2020-01-06
- Faster diff data with real time updates:
<symbol>@depth@0ms
2020-01-03
New endpoints related to isolated position:
POST /fapi/v1/marginType
POST /fapi/v1/positionMargin
GET /fapi/v1/positionMargin/history
New field in response to
GET /fapi/v1/positionRisk
related to isolated position:marginType
isolatedMargin
New field in response to
GET /fapi/v1/account
related to isolated position:isolated
New field in event
ACCOUNT_UPDATE
:- "cw" for cross wallet
- "mt" for margin type
- "iw" for isolated wallet (if isolated)
2019-12-19
- New endpoint
GET /fapi/v1/openInterest
to get present open interest of a specific symbol.
2019-12-18
- New event type in user data stream:
listenKeyExpired
.
2019-12-12
- New endpoint
DELETE /fapi/v1/allOpenOrders
to cancel all open orders of a specific symbol. - New endpoint
DELETE /fapi/v1/batchOrders
to cancel a list of open orders. reduceOnly
has been supported in orders with type:-
TAKE_PROFIT
-
TAKE_PROFIT_MARKET
-
STOP
-
STOP_MARKET
-
2019-11-29
- New endpoint
GET /fapi/v1/allForceOrders
to get all liquidation orders. - New websocket streams:
<symbol>@forceOrder
for liquidation order streams!forceOrder@arr
for all market liquidation order streams
2019-11-25
GET /fapi/v1/account
has new field:positions
- Added new field
time
for order creation time in:GET /fapi/v1/openOrders
GET /fapi/v1/order
GET /fapi/v1/allOrders
2019-11-15
- New websocket streams:
!miniTicker@arr
: All market 24hr mini-tickers stream.-
!ticker@arr
: : All market 24hr tickers stream.
2019-11-12
- WSS now supports live subscribing/unsubscribing to streams.
2019-11-05
- New order type:
STOP_MARKET
,TAKE_PROFIT_MARKET
.
- New parameter
workingType
inPOST /fapi/v1/order
:
order with stop price can be triggered by "CONTRACT_PRICE" or "MARK_PRICE" - New keys in USER-DATA-STREAMS:
- in
ORDER_TRADE_UPDATE
:- "T" as transaction time
- "wt" as workingType
- in
ACCOUNT_UPDATE
:- "T" as transaction time
- in
2019-10-28
- New rest endpoint for income flow history
GET /fapi/v1/income
2019-10-25
- Added "up" in event
ACCOUNT_UPDATE
in user data stream: the unrealized PnL of the position. - Added "R" in event
ORDER_TRADE_UPDATE
in user data stream, showing if the trade is reduce only.
2019-10-24
- New WebSocket streams for booktickers added:
<symbol>@bookTicker
and!bookTicker
. - New WebSocket streams for partial orderbook added:
<symbol>@depth<levels>
and<symbol>@depth<levels>@100ms
- Faster diff data with 100ms updates:
<symbol>@depth@100ms
- Added
Update Speed
: toWebsocket Market Streams
2019-10-18
- New endpoint
POST /fapi/v1/leverage
for changing user's initial leverage in specific symbol market. - Added "leverage" for current initial leverage and "maxNotionalValue" for notional value limit of current initial leverage in response to
GET /fapi/v1/positionRisk
. reduceOnly
now is supported in theMARKET
orders.
2019-10-14
- Added
GET /fapi/v1/fundingRate
for getting funding fee rate history.
2019-10-11
- Added "m" in event
ORDER_TRADE_UPDATE
in user data stream, showing if the trade is the maker side.
2019-10-08
- New order parameter
reduceOnly
forLIMIT
orders. - New order type
TAKE_PROFIT
.
2019-09-20
New retured values in response to GET /fapi/v1/account:
maxWithdrawAmount
,openOrderInitialMargin
,positionInitialMargin
New retured values in response to GET /fapi/v1/positionRisk:
liquidationPrice
General Info
testnet
- Most of the endpoints can be used in the testnet platform.
- The REST baseurl for testnet is "https://testnet.binancefuture.com"
- The Websocket baseurl for testnet is "wss://fstream.binancefuture.com"
SDK and Code Demonstration
Disclaimer:
- The following SDKs are provided by partners and users, and are not officially produced. They are only used to help users become familiar with the API endpoint. Please use it with caution and expand R&D according to your own situation.
- Binance does not make any commitment to the safety and performance of the SDKs, nor will be liable for the risks or even losses caused by using the SDKs.
Python3
SDK:
To get the provided SDK for Binance Futures Connector,
please visit https://github.com/binance/binance-futures-connector-python,
or use the command below:
pip install binance-futures-connector
Java
To get the provided SDK for Binance Futures,
please visit https://github.com/binance/binance-futures-connector-java,
or use the command below:
git clone https://github.com/binance/binance-futures-connector-java.git
General API Information
- Some endpoints will require an API Key. Please refer to this page
- The base endpoint is: https://fapi.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.
- All data types adopt definition in JAVA.
HTTP Return Codes
- HTTP
4XX
return codes are used for for malformed requests; the issue is on the sender's side. - HTTP
403
return code is used when the WAF Limit (Web Application Firewall) has been violated. - HTTP
408
return code is used when a timeout has occurred while waiting for a response from the backend server. - HTTP
429
return code is used when breaking a request rate limit. - HTTP
418
return code is used when an IP has been auto-banned for continuing to send requests after receiving429
codes. - HTTP
5XX
return codes are used for internal errors; the issue is on Binance's side.- If there is an error message "Request occur unknown error.", please retry later.
- HTTP
503
return code is used when:- If there is an error message "Unknown error, please check your request or try again later." returned in the response, the API successfully sent the request but not get a response within the timeout period.
It is important to NOT treat this as a failure operation; the execution status is UNKNOWN and could have been a success; - If there is an error message "Service Unavailable." returned in the response, it means this is a failure API operation and the service might be unavailable at the moment, you need to retry later.
- If there is an error message "Internal error; unable to process your request. Please try again." returned in the response, it means this is a failure API operation and you can resend your request if you need.
- If there is an error message "Server is currently overloaded with other requests. Please try again in a few minutes." returned in the response, it means this is a failure API operation and you can resend your request if you need.
- If there is an error message "Unknown error, please check your request or try again later." returned in the response, the API successfully sent the request but not get a response within the timeout period.
Error Codes and Messages
- Any endpoint can return an ERROR
The error payload is as follows:
{
"code": -1121,
"msg": "Invalid symbol."
}
- Specific error codes and messages defined in Error Codes.
General Information on Endpoints
- For
GET
endpoints, parameters must be sent as aquery string
. - For
POST
,PUT
, andDELETE
endpoints, the parameters may be sent as aquery string
or in therequest body
with content typeapplication/x-www-form-urlencoded
. You may mix parameters between both thequery string
andrequest body
if you wish to do so. - Parameters may be sent in any order.
- If a parameter sent in both the
query string
andrequest body
, thequery string
parameter will be used.
LIMITS
- The
/fapi/v1/exchangeInfo
rateLimits
array contains objects related to the exchange'sRAW_REQUEST
,REQUEST_WEIGHT
, andORDER
rate limits. These are further defined in theENUM definitions
section 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
weight
which 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.
- The limits on the API are based on the IPs, not the API keys.
Order Rate Limits
- Every order response will contain a
X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter)
header which has the current order count for the account 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.
- API-keys are passed into the Rest API via the
X-MBX-APIKEY
header. - 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. |
TRADE
andUSER_DATA
endpoints areSIGNED
endpoints.
SIGNED (TRADE and USER_DATA) Endpoint Security
SIGNED
endpoints require an additional parameter,signature
, to be sent in thequery string
orrequest body
.- Endpoints use
HMAC SHA256
signatures. TheHMAC SHA256 signature
is a keyedHMAC SHA256
operation. Use yoursecretKey
as the key andtotalParams
as the value for the HMAC operation. - The
signature
is not case sensitive. - Please make sure the
signature
is the end part of yourquery string
orrequest body
. totalParams
is defined as thequery string
concatenated with therequest body
.
Timing Security
- A
SIGNED
endpoint 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 aftertimestamp
the request is valid for. IfrecvWindow
is 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.
SIGNED Endpoint Examples for POST /fapi/v1/order - HMAC Keys
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 | dbefbc809e3e83c283a984c3a1459732ea7db1360ca80c5c2c8867408d28cc83 |
secretKey | 2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9 |
Parameter | Value |
---|---|
symbol | BTCUSDT |
side | BUY |
type | LIMIT |
timeInForce | GTC |
quantity | 1 |
price | 9000 |
recvWindow | 5000 |
timestamp | 1591702613943 |
Example 1: As a query string
Example 1
HMAC SHA256 signature:
$ echo -n "symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=1&price=9000&timeInForce=GTC&recvWindow=5000×tamp=1591702613943" | openssl dgst -sha256 -hmac "2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9"
(stdin)= 3c661234138461fcc7a7d8746c6558c9842d4e10870d2ecbedf7777cad694af9
curl command:
$ curl -H "X-MBX-APIKEY: dbefbc809e3e83c283a984c3a1459732ea7db1360ca80c5c2c8867408d28cc83" -X POST 'https://fapi/binance.com/fapi/v1/order?symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=1&price=9000&timeInForce=GTC&recvWindow=5000×tamp=1591702613943&signature= 3c661234138461fcc7a7d8746c6558c9842d4e10870d2ecbedf7777cad694af9'
queryString:
symbol=BTCUSDT
&side=BUY
&type=LIMIT
&timeInForce=GTC
&quantity=1
&price=9000
&recvWindow=5000
×tamp=1591702613943
Example 2: As a request body
Example 2
HMAC SHA256 signature:
$ echo -n "symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=1&price=9000&timeInForce=GTC&recvWindow=5000×tamp=1591702613943" | openssl dgst -sha256 -hmac "2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9"
(stdin)= 3c661234138461fcc7a7d8746c6558c9842d4e10870d2ecbedf7777cad694af9
curl command:
$ curl -H "X-MBX-APIKEY: dbefbc809e3e83c283a984c3a1459732ea7db1360ca80c5c2c8867408d28cc83" -X POST 'https://fapi/binance.com/fapi/v1/order' -d 'symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=1&price=9000&timeInForce=GTC&recvWindow=5000×tamp=1591702613943&signature= 3c661234138461fcc7a7d8746c6558c9842d4e10870d2ecbedf7777cad694af9'
requestBody:
symbol=BTCUSDT
&side=BUY
&type=LIMIT
&timeInForce=GTC
&quantity=1
&price=9000
&recvWindow=5000
×tamp=1591702613943
Example 3: Mixed query string and request body
Example 3
HMAC SHA256 signature:
$ echo -n "symbol=BTCUSDT&side=BUY&type=LIMIT&timeInForce=GTCquantity=1&price=9000&recvWindow=5000×tamp= 1591702613943" | openssl dgst -sha256 -hmac "2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9"
(stdin)= f9d0ae5e813ef6ccf15c2b5a434047a0181cb5a342b903b367ca6d27a66e36f2
curl command:
$ curl -H "X-MBX-APIKEY: dbefbc809e3e83c283a984c3a1459732ea7db1360ca80c5c2c8867408d28cc83" -X POST 'https://fapi.binance.com/fapi/v1/order?symbol=BTCUSDT&side=BUY&type=LIMIT&timeInForce=GTC' -d 'quantity=1&price=9000&recvWindow=5000×tamp=1591702613943&signature=f9d0ae5e813ef6ccf15c2b5a434047a0181cb5a342b903b367ca6d27a66e36f2'
- queryString: symbol=BTCUSDT&side=BUY&type=LIMIT&timeInForce=GTC
- requestBody: quantity=1&price=9000&recvWindow=5000×tamp= 1591702613943
Note that the signature is different in example 3.
There is no & between "GTC" and "quantity=1".
SIGNED Endpoint Examples for POST /fapi/v1/order - RSA Keys
- This will be a step by step process how to create the signature payload to send a valid signed payload.
- We support
PKCS#8
currently. - To get your API key, you need to upload your RSA Public Key to your account and a corresponding API key will be provided for you.
For this example, the private key will be referenced as test-prv-key.pem
Key | Value |
---|---|
apiKey | vE3BDAL1gP1UaexugRLtteaAHg3UO8Nza20uexEuW1Kh3tVwQfFHdAiyjjY428o2 |
Parameter | Value |
---|---|
symbol | BTCUSDT |
side | SELL |
type | MARKET |
quantity | 1.23 |
recvWindow | 9999999 |
timestamp | 1671090801999 |
Signature payload (with the listed parameters):
timestamp=1671090801999&recvWindow=9999999&symbol=BTCUSDT&side=SELL&type=MARKET&quantity=1.23
Step 1: Construct the payload
Arrange the list of parameters into a string. Separate each parameter with a &
.
Step 2: Compute the signature:
2.1 - Encode signature payload as ASCII data.
Step 2.2
$ echo -n 'timestamp=1671090801999&recvWindow=9999999&symbol=BTCUSDT&side=SELL&type=MARKET&quantity=1.23' | openssl dgst -keyform PEM -sha256 -sign ./test-prv-key.pem
2.2 - Sign payload using RSASSA-PKCS1-v1_5 algorithm with SHA-256 hash function.
Step 2.3
$ echo -n 'timestamp=1671090801999&recvWindow=9999999&symbol=BTCUSDT&side=SELL&type=MARKET&quantity=1.23' | openssl dgst -keyform PEM -sha256 -sign ./test-prv-key.pem | openssl enc -base64
aap36wD5loVXizxvvPI3wz9Cjqwmb3KVbxoym0XeWG1jZq8umqrnSk8H8dkLQeySjgVY91Ufs%2BBGCW%2B4sZjQEpgAfjM76riNxjlD3coGGEsPsT2lG39R%2F1q72zpDs8pYcQ4A692NgHO1zXcgScTGgdkjp%2Brp2bcddKjyz5XBrBM%3D
2.3 - Encode output as base64 string.
Step 2.4
$ echo -n 'timestamp=1671090801999&recvWindow=9999999&symbol=BTCUSDT&side=SELL&type=MARKET&quantity=1.23' | openssl dgst -keyform PEM -sha256 -sign ./test-prv-key.pem | openssl enc -base64 | tr -d '\n'
aap36wD5loVXizxvvPI3wz9Cjqwmb3KVbxoym0XeWG1jZq8umqrnSk8H8dkLQeySjgVY91Ufs%2BBGCW%2B4sZjQEpgAfjM76riNxjlD3coGGEsPsT2lG39R%2F1q72zpDs8pYcQ4A692NgHO1zXcgScTGgdkjp%2Brp2bcddKjyz5XBrBM%3D
2.4 - Delete any newlines in the signature.
Step 2.5
aap36wD5loVXizxvvPI3wz9Cjqwmb3KVbxoym0XeWG1jZq8umqrnSk8H8dkLQeySjgVY91Ufs%2BBGCW%2B4sZjQEpgAfjM76riNxjlD3coGGEsPsT2lG39R%2F1q72zpDs8pYcQ4A692NgHO1zXcgScTGgdkjp%2Brp2bcddKjyz5XBrBM%3D
2.5 - Since the signature may contain /
and =
, this could cause issues with sending the request. So the signature has to be URL encoded.
Step 2.6
curl -H "X-MBX-APIKEY: vE3BDAL1gP1UaexugRLtteaAHg3UO8Nza20uexEuW1Kh3tVwQfFHdAiyjjY428o2" -X POST 'https://fapi.binance.com/fapi/v1/order?timestamp=1671090801999&recvWindow=9999999&symbol=BTCUSDT&side=SELL&type=MARKET&quantity=1.23&signature=aap36wD5loVXizxvvPI3wz9Cjqwmb3KVbxoym0XeWG1jZq8umqrnSk8H8dkLQeySjgVY91Ufs%2BBGCW%2B4sZjQEpgAfjM76riNxjlD3coGGEsPsT2lG39R%2F1q72zpDs8pYcQ4A692NgHO1zXcgScTGgdkjp%2Brp2bcddKjyz5XBrBM%3D'
2.6 - curl command
Bash script
#!/usr/bin/env bash
# Set up authentication:
apiKey="vE3BDAL1gP1UaexugRLtteaAHg3UO8Nza20uexEuW1Kh3tVwQfFHdAiyjjY428o2" ### REPLACE THIS WITH YOUR API KEY
# Set up the request:
apiMethod="POST"
apiCall="v1/order"
apiParams="timestamp=1671090801999&recvWindow=9999999&symbol=BTCUSDT&side=SELL&type=MARKET&quantity=1.23"
function rawurlencode {
local value="$1"
local len=${#value}
local encoded=""
local pos c o
for (( pos=0 ; pos<len ; pos++ ))
do
c=${value:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="$o"
done
echo "$encoded"
}
ts=$(date +%s000)
paramsWithTs="$apiParams×tamp=$ts"
rawSignature=$(echo -n "$paramsWithTs" \
| openssl dgst -keyform PEM -sha256 -sign ./test-prv-key.pem \ ### THIS IS YOUR PRIVATE KEY. DO NOT SHARE THIS FILE WITH ANYONE.
| openssl enc -base64 \
| tr -d '\n')
signature=$(rawurlencode "$rawSignature")
curl -H "X-MBX-APIKEY: $apiKey" -X $apiMethod \
"https://fapi.binance.com/fapi/$apiCall?$paramsWithTs&signature=$signature"
A sample Bash script containing similar steps is available in the right side.
Public Endpoints Info
Terminology
base asset
refers to the asset that is thequantity
of a symbol.quote asset
refers to the asset that is theprice
of a symbol.
ENUM definitions
Symbol type:
- FUTURE
Contract type (contractType):
- PERPETUAL
- CURRENT_MONTH
- NEXT_MONTH
- CURRENT_QUARTER
- NEXT_QUARTER
- PERPETUAL_DELIVERING
Contract status(contractStatus,status):
- PENDING_TRADING
- TRADING
- PRE_DELIVERING
- DELIVERING
- DELIVERED
- PRE_SETTLE
- SETTLING
- CLOSE
Order status (status):
- NEW
- PARTIALLY_FILLED
- FILLED
- CANCELED
- REJECTED
- EXPIRED
- EXPIRED_IN_MATCH
Order types (orderTypes, type):
- LIMIT
- MARKET
- STOP
- STOP_MARKET
- TAKE_PROFIT
- TAKE_PROFIT_MARKET
- TRAILING_STOP_MARKET
Order side (side):
- BUY
- SELL
Position side (positionSide):
- BOTH
- LONG
- SHORT
Time in force (timeInForce):
- GTC - Good Till Cancel(GTC order valitidy is 1 year from placement)
- IOC - Immediate or Cancel
- FOK - Fill or Kill
- GTX - Good Till Crossing (Post Only)
- GTD - Good Till Date
Working Type (workingType)
- MARK_PRICE
- CONTRACT_PRICE
Response Type (newOrderRespType)
- ACK
- RESULT
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
STP MODE:
- NONE
- EXPIRE_TAKER
- EXPIRE_BOTH
- EXPIRE_MAKER
Price Match:
- NONE (No price match)
- OPPONENT (counterparty best price)
- OPPONENT_5 (the 5th best price from the counterparty)
- OPPONENT_10 (the 10th best price from the counterparty)
- OPPONENT_20 (the 20th best price from the counterparty)
- QUEUE (the best price on the same side of the order book)
- QUEUE_5 (the 5th best price on the same side of the order book)
- QUEUE_10 (the 10th best price on the same side of the order book)
- QUEUE_20 (the 20th best price on the same side of the order book)
Rate limiters (rateLimitType)
REQUEST_WEIGHT
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400
}
ORDERS
{
"rateLimitType": "ORDERS",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200
}
REQUEST_WEIGHT
ORDERS
Rate limit intervals (interval)
- MINUTE
Filters
Filters define trading rules on a symbol or an exchange.
Symbol filters
PRICE_FILTER
/exchangeInfo format:
{
"filterType": "PRICE_FILTER",
"minPrice": "0.00000100",
"maxPrice": "100000.00000000",
"tickSize": "0.00000100"
}
The PRICE_FILTER
defines the price
rules for a symbol. There are 3 parts:
minPrice
defines the minimumprice
/stopPrice
allowed; disabled onminPrice
== 0.maxPrice
defines the maximumprice
/stopPrice
allowed; disabled onmaxPrice
== 0.tickSize
defines the intervals that aprice
/stopPrice
can 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
>=minPrice
price
<=maxPrice
- (
price
-minPrice
) %tickSize
== 0
LOT_SIZE
/exchangeInfo format:
{
"filterType": "LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
}
The LOT_SIZE
filter defines the quantity
(aka "lots" in auction terms) rules for a symbol. There are 3 parts:
minQty
defines the minimumquantity
allowed.maxQty
defines the maximumquantity
allowed.stepSize
defines the intervals that aquantity
can be increased/decreased by.
In order to pass the lot size
, the following must be true for quantity
:
quantity
>=minQty
quantity
<=maxQty
- (
quantity
-minQty
) %stepSize
== 0
MARKET_LOT_SIZE
/exchangeInfo format:
{
"filterType": "MARKET_LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
}
The MARKET_LOT_SIZE
filter defines the quantity
(aka "lots" in auction terms) rules for MARKET
orders on a symbol. There are 3 parts:
minQty
defines the minimumquantity
allowed.maxQty
defines the maximumquantity
allowed.stepSize
defines the intervals that aquantity
can be increased/decreased by.
In order to pass the market lot size
, the following must be true for quantity
:
quantity
>=minQty
quantity
<=maxQty
- (
quantity
-minQty
) %stepSize
== 0
MAX_NUM_ORDERS
/exchangeInfo format:
{
"filterType": "MAX_NUM_ORDERS",
"limit": 200
}
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.
MAX_NUM_ALGO_ORDERS
/exchangeInfo format:
{
"filterType": "MAX_NUM_ALGO_ORDERS",
"limit": 100
}
The MAX_NUM_ALGO_ORDERS
filter defines the maximum number of all kinds of algo orders an account is allowed to have open on a symbol.
The algo orders include STOP
, STOP_MARKET
, TAKE_PROFIT
, TAKE_PROFIT_MARKET
, and TRAILING_STOP_MARKET
orders.
PERCENT_PRICE
/exchangeInfo format:
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "1.1500",
"multiplierDown": "0.8500",
"multiplierDecimal": 4
}
The PERCENT_PRICE
filter defines valid range for a price based on the mark price.
In order to pass the percent price
, the following must be true for price
:
- BUY:
price
<=markPrice
*multiplierUp
- SELL:
price
>=markPrice
*multiplierDown
MIN_NOTIONAL
/exchangeInfo format:
{
"filterType": "MIN_NOTIONAL",
"notional": "5.0"
}
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
.
Since MARKET
orders have no price, the mark price is used.
Postman Collections
There is now a Postman collection containing the API endpoints for quick and easy use.
For more information please refer to this page: Binance API Postman
WebSocket API General Info
- The base endpoint is:
wss://ws-fapi.binance.com/ws-fapi/v1
- The base endpoint for testnet is:
wss://testnet.binancefuture.com/ws-fapi/v1
- The base endpoint for testnet is:
- A single connection to the API is only valid for 24 hours; expect to be disconnected after the 24-hour mark.
- Websocket server will send a ping frame every 3 minutes.
- If the websocket server does not receive a
pong frame
back from the connection within a 10 minute period, the connection will be disconnected. - When you receive a ping, you must send a pong with a copy of ping's payload as soon as possible.
- Unsolicited pong frames are allowed, but will not prevent disconnection. It is recommended that the payload for these pong frames are empty.
- If the websocket server does not receive a
- Signature payload must be generated by taking all request params except for the signature and sorting them by name in alphabetical order.
- Lists are returned in chronological order, unless noted otherwise.
- All timestamps are in milliseconds in UTC, unless noted otherwise.
- All field names and values are case-sensitive, unless noted otherwise.
INT
parameters such as timestamp are expected as JSON integers, not strings.DECIMAL
parameters such as price are expected as JSON strings, not floats.- User Data Stream requests - you will need to establish a separate WebSocket connection to listen to user data streams
WebSocket API Request format
Requests must be sent as JSON in text frames, one request per frame.
Example of request:
{
"id": "9ca10e58-7452-467e-9454-f669bb9c764e",
"method": "order.place",
"params": {
"apiKey": "yeqKcXjtA9Eu4Tr3nJk61UJAGzXsEmFqqfVterxpMpR4peNfqE7Zl7oans8Qj089",
"price": "42088.0",
"quantity": "0.1",
"recvWindow": 5000,
"side": "BUY",
"signature": "996962a19802b5a09d7bc6ab1524227894533322a2f8a1f8934991689cabf8fe",
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"timestamp": 1705311512994,
"type": "LIMIT"
}
}
Request fields:
Name | Type | Mandatory | Description |
---|---|---|---|
id |
INT/STRING/null | YES | Arbitrary ID used to match responses to requests |
method |
STRING | YES | Request method name |
params |
OBJECT | NO | Request parameters. May be omitted if there are no parameters |
* Request id
is truly arbitrary. You can use UUIDs, sequential IDs, current timestamp, etc. The server does not interpret id
in any way, simply echoing it back in the response.
You can freely reuse IDs within a session. However, be careful to not send more than one request at a time with the same ID, since otherwise it might be impossible to tell the responses apart.
* Request method names may be prefixed with explicit version: e.g., "v3/order.place
".
* The order of params
is not significant.
Response format
Responses are returned as JSON in text frames, one response per frame.
Example of successful response:
{
"id": "43a3843a-2321-4e45-8f79-351e5c354563",
"status": 200,
"result": {
"orderId": 336829446,
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "FqEw6cn0vDhrkmfiwLYPeo",
"price": "42088.00",
"avgPrice": "0.00",
"origQty": "0.100",
"executedQty": "0.000",
"cumQty": "0.000",
"cumQuote": "0.00000",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "BOTH",
"stopPrice": "0.00",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"priceMatch": "NONE",
"selfTradePreventionMode": "NONE",
"goodTillDate": 0,
"updateTime": 1705385954229
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 300,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200,
"count": 0
}
]
}
Example of failed response:
{
"id": "5761b939-27b1-4948-ab87-4a372a3f6b72",
"status": 400,
"error": {
"code": -1102,
"msg": "Mandatory parameter 'quantity' was not sent, was empty/null, or malformed."
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 300,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200,
"count": 1
}
]
}
Response fields:
Name | Type | Mandatory | Description |
---|---|---|---|
id |
INT/STRING/null | YES | Same as in the original request |
status |
INT | YES | Response status. See status codes |
result |
OBJECT/ARRAY | YES | Response content. Present if request succeeded |
error |
OBJECT | YES | Error description. Present if request failed |
rateLimits |
ARRAY | NO | Rate limiting status. See Rate limits |
WebSocket API Rate limits
- Rate limits are the same as on REST API and are shared with REST API.
- WebSocket handshake attempt costs 5 weight.
- Rate limit for ping/pong frames: maximum 5 per second.
- Rate limit information is included in responses by default, see the
rateLimits
field. rateLimits
field visibility can be controlled withreturnRateLimits
boolean parameter in connection string or individual requests.- E.g., use
wss://ws-fapi.binance.com/ws-fapi/v1?returnRateLimits=false
to hiderateLimits
in responses by default. With that, you can pass extra"returnRateLimits": true
parameter in requests to show rate limit in response when it is otherwise hidden by default.
WebSocket API Authenticate after connection
You can authenticate an already established connection using session authentication requests:
* session.logon
- authenticate, or change the API key associated with the connection
* session.status
- check connection status and the current API key
* session.logout
- forget the API key associated with the connection
WebSocket API API key revocation
If during an active session the API key becomes invalid for any reason (e.g. IP address is not whitelisted, API key was deleted, API key doesn't have correct permissions, etc), after the next request the session will be revoked with the following error message:
{
"id": null,
"status": 401,
"error": {
"code": -2015,
"msg": "Invalid API-key, IP, or permissions for action."
}
}
WebSocket API Authorize ad hoc requests
Only one API key can be authenticated with the WebSocket connection. The authenticated API key is used by default for requests that require an apiKey parameter. However, you can always specify the apiKey and signature explicitly for individual requests, overriding the authenticated API key and using a different one to authorize a specific request.
For example, you might want to authenticate your USER_DATA key to be used by default, but specify the TRADE key with an explicit signature when placing orders.
WebSocket API Authentication request
Note: Only Ed25519 keys are supported for this feature.
Log in with API key (SIGNED)
Request
{
"id": "c174a2b1-3f51-4580-b200-8528bd237cb7",
"method": "session.logon",
"params": {
"apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A",
"signature": "1cf54395b336b0a9727ef27d5d98987962bc47aca6e13fe978612d0adee066ed",
"timestamp": 1649729878532
}
}
Response
{
"id": "c174a2b1-3f51-4580-b200-8528bd237cb7",
"status": 200,
"result": {
"apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A",
"authorizedSince": 1649729878532,
"connectedSince": 1649729873021,
"returnRateLimits": false,
"serverTime": 1649729878630
}
}
Authenticate WebSocket connection using the provided API key.
After calling session.logon
, you can omit apiKey
and signature
parameters for future requests that require them.
Note that only one API key can be authenticated. Calling session.logon
multiple times changes the current authenticated API key.
Weight: 2
Method: "session.logon"
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
apiKey |
STRING | YES | |
recvWindow |
INT | NO | |
signature |
STRING | YES | |
timestamp |
INT | YES |
Query session status
Request
{
"id": "b50c16cd-62c9-4e29-89e4-37f10111f5bf",
"method": "session.status"
}
Response
{
"id": "b50c16cd-62c9-4e29-89e4-37f10111f5bf",
"status": 200,
"result": {
// if the connection is not authenticated, "apiKey" and "authorizedSince" will be shown as null
"apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A",
"authorizedSince": 1649729878532,
"connectedSince": 1649729873021,
"returnRateLimits": false,
"serverTime": 1649730611671
}
}
Query the status of the WebSocket connection, inspecting which API key (if any) is used to authorize requests.
Weight: 2
Method: "session.status"
Parameters: None
Log out of the session
Request
{
"id": "c174a2b1-3f51-4580-b200-8528bd237cb7",
"method": "session.logout"
}
Response
{
"id": "c174a2b1-3f51-4580-b200-8528bd237cb7",
"status": 200,
"result": {
"apiKey": null,
"authorizedSince": null,
"connectedSince": 1649729873021,
"returnRateLimits": false,
"serverTime": 1649730611671
}
}
Forget the API key previously authenticated. If the connection is not authenticated, this request does nothing.
Note that the WebSocket connection stays open after session.logout
request. You can continue using the connection, but now you will have to explicitly provide the apiKey
and signature
parameters where needed.
Weight: 2
Method: "session.logout"
Parameters: None
SIGNED (TRADE and USER_DATA) Endpoint Security
SIGNED request example (Ed25519)
Parameter | Value |
---|---|
symbol | BTCUSDT |
side | SELL |
type | LIMIT |
timeInForce | GTC |
quantity | 1 |
price | 0.2 |
timestamp | 1668481559918 |
#!/usr/bin/env python3
import base64
import time
import json
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from websocket import create_connection
# Set up authentication
API_KEY='put your own API Key here'
PRIVATE_KEY_PATH='test-prv-key.pem'
# Load the private key.
# In this example the key is expected to be stored without encryption,
# but we recommend using a strong password for improved security.
with open(PRIVATE_KEY_PATH, 'rb') as f:
private_key = load_pem_private_key(data=f.read(),
password=None)
# Set up the request parameters
params = {
'apiKey': API_KEY,
'symbol': 'BTCUSDT',
'side': 'SELL',
'type': 'LIMIT',
'timeInForce': 'GTC',
'quantity': '1.0000000',
'price': '0.20'
}
# Timestamp the request
timestamp = int(time.time() * 1000) # UNIX timestamp in milliseconds
params['timestamp'] = timestamp
# Sign the request
payload = '&'.join([f'{param}={value}' for param, value in sorted(params.items())])
signature = base64.b64encode(private_key.sign(payload.encode('ASCII')))
params['signature'] = signature.decode('ASCII')
# Send the request
request = {
'id': 'my_new_order',
'method': 'order.place',
'params': params
}
ws = create_connection("wss://ws-fapi.binance.com/ws-fapi/v1")
ws.send(json.dumps(request))
result = ws.recv()
ws.close()
print(result)
A sample code in Python to show how to sign the payload with an Ed25519 key is available on the right side.
Market Data Endpoints
Test Connectivity
Response:
{}
GET /fapi/v1/ping
Test connectivity to the Rest API.
Weight: 1
Parameters: NONE
Check Server Time
Response:
{
"serverTime": 1499827319559
}
GET /fapi/v1/time
Test connectivity to the Rest API and get the current server time.
Weight: 1
Parameters: NONE
Exchange Information
Response:
{
"exchangeFilters": [],
"rateLimits": [
{
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"rateLimitType": "REQUEST_WEIGHT"
},
{
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200,
"rateLimitType": "ORDERS"
}
],
"serverTime": 1565613908500, // Ignore please. If you want to check current server time, please check via "GET /fapi/v1/time"
"assets": [ // assets information
{
"asset": "BUSD",
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"autoAssetExchange": 0 // only valid for vip2-9 users
},
{
"asset": "USDT",
"marginAvailable": true,
"autoAssetExchange": 0 //only valid for vip2-9 users
},
{
"asset": "BNB",
"marginAvailable": false,
"autoAssetExchange": null
}
],
"symbols": [
{
"symbol": "BLZUSDT",
"pair": "BLZUSDT",
"contractType": "PERPETUAL",
"deliveryDate": 4133404800000,
"onboardDate": 1598252400000,
"status": "TRADING",
"maintMarginPercent": "2.5000", // ignore
"requiredMarginPercent": "5.0000", // ignore
"baseAsset": "BLZ",
"quoteAsset": "USDT",
"marginAsset": "USDT",
"pricePrecision": 5, // please do not use it as tickSize
"quantityPrecision": 0, // please do not use it as stepSize
"baseAssetPrecision": 8,
"quotePrecision": 8,
"underlyingType": "COIN",
"underlyingSubType": ["STORAGE"],
"settlePlan": 0,
"triggerProtect": "0.15", // threshold for algo order with "priceProtect"
"filters": [
{
"filterType": "PRICE_FILTER",
"maxPrice": "300",
"minPrice": "0.0001",
"tickSize": "0.0001"
},
{
"filterType": "LOT_SIZE",
"maxQty": "10000000",
"minQty": "1",
"stepSize": "1"
},
{
"filterType": "MARKET_LOT_SIZE",
"maxQty": "590119",
"minQty": "1",
"stepSize": "1"
},
{
"filterType": "MAX_NUM_ORDERS",
"limit": 200
},
{
"filterType": "MAX_NUM_ALGO_ORDERS",
"limit": 100
},
{
"filterType": "MIN_NOTIONAL",
"notional": "5.0",
},
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "1.1500",
"multiplierDown": "0.8500",
"multiplierDecimal": 4
}
],
"OrderType": [
"LIMIT",
"MARKET",
"STOP",
"STOP_MARKET",
"TAKE_PROFIT",
"TAKE_PROFIT_MARKET",
"TRAILING_STOP_MARKET"
],
"timeInForce": [
"GTC",
"IOC",
"FOK",
"GTX"
],
"liquidationFee": "0.010000", // liquidation fee rate
"marketTakeBound": "0.30", // the max price difference rate( from mark price) a market order can make
}
],
"timezone": "UTC"
}
GET /fapi/v1/exchangeInfo
Current exchange trading rules and symbol information
Weight: 1
Parameters: NONE
Order Book
Response:
{
"lastUpdateId": 1027024,
"E": 1589436922972, // Message output time
"T": 1589436922959, // Transaction time
"bids": [
[
"4.00000000", // PRICE
"431.00000000" // QTY
]
],
"asks": [
[
"4.00000200",
"12.00000000"
]
]
}
GET /fapi/v1/depth
Weight:
Adjusted based on the limit:
Limit | Weight |
---|---|
5, 10, 20, 50 | 2 |
100 | 5 |
500 | 10 |
1000 | 20 |
Update Speed: 15ms
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
limit | INT | NO | Default 500; Valid limits:[5, 10, 20, 50, 100, 500, 1000] |
Recent Trades List
Response:
[
{
"id": 28457,
"price": "4.00000100",
"qty": "12.00000000",
"quoteQty": "48.00",
"time": 1499865549590,
"isBuyerMaker": true,
}
]
GET /fapi/v1/trades
Get recent market trades
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
limit | INT | NO | Default 500; max 1000. |
- Market trades means trades filled in the order book. Only market trades will be returned, which means the insurance fund trades and ADL trades won't be returned.
Old Trades Lookup (MARKET_DATA)
Response:
[
{
"id": 28457,
"price": "4.00000100",
"qty": "12.00000000",
"quoteQty": "8000.00",
"time": 1499865549590,
"isBuyerMaker": true,
}
]
GET /fapi/v1/historicalTrades
Get older market historical trades.
Weight: 20
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. |
- Market trades means trades filled in the order book. Only market trades will be returned, which means the insurance fund trades and ADL trades won't be returned.
- Only supports returning data from the last three months (the earliest available time is currently 2023-11-21 00:00:00).
Compressed/Aggregate Trades List
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?
}
]
GET /fapi/v1/aggTrades
Get compressed, aggregate market trades. Market trades that fill in 100ms with the same price and the same taking side will have the quantity aggregated.
Weight: 20
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
andendTime
are sent, time betweenstartTime
andendTime
must be less than 1 hour. - If
fromId
,startTime
, andendTime
are not sent, the most recent aggregate trades will be returned. - Only market trades will be aggregated and returned, which means the insurance fund trades and ADL trades won't be aggregated.
- Sending both
startTime
/endTime
andfromId
might cause response timeout, please send eitherfromId
orstartTime
/endTime
Kline/Candlestick Data
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.
]
]
GET /fapi/v1/klines
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
Weight: based on parameter LIMIT
LIMIT | weight |
---|---|
[1,100) | 1 |
[100, 500) | 2 |
[500, 1000] | 5 |
> 1000 | 10 |
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
interval | ENUM | YES | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1500. |
- If startTime and endTime are not sent, the most recent klines are returned.
Continuous Contract Kline/Candlestick Data
Response:
[
[
1607444700000, // Open time
"18879.99", // Open
"18900.00", // High
"18878.98", // Low
"18896.13", // Close (or latest price)
"492.363", // Volume
1607444759999, // Close time
"9302145.66080", // Quote asset volume
1874, // Number of trades
"385.983", // Taker buy volume
"7292402.33267", // Taker buy quote asset volume
"0" // Ignore.
]
]
GET /fapi/v1/continuousKlines
Kline/candlestick bars for a specific contract type.
Klines are uniquely identified by their open time.
Weight: based on parameter LIMIT
LIMIT | weight |
---|---|
[1,100) | 1 |
[100, 500) | 2 |
[500, 1000] | 5 |
> 1000 | 10 |
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | STRING | YES | |
contractType | ENUM | YES | |
interval | ENUM | YES | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1500. |
If startTime and endTime are not sent, the most recent klines are returned.
Contract type:
- PERPETUAL
- CURRENT_QUARTER
- NEXT_QUARTER
Index Price Kline/Candlestick Data
Response:
[
[
1591256400000, // Open time
"9653.69440000", // Open
"9653.69640000", // High
"9651.38600000", // Low
"9651.55200000", // Close (or latest price)
"0 ", // Ignore
1591256459999, // Close time
"0", // Ignore
60, // Ignore
"0", // Ignore
"0", // Ignore
"0" // Ignore
]
]
GET /fapi/v1/indexPriceKlines
Kline/candlestick bars for the index price of a pair.
Klines are uniquely identified by their open time.
Weight: based on parameter LIMIT
LIMIT | weight |
---|---|
[1,100) | 1 |
[100, 500) | 2 |
[500, 1000] | 5 |
> 1000 | 10 |
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | STRING | YES | |
interval | ENUM | YES | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1500. |
- If startTime and endTime are not sent, the most recent klines are returned.
Mark Price Kline/Candlestick Data
Response:
[
[
1591256460000, // Open time
"9653.29201333", // Open
"9654.56401333", // High
"9653.07367333", // Low
"9653.07367333", // Close (or latest price)
"0 ", // Ignore
1591256519999, // Close time
"0", // Ignore
60, // Ignore
"0", // Ignore
"0", // Ignore
"0" // Ignore
]
]
GET /fapi/v1/markPriceKlines
Kline/candlestick bars for the mark price of a symbol.
Klines are uniquely identified by their open time.
Weight: based on parameter LIMIT
LIMIT | weight |
---|---|
[1,100) | 1 |
[100, 500) | 2 |
[500, 1000] | 5 |
> 1000 | 10 |
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
interval | ENUM | YES | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1500. |
- If startTime and endTime are not sent, the most recent klines are returned.
Premium index Kline Data
Response:
[
[
1691603820000, // Open time
"-0.00042931", // Open
"-0.00023641", // High
"-0.00059406", // Low
"-0.00043659", // Close
"0", // Ignore
1691603879999, // Close time
"0", // Ignore
12, // Ignore
"0", // Ignore
"0", // Ignore
"0" // Ignore
]
]
GET /fapi/v1/premiumIndexKlines
Premium index kline bars of a symbol.
Klines are uniquely identified by their open time.
Weight: based on parameter LIMIT
LIMIT | weight |
---|---|
[1,100) | 1 |
[100, 500) | 2 |
[500, 1000] | 5 |
> 1000 | 10 |
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
interval | ENUM | YES | |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 500; max 1500. |
- If startTime and endTime are not sent, the most recent klines are returned.
Mark Price
Response:
{
"symbol": "BTCUSDT",
"markPrice": "11793.63104562", // mark price
"indexPrice": "11781.80495970", // index price
"estimatedSettlePrice": "11781.16138815", // Estimated Settle Price, only useful in the last hour before the settlement starts.
"lastFundingRate": "0.00038246", // This is the Latest funding rate
"nextFundingTime": 1597392000000,
"interestRate": "0.00010000",
"time": 1597370495002
}
OR (when symbol not sent)
[
{
"symbol": "BTCUSDT",
"markPrice": "11793.63104562", // mark price
"indexPrice": "11781.80495970", // index price
"estimatedSettlePrice": "11781.16138815", // Estimated Settle Price, only useful in the last hour before the settlement starts.
"lastFundingRate": "0.00038246", // This is the lastest estimated funding rate
"nextFundingTime": 1597392000000,
"interestRate": "0.00010000",
"time": 1597370495002
}
]
GET /fapi/v1/premiumIndex
Mark Price and Funding Rate
Weight: 1 with symbol; 10 without symbol
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO |
Get Funding Rate History
Response:
[
{
"symbol": "BTCUSDT",
"fundingTime": 1698768000000,
"fundingRate": "0.00010000",
"markPrice": "34287.54619963" // mark price associated with a particular funding fee charge
},
{
"symbol": "BTCUSDT",
"fundingTime": 1698796800000,
"fundingRate": "0.00010000",
"markPrice": "34651.40000000"
}
]
GET /fapi/v1/fundingRate
Rate Limit
share 500/5min/IP rate limit with GET /fapi/v1/fundingInfo
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
startTime | LONG | NO | Timestamp in ms to get funding rate from INCLUSIVE. |
endTime | LONG | NO | Timestamp in ms to get funding rate until INCLUSIVE. |
limit | INT | NO | Default 100; max 1000 |
- rate limit on
- If
startTime
andendTime
are not sent, the most recentlimit
datas are returned. - If the number of data between
startTime
andendTime
is larger thanlimit
, return asstartTime
+limit
. - In ascending order.
Get Funding Rate Info
Response:
[
{
"symbol": "BLZUSDT",
"adjustedFundingRateCap": "0.02500000",
"adjustedFundingRateFloor": "-0.02500000",
"fundingIntervalHours": 8,
"disclaimer": false // ingore
}
]
GET /fapi/v1/fundingInfo
rate limit
share 500/5min/IP rate limit with GET /fapi/v1/fundingInfo
Query funding rate info for symbols that had FundingRateCap/ FundingRateFloor / fundingIntervalHours adjustment
24hr Ticker Price Change Statistics
Response:
{
"symbol": "BTCUSDT",
"priceChange": "-94.99999800",
"priceChangePercent": "-95.960",
"weightedAvgPrice": "0.29628482",
"lastPrice": "4.00000200",
"lastQty": "200.00000000",
"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": "BTCUSDT",
"priceChange": "-94.99999800",
"priceChangePercent": "-95.960",
"weightedAvgPrice": "0.29628482",
"lastPrice": "4.00000200",
"lastQty": "200.00000000",
"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
}
]
GET /fapi/v1/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
Update Speed: 5s
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO |
- If the symbol is not sent, tickers for all symbols will be returned in an array.
Symbol Price Ticker
Response:
{
"symbol": "BTCUSDT",
"price": "6000.01",
"time": 1589437530011 // Transaction time
}
OR
[
{
"symbol": "BTCUSDT",
"price": "6000.01",
"time": 1589437530011
}
]
GET /fapi/v1/ticker/price
Latest price for a symbol or symbols.
Weight:
1 for a single symbol;
2 when the symbol parameter is omitted
Update Speed: 5s
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO |
- If the symbol is not sent, prices for all symbols will be returned in an array.
Symbol Price Ticker V2
Response:
{
"symbol": "BTCUSDT",
"price": "6000.01",
"time": 1589437530011 // Transaction time
}
OR
[
{
"symbol": "BTCUSDT",
"price": "6000.01",
"time": 1589437530011
}
]
GET /fapi/v2/ticker/price
Latest price for a symbol or symbols.
Weight:
- with symbol
1
- no symbol
2
Update Speed: real time
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO |
- If the symbol is not sent, prices for all symbols will be returned in an array.
Symbol Order Book Ticker
Response:
{
"lastUpdateId": 1027024,
"symbol": "BTCUSDT",
"bidPrice": "4.00000000",
"bidQty": "431.00000000",
"askPrice": "4.00000200",
"askQty": "9.00000000",
"time": 1589437530011 // Transaction time
}
OR
[
{
"lastUpdateId": 1027024,
"symbol": "BTCUSDT",
"bidPrice": "4.00000000",
"bidQty": "431.00000000",
"askPrice": "4.00000200",
"askQty": "9.00000000",
"time": 1589437530011
}
]
GET /fapi/v1/ticker/bookTicker
Best price/qty on the order book for a symbol or symbols.
Weight:
2 for a single symbol;
5 when the symbol parameter is omitted
Update Speed: real time
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO |
- If the symbol is not sent, bookTickers for all symbols will be returned in an array.
- The field
X-MBX-USED-WEIGHT-1M
in response header is not accurate from this endpoint, please ignore.
Open Interest
Response:
{
"openInterest": "10659.509",
"symbol": "BTCUSDT",
"time": 1589437530011 // Transaction time
}
GET /fapi/v1/openInterest
Get present open interest of a specific symbol.
Weight:
1
Update Speed: 3s
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES |
Quarterly Contract Settlement Price
Response:
[
{
"deliveryTime": 1695945600000,
"deliveryPrice": 27103.00000000
},
{
"deliveryTime": 1688083200000,
"deliveryPrice": 30733.60000000
},
{
"deliveryTime": 1680220800000,
"deliveryPrice": 27814.20000000
},
{
"deliveryTime": 1648166400000,
"deliveryPrice": 44066.30000000
}
]
GET /futures/data/delivery-price
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | STRING | YES | e.g BTCUSDT |
Open Interest Statistics
Response:
[
{
"symbol":"BTCUSDT",
"sumOpenInterest":"20403.63700000", // total open interest
"sumOpenInterestValue": "150570784.07809979", // total open interest value
"timestamp":"1583127900000"
},
{
"symbol":"BTCUSDT",
"sumOpenInterest":"20401.36700000",
"sumOpenInterestValue":"149940752.14464448",
"timestamp":"1583128200000"
},
]
GET /futures/data/openInterestHist
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
period | ENUM | YES | "5m","15m","30m","1h","2h","4h","6h","12h","1d" |
limit | LONG | NO | default 30, max 500 |
startTime | LONG | NO | |
endTime | LONG | NO |
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
- IP rate limit 1000 requests/5min
Top Trader Long/Short Ratio (Accounts)
Response:
[
{
"symbol":"BTCUSDT",
"longShortRatio":"1.8105", // long/short account num ratio of top traders
"longAccount": "0.6442", // long account num ratio of top traders
"shortAccount":"0.3558", // long account num ratio of top traders
"timestamp":"1583139600000"
},
{
"symbol":"BTCUSDT",
"longShortRatio":"0.5576",
"longAccount": "0.3580",
"shortAccount":"0.6420",
"timestamp":"1583139900000"
},
]
GET /futures/data/topLongShortAccountRatio
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
period | ENUM | YES | "5m","15m","30m","1h","2h","4h","6h","12h","1d" |
limit | LONG | NO | default 30, max 500 |
startTime | LONG | NO | |
endTime | LONG | NO |
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
- IP rate limit 1000 requests/5min
Top Trader Long/Short Ratio (Positions)
Response:
[
{
"symbol":"BTCUSDT",
"longShortRatio":"1.4342",// long/short position ratio of top traders
"longAccount": "0.5891", // long positions ratio of top traders
"shortAccount":"0.4656", // short positions ratio of top traders
"timestamp":"1583139600000"
},
{
"symbol":"BTCUSDT",
"longShortRatio":"1.4337",
"longAccount": "0.3583",
"shortAccount":"0.6417",
"timestamp":"1583139900000"
},
]
GET /futures/data/topLongShortPositionRatio
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
period | ENUM | YES | "5m","15m","30m","1h","2h","4h","6h","12h","1d" |
limit | LONG | NO | default 30, max 500 |
startTime | LONG | NO | |
endTime | LONG | NO |
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
- IP rate limit 1000 requests/5min
Long/Short Ratio
Response:
[
{
"symbol":"BTCUSDT", // long/short account num ratio of all traders
"longShortRatio":"0.1960", //long account num ratio of all traders
"longAccount": "0.6622", // short account num ratio of all traders
"shortAccount":"0.3378",
"timestamp":"1583139600000"
},
{
"symbol":"BTCUSDT",
"longShortRatio":"1.9559",
"longAccount": "0.6617",
"shortAccount":"0.3382",
"timestamp":"1583139900000"
},
]
GET /futures/data/globalLongShortAccountRatio
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
period | ENUM | YES | "5m","15m","30m","1h","2h","4h","6h","12h","1d" |
limit | LONG | NO | default 30, max 500 |
startTime | LONG | NO | |
endTime | LONG | NO |
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
- IP rate limit 1000 requests/5min
Taker Buy/Sell Volume
Response:
[
{
"buySellRatio":"1.5586",
"buyVol": "387.3300",
"sellVol":"248.5030",
"timestamp":"1585614900000"
},
{
"buySellRatio":"1.3104",
"buyVol": "343.9290",
"sellVol":"248.5030",
"timestamp":"1583139900000"
},
]
GET /futures/data/takerlongshortRatio
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
period | ENUM | YES | "5m","15m","30m","1h","2h","4h","6h","12h","1d" |
limit | LONG | NO | default 30, max 500 |
startTime | LONG | NO | |
endTime | LONG | NO |
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
- IP rate limit 1000 requests/5min
Basis
Response:
[
{
"indexPrice": "34400.15945055",
"contractType": "PERPETUAL",
"basisRate": "0.0004",
"futuresPrice": "34414.10",
"annualizedBasisRate": "",
"basis": "13.94054945",
"pair": "BTCUSDT",
"timestamp": 1698742800000
}
]
GET /futures/data/basis
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | STRING | YES | BTCUSDT |
contractType | ENUM | YES | CURRENT_QUARTER, NEXT_QUARTER, PERPETUAL |
period | ENUM | YES | "5m","15m","30m","1h","2h","4h","6h","12h","1d" |
limit | LONG | YES | Default 30,Max 500 |
startTime | LONG | NO | |
endTime | LONG | NO |
- If startTime and endTime are not sent, the most recent data is returned.
- Only the data of the latest 30 days is available.
Composite Index Symbol Information
Response:
[
{
"symbol": "DEFIUSDT",
"time": 1589437530011, // Current time
"component": "baseAsset", //Component asset
"baseAssetList":[
{
"baseAsset":"BAL",
"quoteAsset": "USDT",
"weightInQuantity":"1.04406228",
"weightInPercentage":"0.02783900"
},
{
"baseAsset":"BAND",
"quoteAsset": "USDT",
"weightInQuantity":"3.53782729",
"weightInPercentage":"0.03935200"
}
]
}
]
GET /fapi/v1/indexInfo
Weight: with symbol 1; without symbol 10
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO |
- Only for composite index symbols
Multi-Assets Mode Asset Index
Response:
{
"symbol": "ADAUSD",
"time": 1635740268004,
"index": "1.92957370",
"bidBuffer": "0.10000000",
"askBuffer": "0.10000000",
"bidRate": "1.73661633",
"askRate": "2.12253107",
"autoExchangeBidBuffer": "0.05000000",
"autoExchangeAskBuffer": "0.05000000",
"autoExchangeBidRate": "1.83309501",
"autoExchangeAskRate": "2.02605238"
}
Or(without symbol)
[
{
"symbol": "ADAUSD",
"time": 1635740268004,
"index": "1.92957370",
"bidBuffer": "0.10000000",
"askBuffer": "0.10000000",
"bidRate": "1.73661633",
"askRate": "2.12253107",
"autoExchangeBidBuffer": "0.05000000",
"autoExchangeAskBuffer": "0.05000000",
"autoExchangeBidRate": "1.83309501",
"autoExchangeAskRate": "2.02605238"
}
]
GET /fapi/v1/assetIndex
asset index for Multi-Assets mode
Weight: 1 for a single symbol; 10 when the symbol parameter is omitted
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Asset pair |
Query Index Price Constituents
Response:
{
"symbol": "BTCUSDT",
"time": 1697421272043,
"constituents": [
{
"exchange": "binance",
"symbol": "BTCUSDT"
},
{
"exchange": "okex",
"symbol": "BTC-USDT"
},
{
"exchange": "huobi",
"symbol": "btcusdt"
},
{
"exchange": "coinbase",
"symbol": "BTC-USDT"
}
]
}
GET /fapi/v1/constituents
Query index price constituents
Weight: 2
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | symbol |
Websocket Market Streams
The connection method for Websocket is:
- Base Url: wss://fstream.binance.com
- Streams can be access either in a single raw stream or a combined stream
- Raw streams are accessed at /ws/<streamName>
- Combined streams are accessed at /stream?streams=<streamName1>/<streamName2>/<streamName3>
- Example:
wss://fstream.binance.com/ws/bnbusdt@aggTrade
wss://fstream.binance.com/stream?streams=bnbusdt@aggTrade/btcusdt@markPrice
Combined stream events are wrapped as follows: {"stream":"<streamName>","data":<rawPayload>}
All symbols for streams are lowercase
A single connection is only valid for 24 hours; expect to be disconnected at the 24 hour mark
Websocket server will send a
ping frame
every 3 minutes.- If the websocket server does not receive a
pong frame
back from the connection within a 10 minute period, the connection will be disconnected. - When you receive a ping, you must send a pong with a copy of ping's payload as soon as possible.
- Unsolicited
pong frames
are allowed, but will not prevent disconnection. It is recommended that the payload for these pong frames are empty.
- If the websocket server does not receive a
WebSocket connections have a limit of 10 incoming messages per second.
A connection that goes beyond the limit will be disconnected; IPs that are repeatedly disconnected may be banned.
A single connection is not recommended to listen to more than 200 streams.
Considering the possible data latency from RESTful endpoints during an extremely volatile market, it is highly recommended to get the order status, position, etc from the Websocket user data stream.
Live Subscribing/Unsubscribing to streams
- The following data can be sent through the websocket instance in order to subscribe/unsubscribe from streams. Examples can be seen below.
- The
id
used in the JSON payloads is an unsigned INT used as an identifier to uniquely identify the messages going back and forth.
Subscribe to a stream
Response
{
"result": null,
"id": 1
}
Request
{
"method": "SUBSCRIBE",
"params":
[
"btcusdt@aggTrade",
"btcusdt@depth"
],
"id": 1
}
Unsubscribe to a stream
Response
{
"result": null,
"id": 312
}
- Request
{
"method": "UNSUBSCRIBE",
"params":
[
"btcusdt@depth"
],
"id": 312
}
Listing Subscriptions
Response
{
"result": [
"btcusdt@aggTrade"
],
"id": 3
}
- Request
{
"method": "LIST_SUBSCRIPTIONS",
"id": 3
}
Setting Properties
Currently, the only property can be set is to set whether combined
stream payloads are enabled are not.
The combined property is set to false
when connecting using /ws/
("raw streams") and true
when connecting using /stream/
.
Response
{
"result": null,
"id": 5
}
- Request
{
"method": "SET_PROPERTY",
"params":
[
"combined",
true
],
"id": 5
}
Retrieving Properties
Response
{
"result": true, // Indicates that combined is set to true.
"id": 2
}
- Request
{
"method": "GET_PROPERTY",
"params":
[
"combined"
],
"id": 2
}
Error Messages
Error Message | Description |
---|---|
{"code": 0, "msg": "Unknown property"} | Parameter used in the SET_PROPERTY or GET_PROPERTY was invalid |
{"code": 1, "msg": "Invalid value type: expected Boolean"} | Value should only be true or false |
{"code": 2, "msg": "Invalid request: property name must be a string"} | Property name provided was invalid |
{"code": 2, "msg": "Invalid request: request ID must be an unsigned integer"} | Parameter id had to be provided or the value provided in the id parameter is an unsupported type |
{"code": 2, "msg": "Invalid request: unknown variant %s, expected one of SUBSCRIBE , UNSUBSCRIBE , LIST_SUBSCRIPTIONS , SET_PROPERTY , GET_PROPERTY at line 1 column 28"} |
Possible typo in the provided method or provided method was neither of the expected values |
{"code": 2, "msg": "Invalid request: too many parameters"} | Unnecessary parameters provided in the data |
{"code": 2, "msg": "Invalid request: property name must be a string"} | Property name was not provided |
{"code": 2, "msg": "Invalid request: missing field method at line 1 column 73"} |
method was not provided in the data |
{"code":3,"msg":"Invalid JSON: expected value at line %s column %s"} | JSON data sent has incorrect syntax. |
Aggregate Trade Streams
Payload:
{
"e": "aggTrade", // Event type
"E": 123456789, // Event time
"s": "BTCUSDT", // Symbol
"a": 5933014, // Aggregate trade ID
"p": "0.001", // Price
"q": "100", // Quantity
"f": 100, // First trade ID
"l": 105, // Last trade ID
"T": 123456785, // Trade time
"m": true, // Is the buyer the market maker?
}
The Aggregate Trade Streams push market trade information that is aggregated for fills with same price and taking side every 100 milliseconds.
Stream Name:
<symbol>@aggTrade
Update Speed: 100ms
- Only market trades will be aggregated, which means the insurance fund trades and ADL trades won't be aggregated.
Mark Price Stream
Payload:
{
"e": "markPriceUpdate", // Event type
"E": 1562305380000, // Event time
"s": "BTCUSDT", // Symbol
"p": "11794.15000000", // Mark price
"i": "11784.62659091", // Index price
"P": "11784.25641265", // Estimated Settle Price, only useful in the last hour before the settlement starts
"r": "0.00038167", // Funding rate
"T": 1562306400000 // Next funding time
}
Mark price and funding rate for a single symbol pushed every 3 seconds or every second.
Stream Name:
<symbol>@markPrice
or <symbol>@markPrice@1s
Update Speed: 3000ms or 1000ms
Mark Price Stream for All market
Payload:
[
{
"e": "markPriceUpdate", // Event type
"E": 1562305380000, // Event time
"s": "BTCUSDT", // Symbol
"p": "11185.87786614", // Mark price
"i": "11784.62659091" // Index price
"P": "11784.25641265", // Estimated Settle Price, only useful in the last hour before the settlement starts
"r": "0.00030000", // Funding rate
"T": 1562306400000 // Next funding time
}
]
Mark price and funding rate for all symbols pushed every 3 seconds or every second.
Stream Name:
!markPrice@arr
or !markPrice@arr@1s
Update Speed: 3000ms or 1000ms
Kline/Candlestick Streams
Payload:
{
"e": "kline", // Event type
"E": 1638747660000, // Event time
"s": "BTCUSDT", // Symbol
"k": {
"t": 1638747660000, // Kline start time
"T": 1638747719999, // Kline close time
"s": "BTCUSDT", // Symbol
"i": "1m", // Interval
"f": 100, // First trade ID
"L": 200, // Last trade ID
"o": "0.0010", // Open price
"c": "0.0020", // Close price
"h": "0.0025", // High price
"l": "0.0015", // Low price
"v": "1000", // Base asset volume
"n": 100, // Number of trades
"x": false, // Is this kline closed?
"q": "1.0000", // Quote asset volume
"V": "500", // Taker buy base asset volume
"Q": "0.500", // Taker buy quote asset volume
"B": "123456" // Ignore
}
}
The Kline/Candlestick Stream push updates to the current klines/candlestick every 250 milliseconds (if existing).
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
Stream Name:
<symbol>@kline_<interval>
Update Speed: 250ms
Continuous Contract Kline/Candlestick Streams
Payload:
{
"e":"continuous_kline", // Event type
"E":1607443058651, // Event time
"ps":"BTCUSDT", // Pair
"ct":"PERPETUAL" // Contract type
"k":{
"t":1607443020000, // Kline start time
"T":1607443079999, // Kline close time
"i":"1m", // Interval
"f":116467658886, // First updateId
"L":116468012423, // Last updateId
"o":"18787.00", // Open price
"c":"18804.04", // Close price
"h":"18804.04", // High price
"l":"18786.54", // Low price
"v":"197.664", // volume
"n": 543, // Number of trades
"x":false, // Is this kline closed?
"q":"3715253.19494", // Quote asset volume
"V":"184.769", // Taker buy volume
"Q":"3472925.84746", //Taker buy quote asset volume
"B":"0" // Ignore
}
}
Contract type:
- perpetual
- current_quarter
- next_quarter
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
Stream Name:
<pair>_<contractType>@continuousKline_<interval>
Update Speed: 250ms
Individual Symbol Mini Ticker Stream
Payload:
{
"e": "24hrMiniTicker", // Event type
"E": 123456789, // Event time
"s": "BTCUSDT", // Symbol
"c": "0.0025", // Close price
"o": "0.0010", // Open price
"h": "0.0025", // High price
"l": "0.0010", // Low price
"v": "10000", // Total traded base asset volume
"q": "18" // Total traded quote asset volume
}
24hr rolling window mini-ticker statistics for a single symbol. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before.
Stream Name:
<symbol>@miniTicker
Update Speed: 500ms
All Market Mini Tickers Stream
Payload:
[
{
"e": "24hrMiniTicker", // Event type
"E": 123456789, // Event time
"s": "BTCUSDT", // Symbol
"c": "0.0025", // Close price
"o": "0.0010", // Open price
"h": "0.0025", // High price
"l": "0.0010", // Low price
"v": "10000", // Total traded base asset volume
"q": "18" // Total traded quote asset volume
}
]
24hr rolling window mini-ticker statistics for all symbols. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before. Note that only tickers that have changed will be present in the array.
Stream Name:
!miniTicker@arr
Update Speed: 1000ms
Individual Symbol Ticker Streams
Payload:
{
"e": "24hrTicker", // Event type
"E": 123456789, // Event time
"s": "BTCUSDT", // Symbol
"p": "0.0015", // Price change
"P": "250.00", // Price change percent
"w": "0.0018", // Weighted average price
"c": "0.0025", // Last price
"Q": "10", // Last quantity
"o": "0.0010", // Open price
"h": "0.0025", // High price
"l": "0.0010", // Low price
"v": "10000", // Total traded base asset volume
"q": "18", // Total traded quote asset volume
"O": 0, // Statistics open time
"C": 86400000, // Statistics close time
"F": 0, // First trade ID
"L": 18150, // Last trade Id
"n": 18151 // Total number of trades
}
24hr rolling window ticker statistics for a single symbol. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before.
Stream Name:
<symbol>@ticker
Update Speed: 2000ms
All Market Tickers Streams
Payload:
[
{
"e": "24hrTicker", // Event type
"E": 123456789, // Event time
"s": "BTCUSDT", // Symbol
"p": "0.0015", // Price change
"P": "250.00", // Price change percent
"w": "0.0018", // Weighted average price
"c": "0.0025", // Last price
"Q": "10", // Last quantity
"o": "0.0010", // Open price
"h": "0.0025", // High price
"l": "0.0010", // Low price
"v": "10000", // Total traded base asset volume
"q": "18", // Total traded quote asset volume
"O": 0, // Statistics open time
"C": 86400000, // Statistics close time
"F": 0, // First trade ID
"L": 18150, // Last trade Id
"n": 18151 // Total number of trades
}
]
24hr rolling window ticker statistics for all symbols. These are NOT the statistics of the UTC day, but a 24hr rolling window from requestTime to 24hrs before. Note that only tickers that have changed will be present in the array.
Stream Name:
!ticker@arr
Update Speed: 1000ms
Individual Symbol Book Ticker Streams
Payload:
{
"e":"bookTicker", // event type
"u":400900217, // order book updateId
"E": 1568014460893, // event time
"T": 1568014460891, // transaction time
"s":"BNBUSDT", // symbol
"b":"25.35190000", // best bid price
"B":"31.21000000", // best bid qty
"a":"25.36520000", // best ask price
"A":"40.66000000" // best ask qty
}
Pushes any update to the best bid or ask's price or quantity in real-time for a specified symbol.
Stream Name: <symbol>@bookTicker
Update Speed: Real-time
All Book Tickers Stream
Payload:
{
// Same as <symbol>@bookTicker payload
}
Pushes any update to the best bid or ask's price or quantity in real-time for all symbols.
Stream Name: !bookTicker
Update Speed: Real-time, Starting from December 20th, 2023, it will be updated every 5 seconds.
Liquidation Order Streams
Payload:
{
"e":"forceOrder", // Event Type
"E":1568014460893, // Event Time
"o":{
"s":"BTCUSDT", // Symbol
"S":"SELL", // Side
"o":"LIMIT", // Order Type
"f":"IOC", // Time in Force
"q":"0.014", // Original Quantity
"p":"9910", // Price
"ap":"9910", // Average Price
"X":"FILLED", // Order Status
"l":"0.014", // Order Last Filled Quantity
"z":"0.014", // Order Filled Accumulated Quantity
"T":1568014460893, // Order Trade Time
}
}
The Liquidation Order Snapshot Streams push force liquidation order information for specific symbol.
For each symbol,only the latest one liquidation order within 1000ms will be pushed as the snapshot. If no liquidation happens in the interval of 1000ms, no stream will be pushed.
Stream Name: <symbol>@forceOrder
Update Speed: 1000ms
All Market Liquidation Order Streams
Payload:
{
"e":"forceOrder", // Event Type
"E":1568014460893, // Event Time
"o":{
"s":"BTCUSDT", // Symbol
"S":"SELL", // Side
"o":"LIMIT", // Order Type
"f":"IOC", // Time in Force
"q":"0.014", // Original Quantity
"p":"9910", // Price
"ap":"9910", // Average Price
"X":"FILLED", // Order Status
"l":"0.014", // Order Last Filled Quantity
"z":"0.014", // Order Filled Accumulated Quantity
"T":1568014460893, // Order Trade Time
}
}
The All Liquidation Order Snapshot Streams push force liquidation order information for all symbols in the market.
For each symbol,only the latest one liquidation order within 1000ms will be pushed as the snapshot. If no liquidation happens in the interval of 1000ms, no stream will be pushed.
Stream Name: !forceOrder@arr
Update Speed: 1000ms
Partial Book Depth Streams
Payload:
{
"e": "depthUpdate", // Event type
"E": 1571889248277, // Event time
"T": 1571889248276, // Transaction time
"s": "BTCUSDT",
"U": 390497796,
"u": 390497878,
"pu": 390497794,
"b": [ // Bids to be updated
[
"7403.89", // Price Level to be
"0.002" // Quantity
],
[
"7403.90",
"3.906"
],
[
"7404.00",
"1.428"
],
[
"7404.85",
"5.239"
],
[
"7405.43",
"2.562"
]
],
"a": [ // Asks to be updated
[
"7405.96", // Price level to be
"3.340" // Quantity
],
[
"7406.63",
"4.525"
],
[
"7407.08",
"2.475"
],
[
"7407.15",
"4.800"
],
[
"7407.20",
"0.175"
]
]
}
Top
Stream Names: <symbol>@depth<levels>
OR <symbol>@depth<levels>@500ms
OR <symbol>@depth<levels>@100ms
.
Update Speed: 250ms, 500ms or 100ms
Diff. Book Depth Streams
Payload:
{
"e": "depthUpdate", // Event type
"E": 123456789, // Event time
"T": 123456788, // Transaction time
"s": "BTCUSDT", // Symbol
"U": 157, // First update ID in event
"u": 160, // Final update ID in event
"pu": 149, // Final update Id in last stream(ie `u` in last stream)
"b": [ // Bids to be updated
[
"0.0024", // Price level to be updated
"10" // Quantity
]
],
"a": [ // Asks to be updated
[
"0.0026", // Price level to be updated
"100" // Quantity
]
]
}
Bids and asks, pushed every 250 milliseconds, 500 milliseconds, 100 milliseconds (if existing)
Stream Name:
<symbol>@depth
OR <symbol>@depth@500ms
OR <symbol>@depth@100ms
Update Speed: 250ms, 500ms, 100ms
How to manage a local order book correctly
- Open a stream to wss://fstream.binance.com/stream?streams=btcusdt@depth.
- Buffer the events you receive from the stream. For same price, latest received update covers the previous one.
- Get a depth snapshot from https://fapi.binance.com/fapi/v1/depth?symbol=BTCUSDT&limit=1000 .
- Drop any event where
u
is <lastUpdateId
in the snapshot. - The first processed event should have
U
<=lastUpdateId
ANDu
>=lastUpdateId
- While listening to the stream, each new event's
pu
should be equal to the previous event'su
, otherwise initialize the process from step 3. - The data in each event is the absolute quantity for a price level.
- If the quantity is 0, remove the price level.
- Receiving an event that removes a price level that is not in your local order book can happen and is normal.
Composite Index Symbol Information Streams
Payload:
{
"e":"compositeIndex", // Event type
"E":1602310596000, // Event time
"s":"DEFIUSDT", // Symbol
"p":"554.41604065", // Price
"C":"baseAsset",
"c":[ // Composition
{
"b":"BAL", // Base asset
"q":"USDT", // Quote asset
"w":"1.04884844", // Weight in quantity
"W":"0.01457800", // Weight in percentage
"i":"24.33521021" // Index price
},
{
"b":"BAND",
"q":"USDT" ,
"w":"3.53782729",
"W":"0.03935200",
"i":"7.26420084"
}
]
}
Composite index information for index symbols pushed every second.
Stream Name: <symbol>@compositeIndex
Update Speed: 1000ms
Contract Info Stream
Payload:
{
"e":"contractInfo", // Event Type
"E":1669356423908, // Event Time
"s":"IOTAUSDT", // Symbol
"ps":"IOTAUSDT", // Pair
"ct":"PERPETUAL", // Contract type
"dt":4133404800000, // Delivery date time
"ot":1569398400000, // onboard date time
"cs":"TRADING", // Contract status
"bks":[
{
"bs":1, // Notional bracket
"bnf":0, // Floor notional of this bracket
"bnc":5000, // Cap notional of this bracket
"mmr":0.01, // Maintenance ratio for this bracket
"cf":0, // Auxiliary number for quick calculation
"mi":21, // Min leverage for this bracket
"ma":50 // Max leverage for this bracket
},
{
"bs":2,
"bnf":5000,
"bnc":25000,
"mmr":0.025,
"cf":75,
"mi":11,
"ma":20
}
]
}
ContractInfo stream pushes when contract info updates(listing/settlement/contract bracket update). bks
field only shows up when bracket gets updated.
Stream Name: !contractInfo
Update Speed: Real-time
Multi-Assets Mode Asset Index
Payload:
[
{
"e":"assetIndexUpdate",
"E":1686749230000,
"s":"ADAUSD", // asset index symbol
"i":"0.27462452", // index price
"b":"0.10000000", // bid buffer
"a":"0.10000000", // ask buffer
"B":"0.24716207", // bid rate
"A":"0.30208698", // ask rate
"q":"0.05000000", // auto exchange bid buffer
"g":"0.05000000", // auto exchange ask buffer
"Q":"0.26089330", // auto exchange bid rate
"G":"0.28835575" // auto exchange ask rate
},
{
"e":"assetIndexUpdate",
"E":1686749230000,
"s":"USDTUSD",
"i":"0.99987691",
"b":"0.00010000",
"a":"0.00010000",
"B":"0.99977692",
"A":"0.99997689",
"q":"0.00010000",
"g":"0.00010000",
"Q":"0.99977692",
"G":"0.99997689"
}
]
Asset index for multi-assets mode user
Stream Name: !assetIndex@arr
OR <assetSymbol>@assetIndex
Update Speed: 1s
Account/Trades Endpoints
New Future Account Transfer
Please find details from here.
Get Future Account Transaction History List (USER_DATA)
Please find details from here.
Change Position Mode(TRADE)
Response:
{
"code": 200,
"msg": "success"
}
POST /fapi/v1/positionSide/dual
Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
dualSidePosition | STRING | YES | "true": Hedge Mode; "false": One-way Mode |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Get Current Position Mode(USER_DATA)
Response:
{
"dualSidePosition": true // "true": Hedge Mode; "false": One-way Mode
}
GET /fapi/v1/positionSide/dual
Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol
Weight: 30
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Change Multi-Assets Mode (TRADE)
Response:
{
"code": 200,
"msg": "success"
}
POST /fapi/v1/multiAssetsMargin
Change user's Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
multiAssetsMargin | STRING | YES | "true": Multi-Assets Mode; "false": Single-Asset Mode |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Get Current Multi-Assets Mode (USER_DATA)
Response:
{
"multiAssetsMargin": true // "true": Multi-Assets Mode; "false": Single-Asset Mode
}
GET /fapi/v1/multiAssetsMargin
Get user's Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol
Weight: 30
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Toggle BNB Burn On Futures Trade (TRADE)
Response:
{
"code": 200,
"msg": "success"
}
POST /fapi/v1/feeBurn (HMAC SHA256)
Change user's BNB Fee Discount (Fee Discount On or Fee Discount Off ) on EVERY symbol
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
feeBurn | STRING | YES | "true": Fee Discount On; "false": Fee Discount Off |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Get BNB Burn Status (USER_DATA)
Response:
{
"feeBurn": true // "true": Fee Discount On; "false": Fee Discount Off
}
GET /fapi/v1/feeBurn (HMAC SHA256)
Get user's BNB Fee Discount (Fee Discount On or Fee Discount Off ) on EVERY symbol
Weight: 30
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
New Order (TRADE)
Response:
{
"clientOrderId": "testOrder",
"cumQty": "0",
"cumQuote": "0",
"executedQty": "0",
"orderId": 22542179,
"avgPrice": "0.00000",
"origQty": "10",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "NEW",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"timeInForce": "GTD",
"type": "TRAILING_STOP_MARKET",
"origType": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1566818724722,
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 1693207680000 //order pre-set auot cancel time for TIF GTD order
}
POST /fapi/v1/order
Send in a new order.
Weight: 0
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
side | ENUM | YES | |
positionSide | ENUM | NO | Default BOTH for One-way Mode ; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode. |
type | ENUM | YES | |
timeInForce | ENUM | NO | |
quantity | DECIMAL | NO | Cannot be sent with closePosition =true (Close-All) |
reduceOnly | STRING | NO | "true" or "false". default "false". Cannot be sent in Hedge Mode; cannot be sent with closePosition =true |
price | DECIMAL | NO | |
newClientOrderId | STRING | NO | A unique id among open orders. Automatically generated if not sent. Can only be string following the rule: ^[\.A-Z\:/a-z0-9_-]{1,36}$ |
stopPrice | DECIMAL | NO | Used with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders. |
closePosition | STRING | NO | true , false ;Close-All,used with STOP_MARKET or TAKE_PROFIT_MARKET . |
activationPrice | DECIMAL | NO | Used with TRAILING_STOP_MARKET orders, default as the latest price(supporting different workingType ) |
callbackRate | DECIMAL | NO | Used with TRAILING_STOP_MARKET orders, min 0.1, max 10, where 1 for 1% |
workingType | ENUM | NO | stopPrice triggered by: "MARK_PRICE", "CONTRACT_PRICE". Default "CONTRACT_PRICE" |
priceProtect | STRING | NO | "TRUE" or "FALSE", default "FALSE". Used with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders. |
newOrderRespType | ENUM | NO | "ACK", "RESULT", default "ACK" |
priceMatch | ENUM | NO | only avaliable for LIMIT /STOP /TAKE_PROFIT order; can be set to OPPONENT / OPPONENT_5 / OPPONENT_10 / OPPONENT_20 : /QUEUE / QUEUE_5 / QUEUE_10 / QUEUE_20 ; Can't be passed together with price |
selfTradePreventionMode | ENUM | NO | NONE :No STP / EXPIRE_TAKER :expire taker order when STP triggers/ EXPIRE_MAKER :expire maker order when STP triggers/ EXPIRE_BOTH :expire both orders when STP triggers; default NONE |
goodTillDate | LONG | NO | order cancel time for timeInForce GTD , mandatory when timeInforce set to GTD ; order the timestamp only retains second-level precision, ms part will be ignored; The goodTillDate timestamp must be greater than the current time plus 600 seconds and smaller than 253402300799000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Additional mandatory parameters based on type
:
Type | Additional mandatory parameters |
---|---|
LIMIT |
timeInForce , quantity , price |
MARKET |
quantity |
STOP/TAKE_PROFIT |
quantity , price , stopPrice |
STOP_MARKET/TAKE_PROFIT_MARKET |
stopPrice |
TRAILING_STOP_MARKET |
quantity ,callbackRate |
- Order with type
STOP
, parametertimeInForce
can be sent ( defaultGTC
). - Order with type
TAKE_PROFIT
, parametertimeInForce
can be sent ( defaultGTC
). Condition orders will be triggered when:
- If parameter
priceProtect
is sent as true:- when price reaches the
stopPrice
,the difference rate between "MARK_PRICE" and "CONTRACT_PRICE" cannot be larger than the "triggerProtect" of the symbol - "triggerProtect" of a symbol can be got from
GET /fapi/v1/exchangeInfo
- when price reaches the
STOP
,STOP_MARKET
:- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >=
stopPrice
- SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <=
stopPrice
- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >=
TAKE_PROFIT
,TAKE_PROFIT_MARKET
:- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <=
stopPrice
- SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >=
stopPrice
- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <=
TRAILING_STOP_MARKET
:- BUY: the lowest price after order placed <=
activationPrice
, and the latest price >= the lowest price * (1 +callbackRate
) - SELL: the highest price after order placed >=
activationPrice
, and the latest price <= the highest price * (1 -callbackRate
)
- BUY: the lowest price after order placed <=
- If parameter
For
TRAILING_STOP_MARKET
, if you got such error code.
{"code": -2021, "msg": "Order would immediately trigger."}
means that the parameters you send do not meet the following requirements:- BUY:
activationPrice
should be smaller than latest price. - SELL:
activationPrice
should be larger than latest price.
- BUY:
If
newOrderRespType
is sent asRESULT
:MARKET
order: the final FILLED result of the order will be return directly.LIMIT
order with specialtimeInForce
: the final status result of the order(FILLED or EXPIRED) will be returned directly.
STOP_MARKET
,TAKE_PROFIT_MARKET
withclosePosition
=true
:- Follow the same rules for condition orders.
- If triggered,close all current long position( if
SELL
) or current short position( ifBUY
). - Cannot be used with
quantity
paremeter - Cannot be used with
reduceOnly
parameter - In Hedge Mode,cannot be used with
BUY
orders inLONG
position side. and cannot be used withSELL
orders inSHORT
position side
selfTradePreventionMode
is only effective whentimeInForce
set toIOC
orGTC
orGTD
.In extreme market conditions, timeInForce
GTD
order auto cancel time might be delayed comparing togoodTillDate
Test Order(TRADE)
Response:
response result matches request
POST /fapi/v1/order/test
Testing order request, this order will not be submitted to matching engine
Parameters:
Please refer to POST /fapi/v1/order
Modify Order (TRADE)
Response:
{
"orderId": 20072994037,
"symbol": "BTCUSDT",
"pair": "BTCUSDT",
"status": "NEW",
"clientOrderId": "LJ9R4QZDihCaS8UAOOLpgW",
"price": "30005",
"avgPrice": "0.0",
"origQty": "1",
"executedQty": "0",
"cumQty": "0",
"cumBase": "0",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "LONG",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
"updateTime": 1629182711600
}
PUT /fapi/v1/order
Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
Weight: 1 on 10s order rate limit(X-MBX-ORDER-COUNT-10S); 1 on 1min order rate limit(X-MBX-ORDER-COUNT-1M); 1 on IP rate limit(x-mbx-used-weight-1m);
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
symbol | STRING | YES | |
side | ENUM | YES | SELL , BUY ; side needs to be same as origin order |
quantity | DECIMAL | YES | Order quantity, cannot be sent with closePosition=true |
price | DECIMAL | YES | |
priceMatch | ENUM | NO | only avaliable for LIMIT /STOP /TAKE_PROFIT order; can be set to OPPONENT / OPPONENT_5 / OPPONENT_10 / OPPONENT_20 : /QUEUE / QUEUE_5 / QUEUE_10 / QUEUE_20 ; Can't be passed together with price |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Either
orderId
ororigClientOrderId
must be sent, and theorderId
will prevail if both are sent. - Both
quantity
andprice
must be sent, which is different from dapi modify order endpoint. - When the new
quantity
orprice
doesn't satisfy PRICE_FILTER / PERCENT_FILTER / LOT_SIZE, amendment will be rejected and the order will stay as it is. - However the order will be cancelled by the amendment in the following situations:
- when the order is in partially filled status and the new
quantity
<=executedQty
- When the order is
GTX
and the new price will cause it to be executed immediately
- when the order is in partially filled status and the new
- One order can only be modfied for less than 10000 times
- Order modification will preserve the original
selfTradePreventionMode
of the order
Place Multiple Orders (TRADE)
Response:
[
{
"clientOrderId": "testOrder",
"cumQty": "0",
"cumQuote": "0",
"executedQty": "0",
"orderId": 22542179,
"avgPrice": "0.00000",
"origQty": "10",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "NEW",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"origType": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1566818724722,
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
},
{
"code": -2022,
"msg": "ReduceOnly Order is rejected."
}
]
POST /fapi/v1/batchOrders
Weight: 5 on 10s order rate limit(X-MBX-ORDER-COUNT-10S); 1 on 1min order rate limit(X-MBX-ORDER-COUNT-1M); 5 on IP rate limit(x-mbx-used-weight-1m);
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
batchOrders | LIST<JSON> | YES | order list. Max 5 orders |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Where batchOrders
is the list of order parameters in JSON
- Example: /fapi/v1/batchOrders?batchOrders=[{"type":"LIMIT","timeInForce":"GTC",
"symbol":"BTCUSDT","side":"BUY","price":"10001","quantity":"0.001"}]
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
side | ENUM | YES | |
positionSide | ENUM | NO | Default BOTH for One-way Mode ; LONG or SHORT for Hedge Mode. It must be sent with Hedge Mode. |
type | ENUM | YES | |
timeInForce | ENUM | NO | |
quantity | DECIMAL | YES | |
reduceOnly | STRING | NO | "true" or "false". default "false". |
price | DECIMAL | NO | |
newClientOrderId | STRING | NO | A unique id among open orders. Automatically generated if not sent. Can only be string following the rule: ^[\.A-Z\:/a-z0-9_-]{1,36}$ |
stopPrice | DECIMAL | NO | Used with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders. |
activationPrice | DECIMAL | NO | Used with TRAILING_STOP_MARKET orders, default as the latest price(supporting different workingType ) |
callbackRate | DECIMAL | NO | Used with TRAILING_STOP_MARKET orders, min 0.1, max 4 where 1 for 1% |
workingType | ENUM | NO | stopPrice triggered by: "MARK_PRICE", "CONTRACT_PRICE". Default "CONTRACT_PRICE" |
priceProtect | STRING | NO | "TRUE" or "FALSE", default "FALSE". Used with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders. |
newOrderRespType | ENUM | NO | "ACK", "RESULT", default "ACK" |
priceMatch | ENUM | NO | only avaliable for LIMIT /STOP /TAKE_PROFIT order; can be set to OPPONENT / OPPONENT_5 / OPPONENT_10 / OPPONENT_20 : /QUEUE / QUEUE_5 / QUEUE_10 / QUEUE_20 ; Can't be passed together with price |
selfTradePreventionMode | ENUM | NO | NONE :No STP / EXPIRE_TAKER :expire taker order when STP triggers/ EXPIRE_MAKER :expire maker order when STP triggers/ EXPIRE_BOTH :expire both orders when STP triggers |
goodTillDate | LONG | NO | order cancel time for timeInForce GTD , mandatory when timeInforce set to GTD ; order the timestamp only retains second-level precision, ms part will be ignored; The goodTillDate timestamp must be greater than the current time plus 600 seconds and smaller than 253402300799000 |
- Paremeter rules are same with
New Order
- Batch orders are processed concurrently, and the order of matching is not guaranteed.
- The order of returned contents for batch orders is the same as the order of the order list.
Modify Multiple Orders (TRADE)
Response:
[
{
"orderId": 20072994037,
"symbol": "BTCUSDT",
"pair": "BTCUSDT",
"status": "NEW",
"clientOrderId": "LJ9R4QZDihCaS8UAOOLpgW",
"price": "30005",
"avgPrice": "0.0",
"origQty": "1",
"executedQty": "0",
"cumQty": "0",
"cumBase": "0",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "LONG",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
"updateTime": 1629182711600
},
{
"code": -2022,
"msg": "ReduceOnly Order is rejected."
}
]
PUT /fapi/v1/batchOrders
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
batchOrders | list<JSON> | YES | order list. Max 5 orders |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Where batchOrders
is the list of order parameters in JSON
Name | Type | Mandatory | Description |
---|---|---|---|
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
symbol | STRING | YES | |
side | ENUM | YES | SELL , BUY |
quantity | DECIMAL | YES | Order quantity, cannot be sent with closePosition=true |
price | DECIMAL | YES | |
priceMatch | ENUM | NO | only avaliable for LIMIT /STOP /TAKE_PROFIT order; can be set to OPPONENT / OPPONENT_5 / OPPONENT_10 / OPPONENT_20 : /QUEUE / QUEUE_5 / QUEUE_10 / QUEUE_20 ; Can't be passed together with price |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Parameter rules are same with
Modify Order
- Batch modify orders are processed concurrently, and the order of matching is not guaranteed.
- The order of returned contents for batch modify orders is the same as the order of the order list.
- One order can only be modfied for less than 10000 times
- Order modification will preserve the original
selfTradePreventionMode
of the order
Get Order Modify History (USER_DATA)
Response:
[
{
"amendmentId": 5363, // Order modification ID
"symbol": "BTCUSDT",
"pair": "BTCUSDT",
"orderId": 20072994037,
"clientOrderId": "LJ9R4QZDihCaS8UAOOLpgW",
"time": 1629184560899, // Order modification time
"amendment": {
"price": {
"before": "30004",
"after": "30003.2"
},
"origQty": {
"before": "1",
"after": "1"
},
"count": 3 // Order modification count, representing the number of times the order has been modified
},
"priceMatch":"QUEUE_20"
},
{
"amendmentId": 5361,
"symbol": "BTCUSDT",
"pair": "BTCUSDT",
"orderId": 20072994037,
"clientOrderId": "LJ9R4QZDihCaS8UAOOLpgW",
"time": 1629184533946,
"amendment": {
"price": {
"before": "30005",
"after": "30004"
},
"origQty": {
"before": "1",
"after": "1"
},
"count": 2
},
"priceMatch":"QUEUE_20"
},
{
"amendmentId": 5325,
"symbol": "BTCUSDT",
"pair": "BTCUSDT",
"orderId": 20072994037,
"clientOrderId": "LJ9R4QZDihCaS8UAOOLpgW",
"time": 1629182711787,
"amendment": {
"price": {
"before": "30002",
"after": "30005"
},
"origQty": {
"before": "1",
"after": "1"
},
"count": 1
},
"priceMatch":"QUEUE_20"
}
]
GET /fapi/v1/orderAmendment
Get order modification history
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
startTime | LONG | NO | Timestamp in ms to get modification history from INCLUSIVE |
endTime | LONG | NO | Timestamp in ms to get modification history until INCLUSIVE |
limit | INT | NO | Default 1000; max 1000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Notes:
- Either
orderId
ororigClientOrderId
must be sent, and theorderId
will prevail if both are sent.
Query Order (USER_DATA)
Response:
{
"avgPrice": "0.00000",
"clientOrderId": "abc",
"cumQuote": "0",
"executedQty": "0",
"orderId": 1917641,
"origQty": "0.40",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "NEW",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"time": 1579276756075, // order time
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1579276756075, // update time
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
}
GET /fapi/v1/order
Check an order's status.
Weight: 1
- These orders will not be found:
- order status is
CANCELED
orEXPIRED
AND order has NO filled trade AND created time + 3 days < current time - order create time + 90 days < current time
- order status is
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Notes:
- Either
orderId
ororigClientOrderId
must be sent. orderId
is self-increment for each specificsymbol
Cancel Order (TRADE)
Response:
{
"clientOrderId": "myOrder1",
"cumQty": "0",
"cumQuote": "0",
"executedQty": "0",
"orderId": 283194212,
"origQty": "11",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "CANCELED",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1571110484038,
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
}
DELETE /fapi/v1/order
Cancel an active order.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Either orderId
or origClientOrderId
must be sent.
Cancel All Open Orders (TRADE)
Response:
{
"code": 200,
"msg": "The operation of cancel all open order is done."
}
DELETE /fapi/v1/allOpenOrders
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Cancel Multiple Orders (TRADE)
Response:
[
{
"clientOrderId": "myOrder1",
"cumQty": "0",
"cumQuote": "0",
"executedQty": "0",
"orderId": 283194212,
"origQty": "11",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "CANCELED",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1571110484038,
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
},
{
"code": -2011,
"msg": "Unknown order sent."
}
]
DELETE /fapi/v1/batchOrders
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderIdList | LIST<LONG> | NO | max length 10 e.g. [1234567,2345678] |
origClientOrderIdList | LIST<STRING> | NO | max length 10 e.g. ["my_id_1","my_id_2"], encode the double quotes. No space after comma. |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Either orderIdList
or origClientOrderIdList
must be sent.
Auto-Cancel All Open Orders (TRADE)
Response:
{
"symbol": "BTCUSDT",
"countdownTime": "100000"
}
Cancel all open orders of the specified symbol at the end of the specified countdown.
POST /fapi/v1/countdownCancelAll
Weight: 10
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
countdownTime | LONG | YES | countdown time, 1000 for 1 second. 0 to cancel the timer |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
The endpoint should be called repeatedly as heartbeats so that the existing countdown time can be canceled and replaced by a new one.
Example usage:
Call this endpoint at 30s intervals with an countdownTime of 120000 (120s).
If this endpoint is not called within 120 seconds, all your orders of the specified symbol will be automatically canceled.
If this endpoint is called with an countdownTime of 0, the countdown timer will be stopped.The system will check all countdowns approximately every 10 milliseconds, so please note that sufficient redundancy should be considered when using this function. We do not recommend setting the countdown time to be too precise or too small.
Query Current Open Order (USER_DATA)
Response:
{
"avgPrice": "0.00000",
"clientOrderId": "abc",
"cumQuote": "0",
"executedQty": "0",
"orderId": 1917641,
"origQty": "0.40",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "NEW",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"time": 1579276756075, // order time
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1579276756075,
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
}
GET /fapi/v1/openOrder
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Either
orderId
ororigClientOrderId
must be sent - If the queried order has been filled or cancelled, the error message "Order does not exist" will be returned.
Current All Open Orders (USER_DATA)
Response:
[
{
"avgPrice": "0.00000",
"clientOrderId": "abc",
"cumQuote": "0",
"executedQty": "0",
"orderId": 1917641,
"origQty": "0.40",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "NEW",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"time": 1579276756075, // order time
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1579276756075, // update time
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
}
]
GET /fapi/v1/openOrders
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 | |
timestamp | LONG | YES |
- If the symbol is not sent, orders for all symbols will be returned in an array.
All Orders (USER_DATA)
Response:
[
{
"avgPrice": "0.00000",
"clientOrderId": "abc",
"cumQuote": "0",
"executedQty": "0",
"orderId": 1917641,
"origQty": "0.40",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "NEW",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"time": 1579276756075, // order time
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1579276756075, // update time
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading preventation mode
"goodTillDate": 0 //order pre-set auot cancel time for TIF GTD order
}
]
GET /fapi/v1/allOrders
Get all account orders; active, canceled, or filled.
- These orders will not be found:
- order status is
CANCELED
orEXPIRED
AND order has NO filled trade AND created time + 3 days < current time - order create time + 90 days < current time
- order status is
Weight: 5
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 | |
timestamp | LONG | YES |
Notes:
- If
orderId
is set, it will get orders >= thatorderId
. Otherwise most recent orders are returned. - The query time period must be less then 7 days( default as the recent 7 days).
Futures Account Balance V3 (USER_DATA)
Response:
[
{
"accountAlias": "SgsR", // unique account code
"asset": "USDT", // asset name
"balance": "122607.35137903", // wallet balance
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1617939110373
}
]
GET /fapi/v3/balance
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Futures Account Balance V2 (USER_DATA)
Response:
[
{
"accountAlias": "SgsR", // unique account code
"asset": "USDT", // asset name
"balance": "122607.35137903", // wallet balance
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1617939110373
}
]
GET /fapi/v2/balance
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Account Information V3 (USER_DATA)
Response:
single-asset mode
{
"totalInitialMargin": "0.00000000", // total initial margin required with current mark price (useless with isolated positions), only for USDT asset
"totalMaintMargin": "0.00000000", // total maintenance margin required, only for USDT asset
"totalWalletBalance": "103.12345678", // total wallet balance, only for USDT asset
"totalUnrealizedProfit": "0.00000000", // total unrealized profit, only for USDT asset
"totalMarginBalance": "103.12345678", // total margin balance, only for USDT asset
"totalPositionInitialMargin": "0.00000000", // initial margin required for positions with current mark price, only for USDT asset
"totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price, only for USDT asset
"totalCrossWalletBalance": "103.12345678", // crossed wallet balance, only for USDT asset
"totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions, only for USDT asset
"availableBalance": "103.12345678", // available balance, only for USDT asset
"maxWithdrawAmount": "103.12345678" // maximum amount for transfer out, only for USDT asset
"assets": [ // For assets that are quote assets, USDT/USDC/BTC
{
"asset": "USDT", // asset name
"walletBalance": "23.72469206", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "23.72469206", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"updateTime": 1625474304765 // last update time
},
{
"asset": "USDC", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"updateTime": 1625474304765 // last update time
},
],
"positions": [ // positions of all symbols user had position/ open orders are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT",
"positionSide": "BOTH", // position side
"positionAmt": "1.000",
"unrealizedProfit": "0.00000000", // unrealized profit
"isolatedMargin": "0.00000000",
"notional": "0",
"isolatedWallet": "0",
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"updateTime": 0
}
]
}
OR multi-assets mode
{
"totalInitialMargin": "0.00000000", // the sum of USD value of all cross positions/open order initial margin
"totalMaintMargin": "0.00000000", // the sum of USD value of all cross positions maintenance margin
"totalWalletBalance": "126.72469206", // total wallet balance in USD
"totalUnrealizedProfit": "0.00000000", // total unrealized profit in USD
"totalMarginBalance": "126.72469206", // total margin balance in USD
"totalPositionInitialMargin": "0.00000000", // the sum of USD value of all cross positions initial margin
"totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price in USD
"totalCrossWalletBalance": "126.72469206", // crossed wallet balance in USD
"totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions in USD
"availableBalance": "126.72469206", // available balance in USD
"maxWithdrawAmount": "126.72469206" // maximum virtual amount for transfer out in USD
"assets": [
{
"asset": "USDT", // asset name
"walletBalance": "23.72469206", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "23.72469206", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
},
{
"asset": "BUSD", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
}
],
"positions": [ // positions of all symbols user had position are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT",
"positionSide": "BOTH", // position side
"positionAmt": "1.000",
"unrealizedProfit": "0.00000000", // unrealized profit
"isolatedMargin": "0.00000000",
"notional": "0",
"isolatedWallet": "0",
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"updateTime": 0
}
]
}
GET /fapi/v3/account
Get current account information. User in single-asset/ multi-assets mode will see different value, see comments in response section for detail. Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Account Information V2 (USER_DATA)
Response:
single-asset mode
{
"feeTier": 0, // account commission tier
"feeBurn": true, // "true": Fee Discount On; "false": Fee Discount Off
"canTrade": true, // if can trade
"canDeposit": true, // if can transfer in asset
"canWithdraw": true, // if can transfer out asset
"updateTime": 0, // reserved property, please ignore
"multiAssetsMargin": false,
"tradeGroupId": -1,
"totalInitialMargin": "0.00000000", // total initial margin required with current mark price (useless with isolated positions), only for USDT asset
"totalMaintMargin": "0.00000000", // total maintenance margin required, only for USDT asset
"totalWalletBalance": "23.72469206", // total wallet balance, only for USDT asset
"totalUnrealizedProfit": "0.00000000", // total unrealized profit, only for USDT asset
"totalMarginBalance": "23.72469206", // total margin balance, only for USDT asset
"totalPositionInitialMargin": "0.00000000", // initial margin required for positions with current mark price, only for USDT asset
"totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price, only for USDT asset
"totalCrossWalletBalance": "23.72469206", // crossed wallet balance, only for USDT asset
"totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions, only for USDT asset
"availableBalance": "23.72469206", // available balance, only for USDT asset
"maxWithdrawAmount": "23.72469206" // maximum amount for transfer out, only for USDT asset
"assets": [
{
"asset": "USDT", // asset name
"walletBalance": "23.72469206", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "23.72469206", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
},
{
"asset": "BUSD", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "103.12345678", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
}
],
"positions": [ // positions of all symbols in the market are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT", // symbol name
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"unrealizedProfit": "0.00000000", // unrealized profit
"positionInitialMargin": "0", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0", // initial margin required for open orders with current mark price
"leverage": "100", // current initial leverage
"isolated": true, // if the position is isolated
"entryPrice": "0.00000", // average entry price
"maxNotional": "250000", // maximum available notional with current leverage
"bidNotional": "0", // bids notional, ignore
"askNotional": "0", // ask notional, ignore
"positionSide": "BOTH", // position side
"positionAmt": "0", // position amount
"updateTime": 0 // last update time
}
]
}
OR multi-assets mode
{
"feeTier": 0, // account commission tier
"feeBurn": true, // "true": Fee Discount On; "false": Fee Discount Off
"canTrade": true, // if can trade
"canDeposit": true, // if can transfer in asset
"canWithdraw": true, // if can transfer out asset
"updateTime": 0, // reserved property, please ignore
"multiAssetsMargin": true,
"tradeGroupId": -1,
"totalInitialMargin": "0.00000000", // the sum of USD value of all cross positions/open order initial margin
"totalMaintMargin": "0.00000000", // the sum of USD value of all cross positions maintenance margin
"totalWalletBalance": "126.72469206", // total wallet balance in USD
"totalUnrealizedProfit": "0.00000000", // total unrealized profit in USD
"totalMarginBalance": "126.72469206", // total margin balance in USD
"totalPositionInitialMargin": "0.00000000", // the sum of USD value of all cross positions initial margin
"totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price in USD
"totalCrossWalletBalance": "126.72469206", // crossed wallet balance in USD
"totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions in USD
"availableBalance": "126.72469206", // available balance in USD
"maxWithdrawAmount": "126.72469206" // maximum virtual amount for transfer out in USD
"assets": [
{
"asset": "USDT", // asset name
"walletBalance": "23.72469206", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "23.72469206", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
},
{
"asset": "BUSD", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
}
],
"positions": [ // positions of all symbols in the market are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT", // symbol name
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"unrealizedProfit": "0.00000000", // unrealized profit
"positionInitialMargin": "0", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0", // initial margin required for open orders with current mark price
"leverage": "100", // current initial leverage
"isolated": true, // if the position is isolated
"entryPrice": "0.00000", // average entry price
"breakEvenPrice": "0.0", // average entry price
"maxNotional": "250000", // maximum available notional with current leverage
"bidNotional": "0", // bids notional, ignore
"askNotional": "0", // ask notional, ignore
"positionSide": "BOTH", // position side
"positionAmt": "0", // position amount
"updateTime": 0 // last update time
}
]
}
GET /fapi/v2/account
Get current account information. User in single-asset/ multi-assets mode will see different value, see comments in response section for detail. Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Change Initial Leverage (TRADE)
Response:
{
"leverage": 21,
"maxNotionalValue": "1000000",
"symbol": "BTCUSDT"
}
POST /fapi/v1/leverage
Change user's initial leverage of specific symbol market.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
leverage | INT | YES | target initial leverage: int from 1 to 125 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Change Margin Type (TRADE)
Response:
{
"code": 200,
"msg": "success"
}
POST /fapi/v1/marginType
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
marginType | ENUM | YES | ISOLATED, CROSSED |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Modify Isolated Position Margin (TRADE)
Response:
{
"amount": 100.0,
"code": 200,
"msg": "Successfully modify position margin.",
"type": 1
}
POST /fapi/v1/positionMargin
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
positionSide | ENUM | NO | Default BOTH for One-way Mode ; LONG or SHORT for Hedge Mode. It must be sent with Hedge Mode. |
amount | DECIMAL | YES | |
type | INT | YES | 1: Add position margin,2: Reduce position margin |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Only for isolated symbol
Get Position Margin Change History (TRADE)
Response:
[
{
"symbol": "BTCUSDT",
"type": 1,
"deltaType": "USER_ADJUST",
"amount": "23.36332311",
"asset": "USDT",
"time": 1578047897183,
"positionSide": "BOTH"
},
{
"symbol": "BTCUSDT",
"type": 1,
"deltaType": "USER_ADJUST",
"amount": "100",
"asset": "USDT",
"time": 1578047900425,
"positionSide": "LONG"
}
]
GET /fapi/v1/positionMargin/history
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
type | INT | NO | 1: Add position margin,2: Reduce position margin |
startTime | LONG | NO | |
endTime | LONG | NO | Default current time if not pass |
limit | INT | NO | Default: 500 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- The time between
startTime
andendTime
can't be more than 30 days
Position Information V3 (USER_DATA)
Response:
For One-way position mode:
[
{
"symbol": "ADAUSDT",
"positionSide": "BOTH", // position side
"positionAmt": "30",
"entryPrice": "0.385",
"breakEvenPrice": "0.385077",
"markPrice": "0.41047590",
"unRealizedProfit": "0.76427700", // unrealized profit
"liquidationPrice": "0",
"isolatedMargin": "0",
"notional": "12.31427700",
"marginAsset": "USDT",
"isolatedWallet": "0",
"initialMargin": "0.61571385", // initial margin required with current mark price
"maintMargin": "0.08004280", // maintenance margin required
"positionInitialMargin": "0.61571385",// initial margin required for positions with current mark price
"openOrderInitialMargin": "0", // initial margin required for open orders with current mark price
"adl": 2,
"bidNotional": "0", // bids notional, ignore
"askNotional": "0", // ask notional, ignore
"updateTime": 1720736417660
}
]
For Hedge position mode:
[
{
"symbol": "BTCUSDT",
"positionAmt": "0.001",
"entryPrice": "22185.2",
"breakEvenPrice": "0.0",
"markPrice": "21123.05052574",
"unRealizedProfit": "-1.06214947",
"liquidationPrice": "19731.45529116",
"leverage": "4",
"maxNotionalValue": "100000000",
"marginType": "cross",
"isolatedMargin": "0.00000000",
"isAutoAddMargin": "false",
"positionSide": "LONG",
"notional": "21.12305052",
"isolatedWallet": "0",
"updateTime": 1655217461579
},
{
"symbol": "BTCUSDT",
"positionAmt": "0.000",
"entryPrice": "0.0",
"breakEvenPrice": "0.0",
"markPrice": "21123.05052574",
"unRealizedProfit": "0.00000000",
"liquidationPrice": "0",
"leverage": "4",
"maxNotionalValue": "100000000",
"marginType": "cross",
"isolatedMargin": "0.00000000",
"isAutoAddMargin": "false",
"positionSide": "SHORT",
"notional": "0",
"isolatedWallet": "0",
"updateTime": 0
}
]
GET /fapi/v3/positionRisk
Get current position information(only symbol that has position or open orders will be returned).
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Note
Please use with user data stream ACCOUNT_UPDATE
to meet your timeliness and accuracy needs.
Position Information V2 (USER_DATA)
Response:
For One-way position mode:
[
{
"entryPrice": "0.00000",
"breakEvenPrice": "0.0",
"marginType": "isolated",
"isAutoAddMargin": "false",
"isolatedMargin": "0.00000000",
"leverage": "10",
"liquidationPrice": "0",
"markPrice": "6679.50671178",
"maxNotionalValue": "20000000",
"positionAmt": "0.000",
"notional": "0",,
"isolatedWallet": "0",
"symbol": "BTCUSDT",
"unRealizedProfit": "0.00000000",
"positionSide": "BOTH",
"updateTime": 0
}
]
For Hedge position mode:
[
{
"symbol": "BTCUSDT",
"positionAmt": "0.001",
"entryPrice": "22185.2",
"breakEvenPrice": "0.0",
"markPrice": "21123.05052574",
"unRealizedProfit": "-1.06214947",
"liquidationPrice": "19731.45529116",
"leverage": "4",
"maxNotionalValue": "100000000",
"marginType": "cross",
"isolatedMargin": "0.00000000",
"isAutoAddMargin": "false",
"positionSide": "LONG",
"notional": "21.12305052",
"isolatedWallet": "0",
"updateTime": 1655217461579
},
{
"symbol": "BTCUSDT",
"positionAmt": "0.000",
"entryPrice": "0.0",
"breakEvenPrice": "0.0",
"markPrice": "21123.05052574",
"unRealizedProfit": "0.00000000",
"liquidationPrice": "0",
"leverage": "4",
"maxNotionalValue": "100000000",
"marginType": "cross",
"isolatedMargin": "0.00000000",
"isAutoAddMargin": "false",
"positionSide": "SHORT",
"notional": "0",
"isolatedWallet": "0",
"updateTime": 0
}
]
GET /fapi/v2/positionRisk
Get current position information.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Note
Please use with user data stream ACCOUNT_UPDATE
to meet your timeliness and accuracy needs.
Account Trade List (USER_DATA)
Response:
[
{
"buyer": false,
"commission": "-0.07819010",
"commissionAsset": "USDT",
"id": 698759,
"maker": false,
"orderId": 25851813,
"price": "7819.01",
"qty": "0.002",
"quoteQty": "15.63802",
"realizedPnl": "-0.91539999",
"side": "SELL",
"positionSide": "SHORT",
"symbol": "BTCUSDT",
"time": 1569514978020
}
]
GET /fapi/v1/userTrades
Get trades for a specific account and symbol.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | This can only be used in combination with symbol |
startTime | LONG | NO | |
endTime | LONG | NO | |
fromId | LONG | NO | Trade id to fetch from. Default gets most recent trades. |
limit | INT | NO | Default 500; max 1000. |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- If
startTime
andendTime
are both not sent, then the last 7 days' data will be returned. - The time between
startTime
andendTime
cannot be longer than 7 days. - The parameter
fromId
cannot be sent withstartTime
orendTime
.
Get Income History (USER_DATA)
Response:
[
{
"symbol": "", // trade symbol, if existing
"incomeType": "TRANSFER", // income type
"income": "-0.37500000", // income amount
"asset": "USDT", // income asset
"info":"TRANSFER", // extra information
"time": 1570608000000,
"tranId":"9689322392", // transaction id
"tradeId":"" // trade id, if existing
},
{
"symbol": "BTCUSDT",
"incomeType": "COMMISSION",
"income": "-0.01000000",
"asset": "USDT",
"info":"COMMISSION",
"time": 1570636800000,
"tranId":"9689322392",
"tradeId": 2059192
}
]
GET /fapi/v1/income
Weight: 30
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
incomeType | STRING | NO | TRANSFER, WELCOME_BONUS, REALIZED_PNL, FUNDING_FEE, COMMISSION, INSURANCE_CLEAR, REFERRAL_KICKBACK, COMMISSION_REBATE, API_REBATE, CONTEST_REWARD, CROSS_COLLATERAL_TRANSFER, OPTIONS_PREMIUM_FEE, OPTIONS_SETTLE_PROFIT, INTERNAL_TRANSFER, AUTO_EXCHANGE, DELIVERED_SETTELMENT, COIN_SWAP_DEPOSIT, COIN_SWAP_WITHDRAW, POSITION_LIMIT_INCREASE_FEE |
startTime | LONG | NO | Timestamp in ms to get funding from INCLUSIVE. |
endTime | LONG | NO | Timestamp in ms to get funding until INCLUSIVE. |
page | INT | NO | |
limit | INT | NO | Default 100; max 1000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- If neither
startTime
norendTime
is sent, the recent 7-day data will be returned. - If
incomeType
is not sent, all kinds of flow will be returned - "trandId" is unique in the same incomeType for a user
- Income history only contains data for the last three months
Notional and Leverage Brackets (USER_DATA)
Response:
[
{
"symbol": "ETHUSDT",
"notionalCoef": 1.50, //user symbol bracket multiplier, only appears when user's symbol bracket is adjusted
"brackets": [
{
"bracket": 1, // Notional bracket
"initialLeverage": 75, // Max initial leverage for this bracket
"notionalCap": 10000, // Cap notional of this bracket
"notionalFloor": 0, // Notional threshold of this bracket
"maintMarginRatio": 0.0065, // Maintenance ratio for this bracket
"cum":0 // Auxiliary number for quick calculation
},
]
}
]
OR (if symbol sent)
{
"symbol": "ETHUSDT",
"notionalCoef": 1.50,
"brackets": [
{
"bracket": 1,
"initialLeverage": 75,
"notionalCap": 10000,
"notionalFloor": 0,
"maintMarginRatio": 0.0065,
"cum":0
},
]
}
GET /fapi/v1/leverageBracket
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Position ADL Quantile Estimation (USER_DATA)
Response:
[
{
"symbol": "ETHUSDT",
"adlQuantile":
{
// if the positions of the symbol are crossed margined in Hedge Mode, "LONG" and "SHORT" will be returned a same quantile value, and "HEDGE" will be returned instead of "BOTH".
"LONG": 3,
"SHORT": 3,
"HEDGE": 0 // only a sign, ignore the value
}
},
{
"symbol": "BTCUSDT",
"adlQuantile":
{
// for positions of the symbol are in One-way Mode or isolated margined in Hedge Mode
"LONG": 1, // adl quantile for "LONG" position in hedge mode
"SHORT": 2, // adl qauntile for "SHORT" position in hedge mode
"BOTH": 0 // adl qunatile for position in one-way mode
}
}
]
GET /fapi/v1/adlQuantile
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Values update every 30s.
Values 0, 1, 2, 3, 4 shows the queue position and possibility of ADL from low to high.
For positions of the symbol are in One-way Mode or isolated margined in Hedge Mode, "LONG", "SHORT", and "BOTH" will be returned to show the positions' adl quantiles of different position sides.
If the positions of the symbol are crossed margined in Hedge Mode:
- "HEDGE" as a sign will be returned instead of "BOTH";
- A same value caculated on unrealized pnls on long and short sides' positions will be shown for "LONG" and "SHORT" when there are positions in both of long and short sides.
User's Force Orders (USER_DATA)
Response:
[
{
"orderId": 6071832819,
"symbol": "BTCUSDT",
"status": "FILLED",
"clientOrderId": "autoclose-1596107620040000020",
"price": "10871.09",
"avgPrice": "10913.21000",
"origQty": "0.001",
"executedQty": "0.001",
"cumQuote": "10.91321",
"timeInForce": "IOC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "SELL",
"positionSide": "BOTH",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"origType": "LIMIT",
"time": 1596107620044,
"updateTime": 1596107620087
}
{
"orderId": 6072734303,
"symbol": "BTCUSDT",
"status": "FILLED",
"clientOrderId": "adl_autoclose",
"price": "11023.14",
"avgPrice": "10979.82000",
"origQty": "0.001",
"executedQty": "0.001",
"cumQuote": "10.97982",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "SHORT",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"origType": "LIMIT",
"time": 1596110725059,
"updateTime": 1596110725071
}
]
GET /fapi/v1/forceOrders
Weight: 20 with symbol, 50 without symbol
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
autoCloseType | ENUM | NO | "LIQUIDATION" for liquidation orders, "ADL" for ADL orders. |
startTime | LONG | NO | |
endTime | LONG | NO | |
limit | INT | NO | Default 50; max 100. |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- If "autoCloseType" is not sent, orders with both of the types will be returned
- If "startTime" is not sent, data within 7 days before "endTime" can be queried
Futures Trading Quantitative Rules Indicators (USER_DATA)
- For more information on this, please refer to the Futures Trading Quantitative Rules
Response:
{
"indicators": { // indicator: quantitative rules indicators, value: user's indicators value, triggerValue: trigger indicator value threshold of quantitative rules.
"BTCUSDT": [
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "UFR", // Unfilled Ratio (UFR)
"value": 0.05, // Current value
"triggerValue": 0.995 // Trigger value
},
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "IFER", // IOC/FOK Expiration Ratio (IFER)
"value": 0.99, // Current value
"triggerValue": 0.99 // Trigger value
},
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "GCR", // GTC Cancellation Ratio (GCR)
"value": 0.99, // Current value
"triggerValue": 0.99 // Trigger value
},
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "DR", // Dust Ratio (DR)
"value": 0.99, // Current value
"triggerValue": 0.99 // Trigger value
}
],
"ETHUSDT": [
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "UFR",
"value": 0.05,
"triggerValue": 0.995
},
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "IFER",
"value": 0.99,
"triggerValue": 0.99
},
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "GCR",
"value": 0.99,
"triggerValue": 0.99
}
{
"isLocked": true,
"plannedRecoverTime": 1545741270000,
"indicator": "DR",
"value": 0.99,
"triggerValue": 0.99
}
]
},
"updateTime": 1545741270000
}
Or (account violation triggered)
{
"indicators":{
"ACCOUNT":[
{
"indicator":"TMV", // Too many violations under multiple symbols trigger account violation
"value":10,
"triggerValue":1,
"plannedRecoverTime":1644919865000,
"isLocked":true
}
]
},
"updateTime":1644913304748
}
GET /fapi/v1/apiTradingStatus
Weight:
- 1 for a single symbol
- 10 when the symbol parameter is omitted
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Futures Account Configuration(USER_DATA)
Response:
{
"feeTier": 0, // account commission tier
"canTrade": true, // if can trade
"canDeposit": true, // if can transfer in asset
"canWithdraw": true, // if can transfer out asset
"dualSidePosition": true,
"updateTime": 0, // reserved property, please ignore
"multiAssetsMargin": false,
"tradeGroupId": -1
}
GET /fapi/v1/accountConfig
Query account configuration
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Symbol Configuration(USER_DATA)
Response:
{
"feeTier": 0, // account commission tier
"canTrade": true, // if can trade
"canDeposit": true, // if can transfer in asset
"canWithdraw": true, // if can transfer out asset
"dualSidePosition": true,
"updateTime": 0, // reserved property, please ignore
"multiAssetsMargin": false,
"tradeGroupId": -1
}
GET /fapi/v1/symbolConfig
Get current account symbol configuration.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
User Commission Rate (USER_DATA)
Response:
{
"symbol": "BTCUSDT",
"makerCommissionRate": "0.0002", // 0.02%
"takerCommissionRate": "0.0004" // 0.04%
}
GET /fapi/v1/commissionRate
Weight: 20
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Query User Rate Limit (USER_DATA)
Response:
[
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 10000,
},
{
"rateLimitType": "ORDERS",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 20000,
}
]
GET /fapi/v1/rateLimit/order
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Get Download Id For Futures Transaction History (USER_DATA)
Response:
{
"avgCostTimestampOfLast30d":7241837, // Average time taken for data download in the past 30 days
"downloadId":"546975389218332672",
}
GET /fapi/v1/income/asyn
Weight: 1500
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
startTime | LONG | YES | Timestamp in ms |
endTime | LONG | YES | Timestamp in ms |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Request Limitation is 5 times per month, shared by front end download page and rest api
- The time between
startTime
andendTime
can not be longer than 1 year
Get Futures Transaction History Download Link by Id (USER_DATA)
Response:
{
"downloadId":"545923594199212032",
"status":"completed", // Enum:completed,processing
"url":"www.binance.com", // The link is mapped to download id
"notified":true, // ignore
"expirationTimestamp":1645009771000, // The link would expire after this timestamp
"isExpired":null,
}
OR (Response when server is processing)
{
"downloadId":"545923594199212032",
"status":"processing",
"url":"",
"notified":false,
"expirationTimestamp":-1
"isExpired":null,
}
GET /fapi/v1/income/asyn/id
Weight: 10
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
downloadId | STRING | YES | get by download id api |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Download link expiration: 24h
Get Download Id For Futures Order History (USER_DATA)
Response:
{
"avgCostTimestampOfLast30d":7241837, // Average time taken for data download in the past 30 days
"downloadId":"546975389218332672",
}
GET /fapi/v1/order/asyn
Weight: 1500
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
startTime | LONG | YES | Timestamp in ms |
endTime | LONG | YES | Timestamp in ms |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Request Limitation is 10 times per month, shared by front end download page and rest api
- The time between
startTime
andendTime
can not be longer than 1 year
Get Futures Order History Download Link by Id (USER_DATA)
Response:
{
"downloadId":"545923594199212032",
"status":"completed", // Enum:completed,processing
"url":"www.binance.com", // The link is mapped to download id
"notified":true, // ignore
"expirationTimestamp":1645009771000, // The link would expire after this timestamp
"isExpired":null,
}
OR (Response when server is processing)
{
"downloadId":"545923594199212032",
"status":"processing",
"url":"",
"notified":false,
"expirationTimestamp":-1
"isExpired":null,
}
GET /fapi/v1/order/asyn/id
Weight: 10
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
downloadId | STRING | YES | get by download id api |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Download link expiration: 24h
Get Download Id For Futures Trade History (USER_DATA)
Response:
{
"avgCostTimestampOfLast30d":7241837, // Average time taken for data download in the past 30 days
"downloadId":"546975389218332672",
}
GET /fapi/v1/trade/asyn
Weight: 1500
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
startTime | LONG | YES | Timestamp in ms |
endTime | LONG | YES | Timestamp in ms |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Request Limitation is 5 times per month, shared by front end download page and rest api
- The time between
startTime
andendTime
can not be longer than 1 year
Get Futures Trade Download Link by Id (USER_DATA)
Response:
{
"downloadId":"545923594199212032",
"status":"completed", // Enum:completed,processing
"url":"www.binance.com", // The link is mapped to download id
"notified":true, // ignore
"expirationTimestamp":1645009771000, // The link would expire after this timestamp
"isExpired":null,
}
OR (Response when server is processing)
{
"downloadId":"545923594199212032",
"status":"processing",
"url":"",
"notified":false,
"expirationTimestamp":-1
"isExpired":null,
}
GET /fapi/v1/trade/asyn/id
Weight: 10
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
downloadId | STRING | YES | get by download id api |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Download link expiration: 24h
User Data Streams
- The base API endpoint is: https://fapi.binance.com
- A User Data Stream
listenKey
is valid for 60 minutes after creation. - Doing a
PUT
on alistenKey
will extend its validity for 60 minutes, if response-1125
error "This listenKey does not exist." Please usePOST /fapi/v1/listenKey
to recreatelistenKey
and use newlistenKey
to build connection. - Doing a
DELETE
on alistenKey
will close the stream and invalidate thelistenKey
. - Doing a
POST
on an account with an activelistenKey
will return the currently activelistenKey
and extend its validity for 60 minutes. The connection method for Websocket is:
- Base Url: wss://fstream.binance.com
- User Data Streams are accessed at /ws/<listenKey>
- Example:
wss://fstream.binance.com/ws/XaEAKTsQSRLZAGH9tuIu37plSRsdjmlAVBoNYPUITlTAko1WI22PgmBMpI1rS8Yh
For one connection(one user data), the user data stream payloads can guaranteed to be in order during heavy periods; Strongly recommend you order your updates using E
A single connection is only valid for 24 hours; expect to be disconnected at the 24 hour mark
Start User Data Stream (USER_STREAM)
Response:
{
"listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}
POST /fapi/v1/listenKey
Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active listenKey
, that listenKey
will be returned and its validity will be extended for 60 minutes. In very rare cases, this endpoint will still generate a new listenKey
when the account has a valid listenKey
. Please use this listenKey
to reestablish the connection. We do not recommend extending the listenKey
using this endpoint. Instead, we suggest using PUT /fapi/v1/listenKey
to extend the listenKey.
Weight: 1
Parameters:
None
Keepalive User Data Stream (USER_STREAM)
Response:
{
"listenKey": "3HBntNTepshgEdjIwSUIBgB9keLyOCg5qv3n6bYAtktG8ejcaW5HXz9Vx1JgIieg" //the listenkey which got extended
}
PUT /fapi/v1/listenKey
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 60 minutes. If response -1125
error "This listenKey does not exist." Please use POST /fapi/v1/listenKey
to recreate listenKey
and use new listenKey
to build connection.
Weight: 1
Parameters:
None
Close User Data Stream (USER_STREAM)
Response:
{}
DELETE /fapi/v1/listenKey
Close out a user data stream.
Weight: 1
Parameters:
None
Event: User Data Stream Expired
Payload:
{
"stream": "OfYGbUzi3PraNagEkdKuFwUHn48brFsItTdsuiIXrucEvD0rhRXZ7I6URWfE8YE8",
"data": {
"e": "listenKeyExpired", // event type
"E": "1699596037418", // event time
"listenKey": "OfYGbUzi3PraNagEkdKuFwUHn48brFsItTdsuiIXrucEvD0rhRXZ7I6URWfE8YE8"
}
}
When the listenKey
used for the user data stream turns expired, this event will be pushed.
Notice:
- This event is not related to the websocket disconnection.
- This event will be received only when a valid
listenKey
in connection got expired. - No more user data event will be updated after this event received until a new valid
listenKey
used.
Websocket User Data Request(To be deprecated)
- User data request need a successful connection with the user data stream with a listenKey.
- The following data can be sent through the websocket instance in order to request for user data. Examples can be seen below.
- The
id
used in the JSON payloads is an unsigned INT used as an identifier to uniquely identify the messages going back and forth.
Request Form
Response
{
"result"[
{
"req":"<listenKey>@account", // request name 1
"res": // response to the request name 1
...
},
{
"req":"<listenKey>@balance", // request name 2, if existing
"res": // response to the request name 2, if existing
...
}
]
"id": 12 // request ID
}
Request
{
"method": "REQUEST",
"params":
[
"<listenKey>
@account", // request name 1
"<listenKey>
@balance" // request name 2, if existing
],
"id": 12 // request ID.
}
Event: Margin Call
Payload:
{
"e":"MARGIN_CALL", // Event Type
"E":1587727187525, // Event Time
"cw":"3.16812045", // Cross Wallet Balance. Only pushed with crossed position margin call
"p":[ // Position(s) of Margin Call
{
"s":"ETHUSDT", // Symbol
"ps":"LONG", // Position Side
"pa":"1.327", // Position Amount
"mt":"CROSSED", // Margin Type
"iw":"0", // Isolated Wallet (if isolated position)
"mp":"187.17127", // Mark Price
"up":"-1.166074", // Unrealized PnL
"mm":"1.614445" // Maintenance Margin Required
}
]
}
- When the user's position risk ratio is too high, this stream will be pushed.
- This message is only used as risk guidance information and is not recommended for investment strategies.
- In the case of a highly volatile market, there may be the possibility that the user's position has been liquidated at the same time when this stream is pushed out.
- Under cross margin mode, this stream will be pushed 1 time every 1 hour if margin call triggered; Under isolated margin mode, this stream will be pushed 1 time every 1 hour for each symbol if margin call triggered
Event: Balance and Position Update
Payload:
{
"e": "ACCOUNT_UPDATE", // Event Type
"E": 1564745798939, // Event Time
"T": 1564745798938 , // Transaction
"a": // Update Data
{
"m":"ORDER", // Event reason type
"B":[ // Balances
{
"a":"USDT", // Asset
"wb":"122624.12345678", // Wallet Balance
"cw":"100.12345678", // Cross Wallet Balance
"bc":"50.12345678" // Balance Change except PnL and Commission
},
{
"a":"BUSD",
"wb":"1.00000000",
"cw":"0.00000000",
"bc":"-49.12345678"
}
],
"P":[
{
"s":"BTCUSDT", // Symbol
"pa":"0", // Position Amount
"ep":"0.00000", // Entry Price
"bep":"0", // breakeven price
"cr":"200", // (Pre-fee) Accumulated Realized
"up":"0", // Unrealized PnL
"mt":"isolated", // Margin Type
"iw":"0.00000000", // Isolated Wallet (if isolated position)
"ps":"BOTH" // Position Side
},
{
"s":"BTCUSDT",
"pa":"20",
"ep":"6563.66500",
"bep":"6563.6",
"cr":"0",
"up":"2850.21200",
"mt":"isolated",
"iw":"13200.70726908",
"ps":"LONG"
},
{
"s":"BTCUSDT",
"pa":"-10",
"ep":"6563.86000",
"bep":"6563.6",
"cr":"-45.04000000",
"up":"-1423.15600",
"mt":"isolated",
"iw":"6570.42511771",
"ps":"SHORT"
}
]
}
}
Event type is ACCOUNT_UPDATE
.
When balance or position get updated, this event will be pushed.
ACCOUNT_UPDATE
will be pushed only when update happens on user's account, including changes on balances, positions, or margin type.- Unfilled orders or cancelled orders will not make the event
ACCOUNT_UPDATE
pushed, since there's no change on positions. - "position" in
ACCOUNT_UPDATE
: Only symbols of changed positions will be pushed.
When "FUNDING FEE" changes to the user's balance, the event will be pushed with the brief message:
- When "FUNDING FEE" occurs in a crossed position,
ACCOUNT_UPDATE
will be pushed with only the balanceB
(including the "FUNDING FEE" asset only), without any positionP
message. - When "FUNDING FEE" occurs in an isolated position,
ACCOUNT_UPDATE
will be pushed with only the balanceB
(including the "FUNDING FEE" asset only) and the relative position messageP
( including the isolated position on which the "FUNDING FEE" occurs only, without any other position message).
- When "FUNDING FEE" occurs in a crossed position,
The field "m" represents the reason type for the event and may shows the following possible types:
- DEPOSIT
- WITHDRAW
- ORDER
- FUNDING_FEE
- WITHDRAW_REJECT
- ADJUSTMENT
- INSURANCE_CLEAR
- ADMIN_DEPOSIT
- ADMIN_WITHDRAW
- MARGIN_TRANSFER
- MARGIN_TYPE_CHANGE
- ASSET_TRANSFER
- OPTIONS_PREMIUM_FEE
- OPTIONS_SETTLE_PROFIT
- AUTO_EXCHANGE
- COIN_SWAP_DEPOSIT
- COIN_SWAP_WITHDRAW
The field "bc" represents the balance change except for PnL and commission.
Event: Order Update
Payload:
{
"e":"ORDER_TRADE_UPDATE", // Event Type
"E":1568879465651, // Event Time
"T":1568879465650, // Transaction Time
"o":{
"s":"BTCUSDT", // Symbol
"c":"TEST", // Client Order Id
// special client order id:
// starts with "autoclose-": liquidation order
// "adl_autoclose": ADL auto close order
// "settlement_autoclose-": settlement order for delisting or delivery
"S":"SELL", // Side
"o":"TRAILING_STOP_MARKET", // Order Type
"f":"GTC", // Time in Force
"q":"0.001", // Original Quantity
"p":"0", // Original Price
"ap":"0", // Average Price
"sp":"7103.04", // Stop Price. Please ignore with TRAILING_STOP_MARKET order
"x":"NEW", // Execution Type
"X":"NEW", // Order Status
"i":8886774, // Order Id
"l":"0", // Order Last Filled Quantity
"z":"0", // Order Filled Accumulated Quantity
"L":"0", // Last Filled Price
"N":"USDT", // Commission Asset, will not push if no commission
"n":"0", // Commission, will not push if no commission
"T":1568879465650, // Order Trade Time
"t":0, // Trade Id
"b":"0", // Bids Notional
"a":"9.91", // Ask Notional
"m":false, // Is this trade the maker side?
"R":false, // Is this reduce only
"wt":"CONTRACT_PRICE", // Stop Price Working Type
"ot":"TRAILING_STOP_MARKET",// Original Order Type
"ps":"LONG", // Position Side
"cp":false, // If Close-All, pushed with conditional order
"AP":"7476.89", // Activation Price, only puhed with TRAILING_STOP_MARKET order
"cr":"5.0", // Callback Rate, only puhed with TRAILING_STOP_MARKET order
"pP": false, // If price protection is turned on
"si": 0, // ignore
"ss": 0, // ignore
"rp":"0", // Realized Profit of the trade
"V":"EXPIRE_TAKER", // STP mode
"pm":"OPPONENT", // Price match mode
"gtd":0 // TIF GTD order auto cancel time
}
}
When new order created, order status changed will push such event.
event type is ORDER_TRADE_UPDATE
.
Side
- BUY
- SELL
Order Type
- MARKET
- LIMIT
- STOP
- TAKE_PROFIT
- LIQUIDATION
Execution Type
- NEW
- CANCELED
- CALCULATED - Liquidation Execution
- EXPIRED
- TRADE
- AMENDMENT - Order Modified
Order Status
- NEW
- PARTIALLY_FILLED
- FILLED
- CANCELED
- EXPIRED
- EXPIRED_IN_MATCH
Time in force
- GTC
- IOC
- FOK
- GTX
Working Type
- MARK_PRICE
- CONTRACT_PRICE
Liquidation and ADL:
If user gets liquidated due to insufficient margin balance:
c
shows as "autoclose-XXX",X
shows as "NEW"
If user has enough margin balance but gets ADL:
c
shows as “adl_autoclose”,X
shows as “NEW”
Event: Account Configuration Update previous Leverage Update
Payload:
{
"e":"ACCOUNT_CONFIG_UPDATE", // Event Type
"E":1611646737479, // Event Time
"T":1611646737476, // Transaction Time
"ac":{
"s":"BTCUSDT", // symbol
"l":25 // leverage
}
}
Or
{
"e":"ACCOUNT_CONFIG_UPDATE", // Event Type
"E":1611646737479, // Event Time
"T":1611646737476, // Transaction Time
"ai":{ // User's Account Configuration
"j":true // Multi-Assets Mode
}
}
When the account configuration is changed, the event type will be pushed as ACCOUNT_CONFIG_UPDATE
When the leverage of a trade pair changes, the payload will contain the object ac
to represent the account configuration of the trade pair, where s
represents the specific trade pair and l
represents the leverage
When the user Multi-Assets margin mode changes the payload will contain the object ai
representing the user account configuration, where j
represents the user Multi-Assets margin mode
Event: STRATEGY_UPDATE
Payload:
{
"e": "STRATEGY_UPDATE", // Event Type
"T": 1669261797627, // Transaction Time
"E": 1669261797628, // Event Time
"su": {
"si": 176054594, // Strategy ID
"st": "GRID", // Strategy Type
"ss": "NEW", // Strategy Status
"s": "BTCUSDT", // Symbol
"ut": 1669261797627, // Update Time
"c": 8007 // opCode
}
}
STRATEGY_UPDATE
update when a strategy is created/cancelled/expired, ...etc.
Strategy Status
- NEW
- WORKING
- CANCELLED
- EXPIRED
opCode
- 8001: The strategy params have been updated
- 8002: User cancelled the strategy
- 8003: User manually placed or cancelled an order
- 8004: The stop limit of this order reached
- 8005: User position liquidated
- 8006: Max open order limit reached
- 8007: New grid order
- 8008: Margin not enough
- 8009: Price out of bounds
- 8010: Market is closed or paused
- 8011: Close position failed, unable to fill
- 8012: Exceeded the maximum allowable notional value at current leverage
- 8013: Grid expired due to incomplete KYC verification or access from a restricted jurisdiction
- 8014: Violated Futures Trading Quantitative Rules. Strategy stopped
- 8015: User position empty or liquidated
Event: GRID_UPDATE
Payload:
{
"e": "GRID_UPDATE", // Event Type
"T": 1669262908216, // Transaction Time
"E": 1669262908218, // Event Time
"gu": {
"si": 176057039, // Strategy ID
"st": "GRID", // Strategy Type
"ss": "WORKING", // Strategy Status
"s": "BTCUSDT", // Symbol
"r": "-0.00300716", // Realized PNL
"up": "16720", // Unmatched Average Price
"uq": "-0.001", // Unmatched Qty
"uf": "-0.00300716", // Unmatched Fee
"mp": "0.0", // Matched PNL
"ut": 1669262908197 // Update Time
}
}
GRID_UPDATE
update when a sub order of a grid is filled or partially filled.
Strategy Status
- NEW
- WORKING
- CANCELLED
- EXPIRED
Event: Conditional_Order_Trigger_Reject
Payload:
{
"e":"CONDITIONAL_ORDER_TRIGGER_REJECT", // Event Type
"E":1685517224945, // Event Time
"T":1685517224955, // me message send Time
"or":{
"s":"ETHUSDT", // Symbol
"i":155618472834, // orderId
"r":"Due to the order could not be filled immediately, the FOK order has been rejected. The order will not be recorded in the order history", // reject reason
}
}
CONDITIONAL_ORDER_TRIGGER_REJECT
update when a triggered TP/SL order got rejected.
Portfolio Margin Pro Endpoints
The Binance Portfolio Margin Pro Program is a cross-asset margin program supporting consolidated margin balance across trading products with over 200+ effective crypto collaterals. It is designed for professional traders, market makers, and institutional users looking to actively trade & hedge cross-asset and optimize risk-management in a consolidated setup.
FAQ: Portfolio Margin Pro Program
Only Portfolio Margin Pro Account is accessible to these endpoints. To enroll, kindly refer to: How to Enroll into the Binance Portfolio Margin Pro Program
Portfolio Margin Pro Account Information (USER_DATA)
Response:
{
"maxWithdrawAmountUSD": "1627523.32459208", // Portfolio Margin Pro maximum virtual amount for transfer out in USD
"asset": "BTC", // asset name
"maxWithdrawAmount": "27.43689636", // Please ignore
}
GET /fapi/v1/pmAccountInfo
Get Portfolio Margin Pro current account information.
Weight(IP): 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
asset | STRING | YES | |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- maxWithdrawAmount is for asset transfer out to the spot wallet.
Portfolio Margin Pro User Data Stream
- The websocket base url is: wss://fstream.binance.com/pm-classic
- User Data Streams are accessed at /ws/
- Example:
wss://fstream.binance.com/pm-classic/ws/XaEAKTsQSRLZAGH9tuIu37plSRsdjmlAVBoNYPUITlTAko1WI22PgmBMpI1rS8Yh
Event: riskLevelChange
Payload:
{
"e":"riskLevelChange", // Event Type
"E":1587727187525, // Event Time
"u":"1.99999999", // uniMMR level
"s":"MARGIN_CALL", //MARGIN_CALL, SUPPLY_MARGIN, REDUCE_ONLY, FORCE_LIQUIDATION
"eq":"30.23416728", // account equity in USD value
"ae":"30.23416728", // actual equity without collateral rate in USD value
"m":"15.11708371" // total maintenance margin in USD value
}
When the user's position risk ratio changes, this stream will be pushed.
This message is only used as risk guidance information and is not recommended for investment strategies.
RISK_LEVEL_CHANGE
includes following types:MARGIN_CALL
, SUPPLY_MARGIN
, REDUCE_ONLY
, FORCE_LIQUIDATION
In the case of a highly volatile market, there may be the possibility that the user's position has been liquidated at the same time when this stream is pushed out.
WebSocket API
New Order (TRADE)
Request
{
"id": "3f7df6e3-2df4-44b9-9919-d2f38f90a99a",
"method": "order.place",
"params": {
"apiKey": "HMOchcfii9ZRZnhjp2XjGXhsOBd6msAhKz9joQaWwZ7arcJTlD2hGPHQj1lGdTjR",
"positionSide": "BOTH",
"price": "43187.00",
"quantity": 0.1,
"side": "BUY",
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"timestamp": 1702555533821,
"type": "LIMIT",
"signature": "0f04368b2d22aafd0ggc8809ea34297eff602272917b5f01267db4efbc1c9422"
}
}
Response
{
"id": "3f7df6e3-2df4-44b9-9919-d2f38f90a99a",
"status": 200,
"result": {
"orderId": 325078477,
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "iCXL1BywlBaf2sesNUrVl3",
"price": "43187.00",
"avgPrice": "0.00",
"origQty": "0.100",
"executedQty": "0.000",
"cumQty": "0.000",
"cumQuote": "0.00000",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "BOTH",
"stopPrice": "0.00",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"priceMatch": "NONE",
"selfTradePreventionMode": "NONE",
"goodTillDate": 0,
"updateTime": 1702555534435
},
"rateLimits": [
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 300,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200,
"count": 1
},
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 1
}
]
}
Send in a new order.
Weight: 0
Method:
order.place
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
side | ENUM | YES | |
positionSide | ENUM | NO | Default BOTH for One-way Mode; LONG or SHORT for Hedge Mode. It must be sent in Hedge Mode. |
type | ENUM | YES | |
timeInForce | ENUM | NO | |
quantity | DECIMAL | NO | Cannot be sent with closePosition =true (Close-All) |
reduceOnly | STRING | NO | true or false . default false . Cannot be sent in Hedge Mode; cannot be sent with closePosition =true |
price | DECIMAL | NO | |
newClientOrderId | STRING | NO | A unique id among open orders. Automatically generated if not sent. Can only be string following the rule: ^[\.A-Z\:/a-z0-9_-]{1,36}$ |
stopPrice | DECIMAL | NO | Used with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders. |
closePosition | STRING | NO | true , false ;Close-All,used with STOP_MARKET or TAKE_PROFIT_MARKET . |
activationPrice | DECIMAL | NO | Used with TRAILING_STOP_MARKET orders, default as the latest price(supporting different workingType) |
callbackRate | DECIMAL | NO | Used with TRAILING_STOP_MARKET orders, min 0.1, max 5 where 1 for 1% |
workingType | ENUM | NO | stopPrice triggered by: "MARK_PRICE", "CONTRACT_PRICE". Default "CONTRACT_PRICE" |
priceProtect | ENUM | NO | "TRUE" or "FALSE", default "FALSE". Used with STOP/STOP_MARKET or TAKE_PROFIT/TAKE_PROFIT_MARKET orders. |
newOrderRespType | ENUM | NO | ACK ,RESULT , default ACK |
priceMatch | ENUM | NO | only available for LIMIT /STOP /TAKE_PROFIT order; can be set to OPPONENT / OPPONENT_5 / OPPONENT_10 / OPPONENT_20 : /QUEUE / QUEUE_5 / QUEUE_10 / QUEUE_20 ; Can't be passed together with price |
selfTradePreventionMode | ENUM | NO | NONE / EXPIRE_TAKER / EXPIRE_MAKER / EXPIRE_BOTH ; default NONE |
goodTillDate | INT | NO | Order cancel time for timeInForce GTD , mandatory when timeInforce set to GTD ; order the timestamp only retains second-level precision, ms part will be ignored; The goodTillDate timestamp must be greater than the current time plus 600 seconds and smaller than 253402300799000 |
recvWindow | INT | NO | |
timestamp | INT | YES |
Additional mandatory parameters based on type
:
Type | Additional mandatory parameters |
---|---|
LIMIT |
timeInForce , quantity , price |
MARKET |
quantity |
STOP/TAKE_PROFIT |
quantity , price , stopPrice |
STOP_MARKET/TAKE_PROFIT_MARKET |
stopPrice |
TRAILING_STOP_MARKET |
callbackRate |
- Order with type
STOP
, parametertimeInForce
can be sent ( defaultGTC
). - Order with type
TAKE_PROFIT
, parametertimeInForce
can be sent ( defaultGTC
). - Condition orders will be triggered when:
- If parameter
priceProtect
is sent as true:- when price reaches the
stopPrice
,the difference rate between "MARK_PRICE" and "CONTRACT_PRICE" cannot be larger than the "triggerProtect" of the symbol - "triggerProtect" of a symbol can be got from
GET /fapi/v1/exchangeInfo
- when price reaches the
STOP
,STOP_MARKET
:- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >=
stopPrice
- SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <=
stopPrice
- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >=
TAKE_PROFIT
,TAKE_PROFIT_MARKET
:- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <=
stopPrice
- SELL: latest price ("MARK_PRICE" or "CONTRACT_PRICE") >=
stopPrice
- BUY: latest price ("MARK_PRICE" or "CONTRACT_PRICE") <=
TRAILING_STOP_MARKET
:- BUY: the lowest price after order placed <=
activationPrice
, and the latest price >= the lowest price * (1 +callbackRate
) - SELL: the highest price after order placed >=
activationPrice
, and the latest price <= the highest price * (1 -callbackRate
)
- BUY: the lowest price after order placed <=
- For
TRAILING_STOP_MARKET
, if you got such error code.{"code": -2021, "msg": "Order would immediately trigger."}
means that the parameters you send do not meet the following requirements:- BUY:
activationPrice
should be smaller than latest price. - SELL:
activationPrice
should be larger than latest price.
- BUY:
- If
newOrderRespType
is sent asRESULT
:MARKET
order: the final FILLED result of the order will be return directly.LIMIT
order with specialtimeInForce
: the final status result of the order(FILLED or EXPIRED) will be returned directly.
STOP_MARKET
,TAKE_PROFIT_MARKET
withclosePosition=true
:- Follow the same rules for condition orders.
- If triggered,close all current long position(if
SELL
) or current short position(ifBUY
). - Cannot be used with
quantity
parameter - Cannot be used with
reduceOnly
parameter - In Hedge Mode, cannot be used with
BUY
orders inLONG
position side. and cannot be used withSELL
orders inSHORT
position side
selfTradePreventionMode
is only effective whentimeInForce
set toIOC
orGTC
orGTD
.- In extreme market conditions, timeInForce
GTD
order auto cancel time might be delayed comparing togoodTillDate
- If parameter
Cancel order (TRADE)
Request
{
"id": "5633b6a2-90a9-4192-83e7-925c90b6a2fd",
"method": "order.cancel",
"params": {
"apiKey": "HsOehcfih8ZRxnhjp2XjGXhsOBd6msAhKz9joQaWwZ7arcJTlD2hGOGQj1lGdTjR",
"orderId": 283194212,
"symbol": "BTCUSDT",
"timestamp": 1703439070722,
"signature": "b09c49815b4e3f1f6098cd9fbe26a933a9af79803deaaaae03c29f719c08a8a8"
}
}
Response
{
"id": "5633b6a2-90a9-4192-83e7-925c90b6a2fd",
"status": 200,
"result": {
"clientOrderId": "myOrder1",
"cumQty": "0",
"cumQuote": "0",
"executedQty": "0",
"orderId": 283194212,
"origQty": "11",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "BUY",
"positionSide": "SHORT",
"status": "CANCELED",
"stopPrice": "9300", // please ignore when order type is TRAILING_STOP_MARKET
"closePosition": false, // if Close-All
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020", // activation price, only return with TRAILING_STOP_MARKET order
"priceRate": "0.3", // callback rate, only return with TRAILING_STOP_MARKET order
"updateTime": 1571110484038,
"workingType": "CONTRACT_PRICE",
"priceProtect": false, // if conditional order trigger is protected
"priceMatch": "NONE", //price match mode
"selfTradePreventionMode": "NONE", //self trading prevention mode
"goodTillDate": 0 //order pre-set auto cancel time for TIF GTD order
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 1
}
]
}
Cancel an active order.
Weight: 1
Method:
order.cancel
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | INT | NO | |
origClientOrderId | STRING | NO | |
recvWindow | INT | NO | |
timestamp | INT | YES |
- Either
orderId
ororigClientOrderId
must be sent.
Modify Order (TRADE)
Request
{
"id": "c8c271ba-de70-479e-870c-e64951c753d9",
"method": "order.modify",
"params": {
"apiKey": "HMOchcfiT9ZRZnhjp2XjGXhsOBd6msAhKz9joQaWwZ7arcJTlD2hGPHQj1lGdTjR",
"orderId": 328971409,
"origType": "LIMIT",
"positionSide": "SHORT",
"price": "43769.1",
"priceMatch": "NONE",
"quantity": "0.11",
"side": "SELL",
"symbol": "BTCUSDT",
"timestamp": 1703426755754,
"signature": "d30c9f0736a307f5a9988d4a40b688662d18324b17367d51421da5484e835923"
}
}
Response
{
"id": "c8c271ba-de70-479e-870c-e64951c753d9",
"status": 200,
"result": {
"orderId": 328971409,
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "xGHfltUMExx0TbQstQQfRX",
"price": "43769.10",
"avgPrice": "0.00",
"origQty": "0.110",
"executedQty": "0.000",
"cumQty": "0.000",
"cumQuote": "0.00000",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "SELL",
"positionSide": "SHORT",
"stopPrice": "0.00",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"priceMatch": "NONE",
"selfTradePreventionMode": "NONE",
"goodTillDate": 0,
"updateTime": 1703426756190
},
"rateLimits": [
{
"rateLimitType": "ORDERS",
"interval": "SECOND",
"intervalNum": 10,
"limit": 300,
"count": 1
},
{
"rateLimitType": "ORDERS",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 1200,
"count": 1
},
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 1
}
]
}
Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
Weight: 1 on 10s order rate limit(X-MBX-ORDER-COUNT-10S); 1 on 1min order rate limit(X-MBX-ORDER-COUNT-1M); 1 on IP rate limit(x-mbx-used-weight-1m)
Method:
order.modify
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
orderId | INT | NO | |
origClientOrderId | STRING | NO | |
symbol | STRING | YES | |
side | ENUM | YES | SELL , BUY ; side needs to be same as origin order` |
quantity | DECIMAL | YES | Order quantity, cannot be sent with closePosition=true |
price | DECIMAL | YES | |
priceMatch | ENUM | NO | only available for LIMIT ,STOP ,TAKE_PROFIT order; Can be set to OPPONENT / OPPONENT_5 / OPPONENT_10 / OPPONENT_20 /QUEUE / QUEUE_5 / QUEUE_10 / QUEUE_20 ;can't be passed price together with price |
recvWindow | INT | NO | |
timestamp | INT | YES |
- Either
orderId
ororigClientOrderId
must be sent, and theorderId
will prevail if both are sent. - Both
quantity
andprice
must be sent, which is different from dapi modify order endpoint. - When the new
quantity
orprice
doesn't satisfy PRICE_FILTER / PERCENT_FILTER / LOT_SIZE, amendment will be rejected and the order will stay as it is. - However the order will be cancelled by the amendment in the following situations:
- When the order is in partially filled status and the new
quantity
<=executedQty
- When the order is
GTX
and the new price will cause it to be executed immediately
- When the order is in partially filled status and the new
- One order can only be modified for less than 10000 times
- Modify order will set
selfTradePreventionMode
toNONE
Query Order (USER_DATA)
Request
{
"id": "0ce5d070-a5e5-4ff2-b57f-1556741a4204",
"method": "order.status",
"params": {
"apiKey": "HMOchcfii9ZRZnhjp2XjGXhsOBd6msAhKz9joQaWwZ7arcJTlD2hGPHQj1lGdTjR",
"orderId": 328999071,
"symbol": "BTCUSDT",
"timestamp": 1703441060152,
"signature": "ba48184fc38a71d03d2b5435bd67c1206e3191e989fe99bda1bc643a880dfdbf"
}
}
Response
{
"id": "0ce5d070-a5e5-4ff2-b57f-1556741a4204",
"status": 200,
"result": {
"orderId": 328999071,
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "bK2CASGXToGAKVsePruSCs",
"price": "43634.50",
"avgPrice": "0.00",
"origQty": "0.010",
"executedQty": "0.000",
"cumQuote": "0.00000",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "BOTH",
"stopPrice": "0.00",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"priceMatch": "NONE",
"selfTradePreventionMode": "NONE",
"goodTillDate": 0,
"time": 1703441059890,
"updateTime": 1703441059890
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 6
}
]
}
Check an order's status.
Weight: 1
Method:
order.status
- These orders will not be found:
- order status is
CANCELED
orEXPIRED
AND order has NO filled trade AND created time + 3 days < current time - order create time + 90 days < current time
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | INT | NO | |
origClientOrderId | STRING | NO | |
recvWindow | INT | NO | |
timestamp | INT | YES |
Notes:
- Either
orderId
ororigClientOrderId
must be sent. orderId
is self-increment for each specific symbol
Account information V2(USER_DATA)
Request
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"method": "v2/account.status",
"params": {
"apiKey": "xTaDyrmvA9XT2oBHHjy39zyPzKCvMdtH3b9q4xadkAg2dNSJXQGCxzui26L823W2",
"timestamp": 1702620814781,
"signature": "6bb98ef84170c70ba3d01f44261bfdf50fef374e551e590de22b5c3b729b1d8c"
}
}
Response
Single Asset Mode
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": {
"totalInitialMargin": "0.00000000", // total initial margin required with current mark price (useless with isolated positions), only for USDT asset
"totalMaintMargin": "0.00000000", // total maintenance margin required, only for USDT asset
"totalWalletBalance": "103.12345678", // total wallet balance, only for USDT asset
"totalUnrealizedProfit": "0.00000000", // total unrealized profit, only for USDT asset
"totalMarginBalance": "103.12345678", // total margin balance, only for USDT asset
"totalPositionInitialMargin": "0.00000000", // initial margin required for positions with current mark price, only for USDT asset
"totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price, only for USDT asset
"totalCrossWalletBalance": "103.12345678", // crossed wallet balance, only for USDT asset
"totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions, only for USDT asset
"availableBalance": "103.12345678", // available balance, only for USDT asset
"maxWithdrawAmount": "103.12345678" // maximum amount for transfer out, only for USDT asset
"assets": [ // For assets that are quote assets, USDT/USDC/BTC
{
"asset": "USDT", // asset name
"walletBalance": "23.72469206", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "23.72469206", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"updateTime": 1625474304765 // last update time
},
{
"asset": "USDC", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"updateTime": 1625474304765 // last update time
},
],
"positions": [ // positions of all symbols user had position/ open orders are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT",
"positionSide": "BOTH", // position side
"positionAmt": "1.000",
"unrealizedProfit": "0.00000000", // unrealized profit
"isolatedMargin": "0.00000000",
"notional": "0",
"isolatedWallet": "0",
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"updateTime": 0
}
]
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
Multi-Asset Mode
javascript { "id": "605a6d20-6588-4cb9-afa0-b0ab087507ba", "status": 200, "result": { "totalInitialMargin": "0.00000000", // the sum of USD value of all cross positions/open order initial margin "totalMaintMargin": "0.00000000", // the sum of USD value of all cross positions maintenance margin "totalWalletBalance": "126.72469206", // total wallet balance in USD "totalUnrealizedProfit": "0.00000000", // total unrealized profit in USD "totalMarginBalance": "126.72469206", // total margin balance in USD "totalPositionInitialMargin": "0.00000000", // the sum of USD value of all cross positions initial margin "totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price in USD "totalCrossWalletBalance": "126.72469206", // crossed wallet balance in USD "totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions in USD "availableBalance": "126.72469206", // available balance in USD "maxWithdrawAmount": "126.72469206" // maximum virtual amount for transfer out in USD "assets": [ { "asset": "USDT", // asset name "walletBalance": "23.72469206", // wallet balance "unrealizedProfit": "0.00000000", // unrealized profit "marginBalance": "23.72469206", // margin balance "maintMargin": "0.00000000", // maintenance margin required "initialMargin": "0.00000000", // total initial margin required with current mark price "positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price "openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price "crossWalletBalance": "23.72469206", // crossed wallet balance "crossUnPnl": "0.00000000" // unrealized profit of crossed positions "availableBalance": "126.72469206", // available balance "maxWithdrawAmount": "23.72469206", // maximum amount for transfer out "marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode "updateTime": 1625474304765 // last update time }, { "asset": "BUSD", // asset name "walletBalance": "103.12345678", // wallet balance "unrealizedProfit": "0.00000000", // unrealized profit "marginBalance": "103.12345678", // margin balance "maintMargin": "0.00000000", // maintenance margin required "initialMargin": "0.00000000", // total initial margin required with current mark price "positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price "openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price "crossWalletBalance": "103.12345678", // crossed wallet balance "crossUnPnl": "0.00000000" // unrealized profit of crossed positions "availableBalance": "126.72469206", // available balance "maxWithdrawAmount": "103.12345678", // maximum amount for transfer out "marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode "updateTime": 1625474304765 // last update time } ], "positions": [ // positions of all symbols user had position are returned // only "BOTH" positions will be returned with One-way mode // only "LONG" and "SHORT" positions will be returned with Hedge mode { "symbol": "BTCUSDT", "positionSide": "BOTH", // position side "positionAmt": "1.000", "unrealizedProfit": "0.00000000", // unrealized profit "isolatedMargin": "0.00000000", "notional": "0", "isolatedWallet": "0", "initialMargin": "0", // initial margin required with current mark price "maintMargin": "0", // maintenance margin required "updateTime": 0 } ] }, "rateLimits": [ { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 2400, "count": 20 } ] }
Get current account information. User in single-asset/ multi-assets mode will see different value, see comments in response section for detail.
Weight: 5
Method:
v2/account.status
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | INT | NO | |
timestamp | INT | YES |
Account information (USER_DATA)
Request
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"method": "account.status",
"params": {
"apiKey": "xTaDyrmvA9XT2oBHHjy39zyPzKCvMdtH3b9q4xadkAg2dNSJXQGCxzui26L823W2",
"timestamp": 1702620814781,
"signature": "6bb98ef84170c70ba3d01f44261bfdf50fef374e551e590de22b5c3b729b1d8c"
}
}
Response
Single Asset Mode
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": {
"feeTier": 0, // account commission tier
"canTrade": true, // if can trade
"canDeposit": true, // if can transfer in asset
"canWithdraw": true, // if can transfer out asset
"updateTime": 0, // reserved property, please ignore
"multiAssetsMargin": false,
"tradeGroupId": -1,
"totalInitialMargin": "0.00000000", // total initial margin required with current mark price (useless with isolated positions), only for USDT asset
"totalMaintMargin": "0.00000000", // total maintenance margin required, only for USDT asset
"totalWalletBalance": "23.72469206", // total wallet balance, only for USDT asset
"totalUnrealizedProfit": "0.00000000", // total unrealized profit, only for USDT asset
"totalMarginBalance": "23.72469206", // total margin balance, only for USDT asset
"totalPositionInitialMargin": "0.00000000", // initial margin required for positions with current mark price, only for USDT asset
"totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price, only for USDT asset
"totalCrossWalletBalance": "23.72469206", // crossed wallet balance, only for USDT asset
"totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions, only for USDT asset
"availableBalance": "23.72469206", // available balance, only for USDT asset
"maxWithdrawAmount": "23.72469206" // maximum amount for transfer out, only for USDT asset
"assets": [
{
"asset": "USDT", // asset name
"walletBalance": "23.72469206", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "23.72469206", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
},
{
"asset": "BUSD", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "103.12345678", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
}
],
"positions": [ // positions of all symbols in the market are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT", // symbol name
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"unrealizedProfit": "0.00000000", // unrealized profit
"positionInitialMargin": "0", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0", // initial margin required for open orders with current mark price
"leverage": "100", // current initial leverage
"isolated": true, // if the position is isolated
"entryPrice": "0.00000", // average entry price
"maxNotional": "250000", // maximum available notional with current leverage
"bidNotional": "0", // bids notional, ignore
"askNotional": "0", // ask notional, ignore
"positionSide": "BOTH", // position side
"positionAmt": "0", // position amount
"updateTime": 0 // last update time
}
]
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
Multi-Asset Mode
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": {
"feeTier": 0, // account commission tier
"canTrade": true, // if can trade
"canDeposit": true, // if can transfer in asset
"canWithdraw": true, // if can transfer out asset
"updateTime": 0, // reserved property, please ignore
"multiAssetsMargin": true,
"tradeGroupId": -1,
"totalInitialMargin": "0.00000000", // the sum of USD value of all cross positions/open order initial margin
"totalMaintMargin": "0.00000000", // the sum of USD value of all cross positions maintenance margin
"totalWalletBalance": "126.72469206", // total wallet balance in USD
"totalUnrealizedProfit": "0.00000000", // total unrealized profit in USD
"totalMarginBalance": "126.72469206", // total margin balance in USD
"totalPositionInitialMargin": "0.00000000", // the sum of USD value of all cross positions initial margin
"totalOpenOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price in USD
"totalCrossWalletBalance": "126.72469206", // crossed wallet balance in USD
"totalCrossUnPnl": "0.00000000", // unrealized profit of crossed positions in USD
"availableBalance": "126.72469206", // available balance in USD
"maxWithdrawAmount": "126.72469206" // maximum virtual amount for transfer out in USD
"assets": [
{
"asset": "USDT", // asset name
"walletBalance": "23.72469206", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "23.72469206", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
},
{
"asset": "BUSD", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "126.72469206", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
}
],
"positions": [ // positions of all symbols in the market are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT", // symbol name
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"unrealizedProfit": "0.00000000", // unrealized profit
"positionInitialMargin": "0", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0", // initial margin required for open orders with current mark price
"leverage": "100", // current initial leverage
"isolated": true, // if the position is isolated
"entryPrice": "0.00000", // average entry price
"breakEvenPrice": "0.0", // average entry price
"maxNotional": "250000", // maximum available notional with current leverage
"bidNotional": "0", // bids notional, ignore
"askNotional": "0", // ask notional, ignore
"positionSide": "BOTH", // position side
"positionAmt": "0", // position amount
"updateTime": 0 // last update time
}
]
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
Get current account information. User in single-asset/ multi-assets mode will see different value, see comments in response section for detail.
Weight: 5
Method:
account.status
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | INT | NO | |
timestamp | INT | YES |
Futures Account Balance V2(USER_DATA)
Request
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"method": "v2/account.balance",
"params": {
"apiKey": "xTaDyrmvA9XT2oBHHjy39zyPzKCvMdtH3b9q4xadkAg2dNSJXQGCxzui26L823W2",
"timestamp": 1702561978458,
"signature": "208bb94a26f99aa122b1319490ca9cb2798fccc81d9b6449521a26268d53217a"
}
}
Response
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": {
[
{
"accountAlias": "SgsR", // unique account code
"asset": "USDT", // asset name
"balance": "122607.35137903", // wallet balance
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1617939110373
}
]
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
Weight: 5
Method:
v2/account.balance
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | INT | NO | |
timestamp | INT | YES |
Futures Account Balance(USER_DATA)
Request
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"method": "account.balance",
"params": {
"apiKey": "xTaDyrmvA9XT2oBHHjy39zyPzKCvMdtH3b9q4xadkAg2dNSJXQGCxzui26L823W2",
"timestamp": 1702561978458,
"signature": "208bb94a26f99aa122b1319490ca9cb2798fccc81d9b6449521a26268d53217a"
}
}
Response
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": {
[
{
"accountAlias": "SgsR", // unique account code
"asset": "USDT", // asset name
"balance": "122607.35137903", // wallet balance
"crossWalletBalance": "23.72469206", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1617939110373
}
]
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
Weight: 5
Method:
account.balance
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | INT | NO | |
timestamp | INT | YES |
Position Information V2(USER_DATA)
Request
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"method": "v2/account.position",
"params": {
"apiKey": "xTaDyrmvA9XT2oBHHjy39zyPzKCvMdtH3b9q4xadkAg2dNSJXQGCxzui26L823W2",
"symbol": "BTCUSDT",
"timestamp": 1702920680303,
"signature": "31ab02a51a3989b66c29d40fcdf78216978a60afc6d8dc1c753ae49fa3164a2a"
}
}
Response
For One-way position mode:
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": [
{
"symbol": "BTCUSDT",
"positionSide": "BOTH",
"positionAmt": "1.000",
"entryPrice": "0.00000",
"breakEvenPrice": "0.0",
"markPrice": "6679.50671178",
"unrealizedProfit": "0.00000000",
"liquidationPrice": "0",
"isolatedMargin": "0.00000000",
"notional": "0",
"marginAsset": "USDT",
"isolatedWallet": "0",
"initialMargin": "0",
"maintMargin": "0",
"positionInitialMargin": "0",
"openOrderInitialMargin": "0",
"adl": 0,
"bidNotional": "0",
"askNotional": "0",
"updateTime": 0
}
],
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
For Hedge position mode:
javascript { "id": "605a6d20-6588-4cb9-afa0-b0ab087507ba", "status": 200, "result": [ { "symbol": "BTCUSDT", "positionSide": "LONG", "positionAmt": "1.000", "entryPrice": "0.00000", "breakEvenPrice": "0.0", "markPrice": "6679.50671178", "unrealizedProfit": "0.00000000", "liquidationPrice": "0", "isolatedMargin": "0.00000000", "notional": "0", "marginAsset": "USDT", "isolatedWallet": "0", "initialMargin": "0", "maintMargin": "0", "positionInitialMargin": "0", "openOrderInitialMargin": "0", "adl": 0, "bidNotional": "0", "askNotional": "0", "updateTime": 0 }, { "symbol": "BTCUSDT", "positionSide": "SHORT", "positionAmt": "1.000", "entryPrice": "0.00000", "breakEvenPrice": "0.0", "markPrice": "6679.50671178", "unrealizedProfit": "0.00000000", "liquidationPrice": "0", "isolatedMargin": "0.00000000", "notional": "0", "marginAsset": "USDT", "isolatedWallet": "0", "initialMargin": "0", "maintMargin": "0", "positionInitialMargin": "0", "openOrderInitialMargin": "0", "adl": 0, "bidNotional": "0", "askNotional": "0", "updateTime": 0 } ], "rateLimits": [ { "rateLimitType": "REQUEST_WEIGHT", "interval": "MINUTE", "intervalNum": 1, "limit": 2400, "count": 20 } ] }
Weight: 5
Method:
v2/account.position
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | INT | NO | |
timestamp | INT | YES |
Note
Please use with user data stream ACCOUNT_UPDATE
to meet your timeliness and accuracy needs.
Position Information(USER_DATA)
Request
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"method": "account.position",
"params": {
"apiKey": "xTaDyrmvA9XT2oBHHjy39zyPzKCvMdtH3b9q4xadkAg2dNSJXQGCxzui26L823W2",
"symbol": "BTCUSDT",
"timestamp": 1702920680303,
"signature": "31ab02a51a3989b66c29d40fcdf78216978a60afc6d8dc1c753ae49fa3164a2a"
}
}
Response
For One-way position mode:
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": [
{
"entryPrice": "0.00000",
"breakEvenPrice": "0.0",
"marginType": "isolated",
"isAutoAddMargin": "false",
"isolatedMargin": "0.00000000",
"leverage": "10",
"liquidationPrice": "0",
"markPrice": "6679.50671178",
"maxNotionalValue": "20000000",
"positionAmt": "0.000",
"notional": "0",
"isolatedWallet": "0",
"symbol": "BTCUSDT",
"unRealizedProfit": "0.00000000",
"positionSide": "BOTH",
"updateTime": 0
}
],
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
For Hedge position mode:
{
"id": "605a6d20-6588-4cb9-afa0-b0ab087507ba",
"status": 200,
"result": [
{
"symbol": "BTCUSDT",
"positionAmt": "0.001",
"entryPrice": "22185.2",
"breakEvenPrice": "0.0",
"markPrice": "21123.05052574",
"unRealizedProfit": "-1.06214947",
"liquidationPrice": "19731.45529116",
"leverage": "4",
"maxNotionalValue": "100000000",
"marginType": "cross",
"isolatedMargin": "0.00000000",
"isAutoAddMargin": "false",
"positionSide": "LONG",
"notional": "21.12305052",
"isolatedWallet": "0",
"updateTime": 1655217461579
},
{
"symbol": "BTCUSDT",
"positionAmt": "0.000",
"entryPrice": "0.0",
"breakEvenPrice": "0.0",
"markPrice": "21123.05052574",
"unRealizedProfit": "0.00000000",
"liquidationPrice": "0",
"leverage": "4",
"maxNotionalValue": "100000000",
"marginType": "cross",
"isolatedMargin": "0.00000000",
"isAutoAddMargin": "false",
"positionSide": "SHORT",
"notional": "0",
"isolatedWallet": "0",
"updateTime": 0
}
],
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 20
}
]
}
Weight: 5
Method:
account.position
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | |
recvWindow | INT | NO | |
timestamp | INT | YES |
Note
Please use with user data stream ACCOUNT_UPDATE
to meet your timeliness and accuracy needs.
Order book
Request
{
"id": "51e2affb-0aba-4821-ba75-f2625006eb43",
"method": "depth",
"params": {
"symbol": "BTCUSDT"
}
}
Response
{
"id": "51e2affb-0aba-4821-ba75-f2625006eb43",
"status": 200,
"result": {
"lastUpdateId": 1027024,
"E": 1589436922972, // Message output time
"T": 1589436922959, // Transaction time
"bids": [
[
"4.00000000", // PRICE
"431.00000000" // QTY
]
],
"asks": [
[
"4.00000200",
"12.00000000"
]
]
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 5
}
]
}
Get current order book. Note that this request returns limited market depth.
If you need to continuously monitor order book updates, please consider using Websocket Market Streams:
*
You can use depth
request together with <symbol>@depth
streams to maintain a local order book.
Weight: Adjusted based on the limit:
Limit | Weight |
---|---|
5,10,20,50 | 2 |
100 | 5 |
500 | 10 |
1000 | 20 |
Update Speed: 15ms
Method:
depth
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol |
STRING | YES | |
limit |
INT | NO | Default 500; Valid limits:[5, 10, 20, 50, 100, 500, 1000] |
Symbol Price Ticker
Request
{
"id": "9d32157c-a556-4d27-9866-66760a174b57",
"method": "ticker.price",
"params": {
"symbol": "BTCUSDT"
}
}
Response
{
"id": "9d32157c-a556-4d27-9866-66760a174b57",
"status": 200,
"result": {
"symbol": "BTCUSDT",
"price": "6000.01",
"time": 1589437530011 // Transaction time
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 2
}
]
}
OR
{
"id": "9d32157c-a556-4d27-9866-66760a174b57",
"status": 200,
"result": [
{
"symbol": "BTCUSDT",
"price": "6000.01",
"time": 1589437530011
}
],
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 2
}
]
}
Latest price for a symbol or symbols.
Weight:
* with symbol 1
* no symbol 2
Method:
ticker.price
Update Speed: real time
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol |
STRING | NO |
- If the symbol is not sent, prices for all symbols will be returned in an array.
Symbol Order Book Ticker
Request
{
"id": "9d32157c-a556-4d27-9866-66760a174b57",
"method": "ticker.book",
"params": {
"symbol": "BTCUSDT"
}
}
Response
{
"id": "9d32157c-a556-4d27-9866-66760a174b57",
"status": 200,
"result": {
"lastUpdateId": 1027024,
"symbol": "BTCUSDT",
"bidPrice": "4.00000000",
"bidQty": "431.00000000",
"askPrice": "4.00000200",
"askQty": "9.00000000",
"time": 1589437530011 // Transaction time
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 2
}
]
}
OR
{
"id": "9d32157c-a556-4d27-9866-66760a174b57",
"status": 200,
"result": [
{
"lastUpdateId": 1027024,
"symbol": "BTCUSDT",
"bidPrice": "4.00000000",
"bidQty": "431.00000000",
"askPrice": "4.00000200",
"askQty": "9.00000000",
"time": 1589437530011
}
],
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 2
}
]
}
Best price/qty on the order book for a symbol or symbols.
Weight:
2 for a single symbol; 5 when the symbol parameter is omitted.
Method:
ticker.book
Update Speed: real time
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
symbol |
STRING | NO |
- If the symbol is not sent, bookTickers for all symbols will be returned in an array.
Start user data stream (USER STREAM)
Request
{
"id": "d3df8a61-98ea-4fe0-8f4e-0fcea5d418b0",
"method": "userDataStream.start",
"params": {
"apiKey": "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A"
}
}
Response
{
"id": "d3df8a61-98ea-4fe0-8f4e-0fcea5d418b0",
"status": 200,
"result": {
"listenKey": "xs0mRXdAKlIPDRFrlPcw0qI41Eh3ixNntmymGyhrhgqo7L6FuLaWArTD7RLP"
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 2
}
]
}
The following requests manage User Data Stream subscriptions.
Note: You will need to establish a separate WebSocket connection to listen to user data streams.
Start a new user data stream.
The response will output a listen key that can be subscribed through on the Websocket stream afterwards.
Note: the stream will close in 60 minutes unless userDataStream.ping
requests are sent regularly.
Weight: 5
Method:
userDataStream.start
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
apiKey |
STRING | YES |
Ping user data stream (USER_STREAM)
Request
{
"id": "815d5fce-0880-4287-a567-80badf004c74",
"method": "userDataStream.ping",
"params": {
"listenKey": "xs0mRXdAKlIPDRFrlPcw0qI41Eh3ixNntmymGyhrhgqo7L6FuLaWArTD7RLP",
"apiKey": "vmPUZE6mv9SD5VNHk9HlWFsOr9aLE2zvsw0MuIgwCIPy8atIco14y7Ju91duEh8A"
}
}
Response
{
"id": "815d5fce-0880-4287-a567-80badf004c74",
"status": 200,
"result": {
"listenKey": "3HBntNTepshgEdjIwSUIBgB9keLyOCg5qv3n6bYAtktG8ejcaW5HXz9Vx1JgIieg"
},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 2
}
]
}
Ping a user data stream to keep it alive.
User data streams close automatically after 60 minutes, even if you're listening to them on WebSocket Streams. In order to keep the stream open, you have to regularly send pings using the userDataStream.ping
request.
It is recommended to send a ping once every 30 minutes.
Weight: 5
Method:
userDataStream.ping
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
listenKey |
STRING | YES | |
apiKey |
STRING | YES |
Stop user data stream (USER_STREAM)
Request
{
"id": "819e1b1b-8c06-485b-a13e-131326c69599",
"method": "userDataStream.stop",
"params": {
"listenKey": "xs0mRXdAKlIPDRFrlPcw0qI41Eh3ixNntmymGyhrhgqo7L6FuLaWArTD7RLP",
"apiKey": "vmPUZE6mv9SD5VNHk9HlWFsOr9aLE2zvsw0MuIgwCIPy8atIco14y7Ju91duEh8A"
}
}
Response
{
"id": "819e1b1b-8c06-485b-a13e-131326c69599",
"status": 200,
"result": {},
"rateLimits": [
{
"rateLimitType": "REQUEST_WEIGHT",
"interval": "MINUTE",
"intervalNum": 1,
"limit": 2400,
"count": 2
}
]
}
Explicitly stop and close the user data stream.
Weight: 5
Method:
userDataStream.stop
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
listenKey |
STRING | YES | |
apiKey |
STRING | YES |
Error Codes
Here is the error JSON payload:
{
"code":-1121,
"msg":"Invalid symbol."
}
Errors consist of two parts: an error code and a message.
Codes are universal,but messages can vary.
10xx - General Server or Network issues
-1000 UNKNOWN
- An unknown error occured while processing the request.
-1001 DISCONNECTED
- Internal error; unable to process your request. Please try again.
-1002 UNAUTHORIZED
- You are not authorized to execute this request.
-1003 TOO_MANY_REQUESTS
- Too many requests queued.
- Too many requests; please use the websocket for live updates.
- Too many requests; current limit is %s requests per minute. Please use the websocket for live updates to avoid polling the API.
- Way too many requests; IP banned until %s. Please use the websocket for live updates to avoid bans.
-1004 DUPLICATE_IP
- This IP is already on the white list
-1005 NO_SUCH_IP
- No such IP has been white listed
-1006 UNEXPECTED_RESP
- An unexpected response was received from the message bus. Execution status unknown.
-1007 TIMEOUT
- Timeout waiting for response from backend server. Send status unknown; execution status unknown.
-1008 SERVER_BUSY
- Server is currently overloaded with other requests. Please try again in a few minutes.
-1010 ERROR_MSG_RECEIVED
- ERROR_MSG_RECEIVED.
-1011 NON_WHITE_LIST
- This IP cannot access this route.
-1013 INVALID_MESSAGE
- INVALID_MESSAGE.
-1014 UNKNOWN_ORDER_COMPOSITION
- Unsupported order combination.
-1015 TOO_MANY_ORDERS
- Too many new orders.
- Too many new orders; current limit is %s orders per %s.
-1016 SERVICE_SHUTTING_DOWN
- This service is no longer available.
-1020 UNSUPPORTED_OPERATION
- This operation is not supported.
-1021 INVALID_TIMESTAMP
- Timestamp for this request is outside of the recvWindow.
- Timestamp for this request was 1000ms ahead of the server's time.
-1022 INVALID_SIGNATURE
- Signature for this request is not valid.
-1023 START_TIME_GREATER_THAN_END_TIME
- Start time is greater than end time.
-1099 NOT_FOUND
- Not found, unauthenticated, or unauthorized.
11xx - Request issues
-1100 ILLEGAL_CHARS
- Illegal characters found in a parameter.
- Illegal characters found in parameter '%s'; legal range is '%s'.
-1101 TOO_MANY_PARAMETERS
- Too many parameters sent for this endpoint.
- Too many parameters; expected '%s' and received '%s'.
- Duplicate values for a parameter detected.
-1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED
- A mandatory parameter was not sent, was empty/null, or malformed.
- Mandatory parameter '%s' was not sent, was empty/null, or malformed.
- Param '%s' or '%s' must be sent, but both were empty/null!
-1103 UNKNOWN_PARAM
- An unknown parameter was sent.
-1104 UNREAD_PARAMETERS
- Not all sent parameters were read.
- Not all sent parameters were read; read '%s' parameter(s) but was sent '%s'.
-1105 PARAM_EMPTY
- A parameter was empty.
- Parameter '%s' was empty.
-1106 PARAM_NOT_REQUIRED
- A parameter was sent when not required.
- Parameter '%s' sent when not required.
-1108 BAD_ASSET
- Invalid asset.
-1109 BAD_ACCOUNT
- Invalid account.
-1110 BAD_INSTRUMENT_TYPE
- Invalid symbolType.
-1111 BAD_PRECISION
- Precision is over the maximum defined for this asset.
-1112 NO_DEPTH
- No orders on book for symbol.
-1113 WITHDRAW_NOT_NEGATIVE
- Withdrawal amount must be negative.
-1114 TIF_NOT_REQUIRED
- TimeInForce parameter sent when not required.
-1115 INVALID_TIF
- Invalid timeInForce.
-1116 INVALID_ORDER_TYPE
- Invalid orderType.
-1117 INVALID_SIDE
- Invalid side.
-1118 EMPTY_NEW_CL_ORD_ID
- New client order ID was empty.
-1119 EMPTY_ORG_CL_ORD_ID
- Original client order ID was empty.
-1120 BAD_INTERVAL
- Invalid interval.
-1121 BAD_SYMBOL
- Invalid symbol.
-1122 INVALID_SYMBOL_STATUS
- Invalid symbol status.
-1125 INVALID_LISTEN_KEY
- This listenKey does not exist. Please use
POST /fapi/v1/listenKey
to recreatelistenKey
-1126 ASSET_NOT_SUPPORTED
- This asset is not supported.
-1127 MORE_THAN_XX_HOURS
- Lookup interval is too big.
- More than %s hours between startTime and endTime.
-1128 OPTIONAL_PARAMS_BAD_COMBO
- Combination of optional parameters invalid.
-1130 INVALID_PARAMETER
- Invalid data sent for a parameter.
- Data sent for parameter '%s' is not valid.
-1136 INVALID_NEW_ORDER_RESP_TYPE
- Invalid newOrderRespType.
20xx - Processing Issues
-2010 NEW_ORDER_REJECTED
- NEW_ORDER_REJECTED
-2011 CANCEL_REJECTED
- CANCEL_REJECTED
-2012 CANCEL_ALL_FAIL
- Batch cancel failure.
-2013 NO_SUCH_ORDER
- Order does not exist.
-2014 BAD_API_KEY_FMT
- API-key format invalid.
-2015 REJECTED_MBX_KEY
- Invalid API-key, IP, or permissions for action.
-2016 NO_TRADING_WINDOW
- No trading window could be found for the symbol. Try ticker/24hrs instead.
-2017 API_KEYS_LOCKED
- API Keys are locked on this account.
-2018 BALANCE_NOT_SUFFICIENT
- Balance is insufficient.
-2019 MARGIN_NOT_SUFFICIEN
- Margin is insufficient.
-2020 UNABLE_TO_FILL
- Unable to fill.
-2021 ORDER_WOULD_IMMEDIATELY_TRIGGER
- Order would immediately trigger.
-2022 REDUCE_ONLY_REJECT
- ReduceOnly Order is rejected.
-2023 USER_IN_LIQUIDATION
- User in liquidation mode now.
-2024 POSITION_NOT_SUFFICIENT
- Position is not sufficient.
-2025 MAX_OPEN_ORDER_EXCEEDED
- Reach max open order limit.
-2026 REDUCE_ONLY_ORDER_TYPE_NOT_SUPPORTED
- This OrderType is not supported when reduceOnly.
-2027 MAX_LEVERAGE_RATIO
- Exceeded the maximum allowable position at current leverage.
-2028 MIN_LEVERAGE_RATIO
- Leverage is smaller than permitted: insufficient margin balance.
40xx - Filters and other Issues
-4000 INVALID_ORDER_STATUS
- Invalid order status.
-4001 PRICE_LESS_THAN_ZERO
- Price less than 0.
-4002 PRICE_GREATER_THAN_MAX_PRICE
- Price greater than max price.
-4003 QTY_LESS_THAN_ZERO
- Quantity less than zero.
-4004 QTY_LESS_THAN_MIN_QTY
- Quantity less than min quantity.
-4005 QTY_GREATER_THAN_MAX_QTY
- Quantity greater than max quantity.
-4006 STOP_PRICE_LESS_THAN_ZERO
- Stop price less than zero.
-4007 STOP_PRICE_GREATER_THAN_MAX_PRICE
- Stop price greater than max price.
-4008 TICK_SIZE_LESS_THAN_ZERO
- Tick size less than zero.
-4009 MAX_PRICE_LESS_THAN_MIN_PRICE
- Max price less than min price.
-4010 MAX_QTY_LESS_THAN_MIN_QTY
- Max qty less than min qty.
-4011 STEP_SIZE_LESS_THAN_ZERO
- Step size less than zero.
-4012 MAX_NUM_ORDERS_LESS_THAN_ZERO
- Max mum orders less than zero.
-4013 PRICE_LESS_THAN_MIN_PRICE
- Price less than min price.
-4014 PRICE_NOT_INCREASED_BY_TICK_SIZE
- Price not increased by tick size.
-4015 INVALID_CL_ORD_ID_LEN
- Client order id is not valid.
- Client order id length should not be more than 36 chars
-4016 PRICE_HIGHTER_THAN_MULTIPLIER_UP
- Price is higher than mark price multiplier cap.
-4017 MULTIPLIER_UP_LESS_THAN_ZERO
- Multiplier up less than zero.
-4018 MULTIPLIER_DOWN_LESS_THAN_ZERO
- Multiplier down less than zero.
-4019 COMPOSITE_SCALE_OVERFLOW
- Composite scale too large.
-4020 TARGET_STRATEGY_INVALID
- Target strategy invalid for orderType '%s',reduceOnly '%b'.
-4021 INVALID_DEPTH_LIMIT
- Invalid depth limit.
- '%s' is not valid depth limit.
-4022 WRONG_MARKET_STATUS
- market status sent is not valid.
-4023 QTY_NOT_INCREASED_BY_STEP_SIZE
- Qty not increased by step size.
-4024 PRICE_LOWER_THAN_MULTIPLIER_DOWN
- Price is lower than mark price multiplier floor.
-4025 MULTIPLIER_DECIMAL_LESS_THAN_ZERO
- Multiplier decimal less than zero.
-4026 COMMISSION_INVALID
- Commission invalid.
%s
less than zero.%s
absolute value greater than%s
-4027 INVALID_ACCOUNT_TYPE
- Invalid account type.
-4028 INVALID_LEVERAGE
- Invalid leverage
- Leverage
%s
is not valid - Leverage
%s
already exist with%s
-4029 INVALID_TICK_SIZE_PRECISION
- Tick size precision is invalid.
-4030 INVALID_STEP_SIZE_PRECISION
- Step size precision is invalid.
-4031 INVALID_WORKING_TYPE
- Invalid parameter working type
- Invalid parameter working type:
%s
-4032 EXCEED_MAX_CANCEL_ORDER_SIZE
- Exceed maximum cancel order size.
- Invalid parameter working type:
%s
-4033 INSURANCE_ACCOUNT_NOT_FOUND
- Insurance account not found.
-4044 INVALID_BALANCE_TYPE
- Balance Type is invalid.
-4045 MAX_STOP_ORDER_EXCEEDED
- Reach max stop order limit.
-4046 NO_NEED_TO_CHANGE_MARGIN_TYPE
- No need to change margin type.
-4047 THERE_EXISTS_OPEN_ORDERS
- Margin type cannot be changed if there exists open orders.
-4048 THERE_EXISTS_QUANTITY
- Margin type cannot be changed if there exists position.
-4049 ADD_ISOLATED_MARGIN_REJECT
- Add margin only support for isolated position.
-4050 CROSS_BALANCE_INSUFFICIENT
- Cross balance insufficient.
-4051 ISOLATED_BALANCE_INSUFFICIENT
- Isolated balance insufficient.
-4052 NO_NEED_TO_CHANGE_AUTO_ADD_MARGIN
- No need to change auto add margin.
-4053 AUTO_ADD_CROSSED_MARGIN_REJECT
- Auto add margin only support for isolated position.
-4054 ADD_ISOLATED_MARGIN_NO_POSITION_REJECT
- Cannot add position margin: position is 0.
-4055 AMOUNT_MUST_BE_POSITIVE
- Amount must be positive.
-4056 INVALID_API_KEY_TYPE
- Invalid api key type.
-4057 INVALID_RSA_PUBLIC_KEY
- Invalid api public key
-4058 MAX_PRICE_TOO_LARGE
- maxPrice and priceDecimal too large,please check.
-4059 NO_NEED_TO_CHANGE_POSITION_SIDE
- No need to change position side.
-4060 INVALID_POSITION_SIDE
- Invalid position side.
-4061 POSITION_SIDE_NOT_MATCH
- Order's position side does not match user's setting.
-4062 REDUCE_ONLY_CONFLICT
- Invalid or improper reduceOnly value.
-4063 INVALID_OPTIONS_REQUEST_TYPE
- Invalid options request type
-4064 INVALID_OPTIONS_TIME_FRAME
- Invalid options time frame
-4065 INVALID_OPTIONS_AMOUNT
- Invalid options amount
-4066 INVALID_OPTIONS_EVENT_TYPE
- Invalid options event type
-4067 POSITION_SIDE_CHANGE_EXISTS_OPEN_ORDERS
- Position side cannot be changed if there exists open orders.
-4068 POSITION_SIDE_CHANGE_EXISTS_QUANTITY
- Position side cannot be changed if there exists position.
-4069 INVALID_OPTIONS_PREMIUM_FEE
- Invalid options premium fee
-4070 INVALID_CL_OPTIONS_ID_LEN
- Client options id is not valid.
- Client options id length should be less than 32 chars
-4071 INVALID_OPTIONS_DIRECTION
- Invalid options direction
-4072 OPTIONS_PREMIUM_NOT_UPDATE
- premium fee is not updated, reject order
-4073 OPTIONS_PREMIUM_INPUT_LESS_THAN_ZERO
- input premium fee is less than 0, reject order
-4074 OPTIONS_AMOUNT_BIGGER_THAN_UPPER
- Order amount is bigger than upper boundary or less than 0, reject order
-4075 OPTIONS_PREMIUM_OUTPUT_ZERO
- output premium fee is less than 0, reject order
-4076 OPTIONS_PREMIUM_TOO_DIFF
- original fee is too much higher than last fee
-4077 OPTIONS_PREMIUM_REACH_LIMIT
- place order amount has reached to limit, reject order
-4078 OPTIONS_COMMON_ERROR
- options internal error
-4079 INVALID_OPTIONS_ID
- invalid options id
- invalid options id: %s
- duplicate options id %d for user %d
-4080 OPTIONS_USER_NOT_FOUND
- user not found
- user not found with id: %s
-4081 OPTIONS_NOT_FOUND
- options not found
- options not found with id: %s
-4082 INVALID_BATCH_PLACE_ORDER_SIZE
- Invalid number of batch place orders.
- Invalid number of batch place orders: %s
-4083 PLACE_BATCH_ORDERS_FAIL
- Fail to place batch orders.
-4084 UPCOMING_METHOD
- Method is not allowed currently. Upcoming soon.
-4085 INVALID_NOTIONAL_LIMIT_COEF
- Invalid notional limit coefficient
-4086 INVALID_PRICE_SPREAD_THRESHOLD
- Invalid price spread threshold
-4087 REDUCE_ONLY_ORDER_PERMISSION
- User can only place reduce only order
-4088 NO_PLACE_ORDER_PERMISSION
- User can not place order currently
-4104 INVALID_CONTRACT_TYPE
- Invalid contract type
-4114 INVALID_CLIENT_TRAN_ID_LEN
- clientTranId is not valid
- Client tran id length should be less than 64 chars
-4115 DUPLICATED_CLIENT_TRAN_ID
- clientTranId is duplicated
- Client tran id should be unique within 7 days
-4118 REDUCE_ONLY_MARGIN_CHECK_FAILED
- ReduceOnly Order Failed. Please check your existing position and open orders
-4131 MARKET_ORDER_REJECT
- The counterparty's best price does not meet the PERCENT_PRICE filter limit
-4135 INVALID_ACTIVATION_PRICE
- Invalid activation price
-4137 QUANTITY_EXISTS_WITH_CLOSE_POSITION
- Quantity must be zero with closePosition equals true
-4138 REDUCE_ONLY_MUST_BE_TRUE
- Reduce only must be true with closePosition equals true
-4139 ORDER_TYPE_CANNOT_BE_MKT
- Order type can not be market if it's unable to cancel
-4140 INVALID_OPENING_POSITION_STATUS
- Invalid symbol status for opening position
-4141 SYMBOL_ALREADY_CLOSED
- Symbol is closed
-4142 STRATEGY_INVALID_TRIGGER_PRICE
- REJECT: take profit or stop order will be triggered immediately
-4144 INVALID_PAIR
- Invalid pair
-4161 ISOLATED_LEVERAGE_REJECT_WITH_POSITION
- Leverage reduction is not supported in Isolated Margin Mode with open positions
-4164 MIN_NOTIONAL
- Order's notional must be no smaller than 5.0 (unless you choose reduce only)
- Order's notional must be no smaller than %s (unless you choose reduce only)
-4165 INVALID_TIME_INTERVAL
- Invalid time interval
- Maximum time interval is %s days
-4167 ISOLATED_REJECT_WITH_JOINT_MARGIN
- Unable to adjust to Multi-Assets mode with symbols of USDⓈ-M Futures under isolated-margin mode.
-4168 JOINT_MARGIN_REJECT_WITH_ISOLATED
- Unable to adjust to isolated-margin mode under the Multi-Assets mode.
-4169 JOINT_MARGIN_REJECT_WITH_MB
- Unable to adjust Multi-Assets Mode with insufficient margin balance in USDⓈ-M Futures.
-4170 JOINT_MARGIN_REJECT_WITH_OPEN_ORDER
- Unable to adjust Multi-Assets Mode with open orders in USDⓈ-M Futures.
-4171 NO_NEED_TO_CHANGE_JOINT_MARGIN
- Adjusted asset mode is currently set and does not need to be adjusted repeatedly.
-4172 JOINT_MARGIN_REJECT_WITH_NEGATIVE_BALANCE
- Unable to adjust Multi-Assets Mode with a negative wallet balance of margin available asset in USDⓈ-M Futures account.
-4183 ISOLATED_REJECT_WITH_JOINT_MARGIN
- Price is higher than stop price multiplier cap.
- Limit price can't be higher than %s.
-4184 PRICE_LOWER_THAN_STOP_MULTIPLIER_DOWN
- Price is lower than stop price multiplier floor.
- Limit price can't be lower than %s.
-4192 COOLING_OFF_PERIOD
- Trade forbidden due to Cooling-off Period.
-4202 ADJUST_LEVERAGE_KYC_FAILED
- Intermediate Personal Verification is required for adjusting leverage over 20x
-4203 ADJUST_LEVERAGE_ONE_MONTH_FAILED
- More than 20x leverage is available one month after account registration.
-4205 ADJUST_LEVERAGE_X_DAYS_FAILED
- More than 20x leverage is available %s days after Futures account registration.
-4206 ADJUST_LEVERAGE_KYC_LIMIT
- Users in this country has limited adjust leverage.
- Users in your location/country can only access a maximum leverage of %s
-4208 ADJUST_LEVERAGE_ACCOUNT_SYMBOL_FAILED
- Current symbol leverage cannot exceed 20 when using position limit adjustment service.
-4209 ADJUST_LEVERAGE_SYMBOL_FAILED
- The max leverage of Symbol is 20x
- Leverage adjustment failed. Current symbol max leverage limit is %sx
-4210 STOP_PRICE_HIGHER_THAN_PRICE_MULTIPLIER_LIMIT
- Stop price is higher than price multiplier cap.
- Stop price can't be higher than %s
-4211 STOP_PRICE_LOWER_THAN_PRICE_MULTIPLIER_LIMIT
- Stop price is lower than price multiplier floor.
- Stop price can't be lower than %s
-4400 TRADING_QUANTITATIVE_RULE
- Futures Trading Quantitative Rules violated, only reduceOnly order is allowed, please try again later.
-4401 COMPLIANCE_RESTRICTION
- Compliance restricted account permission: can only place reduceOnly order.
-4402 COMPLIANCE_BLACK_SYMBOL_RESTRICTION
- Dear user, as per our Terms of Use and compliance with local regulations, this feature is currently not available in your region.
-4403 ADJUST_LEVERAGE_COMPLIANCE_FAILED
- Dear user, as per our Terms of Use and compliance with local regulations, the leverage can only up to 10x in your region
- Dear user, as per our Terms of Use and compliance with local regulations, the leverage can only up to %sx in your region
50xx - Order Execution Issues
-5021 FOK_ORDER_REJECT
- Due to the order could not be filled immediately, the FOK order has been rejected.
-5022 GTX_ORDER_REJECT
- Due to the order could not be executed as maker, the Post Only order will be rejected.
-5024 MOVE_ORDER_NOT_ALLOWED_SYMBOL_REASON
- Symbol is not in trading status. Order amendment is not permitted.
-5025 LIMIT_ORDER_ONLY
- Only limit order is supported.
-5026 Exceed_Maximum_Modify_Order_Limit
- Exceed maximum modify order limit.
-5027 SAME_ORDER
- No need to modify the order.
-5028 ME_RECVWINDOW_REJECT
- Timestamp for this request is outside of the ME recvWindow.
-5037 INVALID_PRICE_MATCH
- Invalid price match
-5038 UNSUPPORTED_ORDER_TYPE_PRICE_MATCH
- Price match only supports order type: LIMIT, STOP AND TAKE_PROFIT
-5039 INVALID_SELF_TRADE_PREVENTION_MODE
- Invalid self trade prevention mode
-5040 FUTURE_GOOD_TILL_DATE
- The goodTillDate timestamp must be greater than the current time plus 600 seconds and smaller than 253402300799000 (UTC 9999-12-31 23:59:59)
-5041 BBO_ORDER_REJECT
- No depth matches this BBO order