Change Log
General Information on Endpoints
- For
GET
endpoints, parameters must be sent as aquery string
without setting content type in the http headers.
**2023-02-02**
REST
- Endpoint
POST /eapi/v1/transfer
is disabled.
**2023-01-11**
REST
- Add endpoint
GET /eapi/v1/order
to check order status.
**2022-12-13**
WEBSOCKET
- Add
u
andpu
in stream<symbol>@depth1000
to get diff orderbook update.
**2022-12-09**
REST
- Add updateId field
u
inGET /eapi/v1/depth
- Add parameter
underlying
inGET /eapi/v1/exerciseHistory
to query exercise histroy by underlying
**2022-11-18**
REST
- New endpoint
GET /eapi/v1/openInterest
is added to get options open interest for specific underlying on certain expiration date.
WEBSOCKET
- New stream
<underlyingAsset>@openInterest@<expirationDate>
is added for real-time option open interest feed.
**2022-11-16**
WEBSOCKET
- New trade stream
<underlyingAsset>@trade
is added for all option trades on specific underlying asset. - Adjust format in stream
option_pair
.
**2022-11-03**
REST
- New endpoint for Auto-Cancel All Open Orders will be added on 2022-11-07:
POST /eapi/v1/countdownCancelAll
:Set Auto-Cancel All Open Orders (Kill-Switch) ConfigGET /eapi/v1/countdownCancelAll
:Get Auto-Cancel All Open Orders (Kill-Switch) ConfigPOST /eapi/v1/countdownCancelAllHeartBeat
:Auto-Cancel All Open Orders (Kill-Switch) Heartbeat
**2022-09-20**
WEBSOCKET
- New streams
<underlyingAsset>@markPrice
and<underlyingAsset>@ticker@<expirationDate>
are added. - Streams
<!miniTicker@arr>
will be deprecated on 2022/10/30.
**2022-09-14**
REST
- Adjust endpoint field
strikePrice
,makerFeeRate
,takerFeeRate
,minQty
,maxQty
,initialMargin
,maintenanceMargin
,minInitialMargin
,minMaintenanceMargin
to string in endpointGET /eapi/v1/exchangeInfo
- Only finished orders within 5 days can be queried in
GET /eapi/v1/historyOrders
**2022-09-05**
REST
- Adjust response result in endpoint
DELETE /eapi/v1/allOpenOrdersByUnderlying
**2022-08-22**
REST
- Add
rateLimits
information in endpointGET /eapi/v1/exchangeInfo
- Parameters
symbol
set to not mandatory inGET /eapi/v1/userTrades
General Info
#
General API Information- Some endpoints will require an API Key. Please refer to this page
- The base endpoint is: **https://eapi.binance.com
- All endpoints return either a JSON object or array.
- Data is returned in ascending order. Oldest first, newest last.
- All time and timestamp related fields are in milliseconds.
#
HTTP 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
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. - 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 "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:
- Specific error codes and messages defined in Error Codes.
#
General Information on Endpoints- For
GET
endpoints, parameters must be sent as aquery string
without setting content type in the http headers. - 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
/eapi/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 SecuritySIGNED
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:
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 /eapi/v1/orderHere 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 stringExample 1
HMAC SHA256 signature:
curl command:
- requestBody:
symbol=BTC-210129-40000-C
&side=BUY
&type=LIMIT
&timeInForce=GTC
&quantity=1
&price=2000
&recvWindow=5000
×tamp=1611825601400
#
Example 2: As a request bodyExample 2
HMAC SHA256 signature:
curl command:
- queryString:
symbol=BTC-210129-40000-C
&side=BUY
&type=LIMIT
&timeInForce=GTC
&quantity=1
&price=2000
&recvWindow=5000
×tamp=1611825601400
#
Example 3: Mixed query string and request bodyExample 3
HMAC SHA256 signature:
curl command:
- queryString:
symbol=BTC-210129-40000-C&side=BUY&type=LIMIT&timeInForce=GTC
- requestBody:
quantity=1&price=2000&recvWindow=5000×tamp=1611825601400
Note that the signature is different in example 3. There is no & between "GTC" and "quantity=1".
#
Public Endpoints Info#
Terminologysymbol
refers to the symbol name of a options contract symbolunderlying
refers to the underlying symbol of a options contract symbolquoteAsset
refers to the asset that is the price of a symbol.settleAsset
refers to the settlement asset when options are exercised
#
ENUM definitionsOptions contract type
- CALL
- PUT
Order side
- BUY
- SELL
Position side
- LONG
- SHORT
Time in force
- GTC - Good Till Cancel
- IOC - Immediate or Cancel
- FOK - Fill or Kill
Response Type (newOrderRespType)
- ACK
- RESULT
Order types (type)
- LIMIT
Order status (status)
- ACCEPTED
- REJECTED
- PARTIALLY_FILLED
- FILLED
- CANCELLED
Kline/Candlestick chart intervals:
m -> minutes; h -> hours; d -> days; w -> weeks; M -> months
- 1m
- 3m
- 5m
- 15m
- 30m
- 1h
- 2h
- 4h
- 6h
- 8h
- 12h
- 1d
- 3d
- 1w
- 1M
Rate limiters (rateLimitType)
REQUEST_WEIGHT
ORDERS
REQUEST_WEIGHT
ORDERS
Rate limit intervals (interval)
- MINUTE
#
FiltersFilters define trading rules on a symbol or an exchange.
#
Symbol filters#
PRICE_FILTER/exchangeInfo format:
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:
- sell order
price
>=minPrice
- buy order
price
<=maxPrice
- (
price
-minPrice
) %tickSize
== 0
#
LOT_SIZE/exchangeInfo format:
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 Data Endpoints
#
Test ConnectivityResponse:
GET /eapi/v1/ping
Test connectivity to the Rest API.
Weight: 1
Parameters: NONE
#
Check Server TimeResponse:
GET /eapi/v1/time
Test connectivity to the Rest API and get the current server time.
Weight: 1
Parameters: NONE
#
Exchange InformationResponse:
GET /eapi/v1/exchangeInfo
Current exchange trading rules and symbol information
Weight: 1
Parameters: NONE
#
Order BookResponse:
GET /eapi/v1/depth
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
limit | INT | NO | Default:100 Max:1000.Optional value:[10, 20, 50, 100, 500, 1000] |
#
Recent Trades ListResponse:
GET /eapi/v1/trades
Get recent market trades
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
limit | INT | NO | Number of records Default:100 Max:500 |
#
Old Trades Lookup (MARKET_DATA)Response:
GET /eapi/v1/historicalTrades
Get older market historical trades.
Weight: 20
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
fromId | LONG | NO | The UniqueId ID from which to return. The latest deal record is returned by default |
limit | INT | NO | Number of records Default:100 Max:500 |
#
Kline/Candlestick DataResponse:
GET /eapi/v1/klines
Kline/candlestick bars for an option symbol. Klines are uniquely identified by their open time.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
interval | STRING | YES | Time interval |
startTime | LONG | NO | Start Time 1592317127349 |
endTime | LONG | NO | End Time |
limit | INT | NO | Number of records Default:500 Max:1500 |
- If startTime and endTime are not sent, the most recent klines are returned.
#
Option Mark PriceResponse:
GET /eapi/v1/mark
Option mark price and greek info.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Option trading pair, e.g BTC-200730-9000-C |
#
24hr Ticker Price Change StatisticsResponse:
GET /eapi/v1/ticker
24 hour rolling window price change statistics.
Weight:
5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Option trading pair, e.g BTC-200730-9000-C |
#
Symbol Price TickerResponse:
GET /eapi/v1/index
Get spot index price for option underlying.
Weight:
1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | YES | Spot pair(Option contract underlying asset, e.g BTCUSDT) |
#
Historical Exercise RecordsResponse:
GET /eapi/v1/exerciseHistory
REALISTIC_VALUE_STRICKEN -> Exercised
EXTRINSIC_VALUE_EXPIRED -> Expired OTM
Get historical exercise records.
Weight:
3
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | NO | Underlying index like BTCUSDT |
startTime | LONG | NO | Start Time |
endTime | LONG | NO | End Time |
limit | INT | NO | Number of records Default:100 Max:100 |
#
Open interestResponse:
GET /eapi/v1/openInterest
Get open interest for specific underlying asset on specific expiration date.
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlyingAsset | STRING | YES | underlying asset, e.g ETH/BTC |
expiration | STRING | YES | expiration date, e.g 221225 |
Account/Trades Endpoints
#
Option Account Information (TRADE)Response:
GET /eapi/v1/account (HMAC SHA256)
Get current account information.
Weight: 3
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Funds Transfer (TRADE)Please find details from here.
#
New Order (TRADE)Response ACK:
Response RESULT:
POST /eapi/v1/order (HMAC SHA256)
Send a new order.
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
side | ENUM | YES | Buy/sell direction: SELL, BUY |
type | ENUM | YES | Order Type: LIMIT(only support limit) |
quantity | DECIMAL | YES | Order Quantity |
price | DECIMAL | NO | Order Price |
timeInForce | ENUM | NO | Time in force method(Default GTC) |
reduceOnly | BOOLEAN | NO | Reduce Only(Default false) |
postOnly | BOOLEAN | NO | Post Only(Default false) |
newOrderRespType | ENUM | NO | "ACK", "RESULT", Default "ACK" |
clientOrderId | STRING | NO | User-defined order ID cannot be repeated in pending orders |
isMmp | BOOLEAN | NO | is market maker protection order, true/false |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Some parameters are mandatory depending on the order type as follows:
Type | Mandatory parameters |
---|---|
LIMIT | timeInForce, quantity, price |
#
Place Multiple Orders (TRADE)Response:
POST /eapi/v1/batchOrders (HMAC SHA256)
Send multiple option orders.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
orders | LIST | YES | order list. Max 5 orders |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Where batchOrders is the list of order parameters in JSON:
- example: /eapi/v1/batchOrders?orders=[{"symbol":"BTC-210115-35000-C", "price":"100","quantity":"0.0002","side":"BUY","type":"LIMIT"}]
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
side | ENUM | YES | Buy/sell direction: SELL, BUY |
type | ENUM | YES | Order Type: LIMIT (Only support LIMIT) |
quantity | DECIMAL | YES | Order Quantity |
price | DECIMAL | NO | Order Price |
timeInForce | ENUM | NO | Time in force method(Default GTC) |
reduceOnly | BOOLEAN | NO | Reduce Only(Default false) |
postOnly | BOOLEAN | NO | Post Only(Default false) |
newOrderRespType | ENUM | NO | "ACK", "RESULT", Default "ACK" |
clientOrderId | STRING | NO | User-defined order ID cannot be repeated in pending orders |
isMmp | BOOLEAN | NO | is market maker protection order, true/false |
Some parameters are mandatory depending on the order type as follows:
Type | Mandatory parameters |
---|---|
LIMIT | timeInForce, quantity, price |
- Parameter 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.
#
Query Single Order (TRADE)Response:
No Order Response:
GET /eapi/v1/order (HMAC SHA256)
Check an order status.
Weight: 1
- These orders will not be found:
- order status is
CANCELED
orREJECTED
, AND - order has NO filled trade, AND
- created time + 3 days < current time
- order status is
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
orderId | LONG | NO | Order id |
clientOrderId | STRING | NO | User-defined order ID cannot be repeated in pending orders |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- Either
orderId
orclientOrderId
must be sent.
#
Cancel Option Order (TRADE)Response:
DELETE /eapi/v1/order (HMAC SHA256)
Cancel an active order.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
orderId | LONG | NO | Order ID, e.g 4611875134427365377 |
clientOrderId | STRING | NO | User-defined order ID, e.g 10000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
At least one instance of orderId
and clientOrderId
must be sent.
#
Cancel Multiple Option Orders (TRADE)Response:
DELETE /eapi/v1/batchOrders (HMAC SHA256)
Cancel an active order.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
orderIds | LIST\<LONG> | NO | Order ID, e.g [4611875134427365377,4611875134427365378] |
clientOrderIds | LIST\<STRING> | NO | User-defined order ID, e.g ["my_id_1","my_id_2"] |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
At least one instance of orderId
and clientOrderId
must be sent.
#
Cancel all Option orders on specific symbol (TRADE)Response:
DELETE /eapi/v1/allOpenOrders (HMAC SHA256)
Cancel all active order on a symbol.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair, e.g BTC-200730-9000-C |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Cancel All Option Orders By Underlying (TRADE)Response:
DELETE /eapi/v1/allOpenOrdersByUnderlying (HMAC SHA256)
Cancel all active orders on specified underlying.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | YES | Option underlying, e.g BTCUSDT |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Query Current Open Option Orders (USER_DATA)Response:
GET /eapi/v1/openOrders (HMAC SHA256)
Query current all open orders, status: ACCEPTED PARTIALLY_FILLED
Weight: 1 for a single symbol; 40 when the symbol parameter is omitted
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | return all orders if don't pass, Option trading pair, e.g BTC-200730-9000-C, |
orderId | LONG | NO | Returns the orderId and subsequent orders, the most recent order is returned by default |
startTime | LONG | NO | Start Time |
endTime | LONG | NO | End Time |
limit | INT | NO | Number of result sets returned Default:100 Max:1000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Query Option Order History (TRADE)Response:
GET /eapi/v1/historyOrders (HMAC SHA256)
Query all finished orders within 5 days, finished status: CANCELLED FILLED REJECTED.
Weight: 3
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | Option trading pair |
orderId | LONG | NO | Returns the orderId and subsequent orders, the most recent order is returned by default |
startTime | LONG | NO | Start Time, e.g 1593511200000 |
endTime | LONG | NO | End Time, e.g 1593512200000 |
limit | INT | NO | Number of result sets returned Default:100 Max:1000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Option Position Information (USER_DATA)Response:
GET /eapi/v1/position (HMAC SHA256)
Get current position information.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Option trading pair, e.g BTC-200730-9000-C |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Account Trade List (USER_DATA)Response:
GET /eapi/v1/userTrades (HMAC SHA256)
Get trades for a specific account and symbol.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Option symbol, e.g BTC-200730-9000-C |
fromId | LONG | NO | Trade id to fetch from. Default gets most recent trades, e.g 4611875134427365376 |
startTime | LONG | NO | Start time, e.g 1593511200000 |
endTime | LONG | NO | End time, e.g 1593512200000 |
limit | INT | NO | Default 100; max 1000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
User Exercise Record (USER_DATA)Response:
GET /eapi/v1/exerciseRecord (HMAC SHA256)
Get account exercise records.
Weight: 5
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | NO | Option trading pair, e.g BTC-200730-9000-C |
startTime | LONG | NO | startTime |
endTime | LONG | NO | endTime |
limit | INT | NO | default 1000, max 1000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Account Funding Flow (USER_DATA)Response:
GET /eapi/v1/bill (HMAC SHA256)
Query account funding flows.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
currency | STRING | YES | Asset type, e.g USDT |
recordId | LONG | NO | Return the recordId and subsequent data, the latest data is returned by default, e.g 100000 |
startTime | LONG | NO | Start Time, e.g 1593511200000 |
endTime | LONG | NO | End Time, e.g 1593512200000 |
limit | INT | NO | Number of result sets returned Default:100 Max:1000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
Websocket Market Streams
The baseurl of the websocket interface is: **wss://nbstream.binance.com/eoptions/**
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://nbstream.binance.com/eoptions/ws/BTC-210630-9000-P@ticker
wss://nbstream.binance.com/eoptions/stream?streams=BTC-210630-9000-P@trade/BTC-210630-9000-P@ticker
A single connection is only valid for 24 hours; expect to be disconnected at the 24 hour mark
The websocket server will send a
ping frame
every 5 minutes. If the websocket server does not receive apong frame
back from the connection within a 15 minute period, the connection will be disconnected. Unsolicitedpong frames
are allowed.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 can listen to a maximum of 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.
- Combined stream events are wrapped as follows: {"stream":"\<streamName>","data":\<rawPayload>}
- All symbols for streams are uppercase
- A single connection is only valid for 24 hours; expect to be disconnected at the 24 hour mark
- The websocket server will send a
ping frame
every 5 minutes. If the websocket server does not receive apong frame
back from the connection within a 15 minute period, the connection will be disconnected. Unsolicitedpong frames
are allowed. - 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 can listen to a maximum of 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 streamResponse
- Request
{
"method": "SUBSCRIBE",
"params":
[
"BTC-210630-9000-P@ticker",
"BTC-210630-9000-P@depth"
],
"id": 1
}
#
Unsubscribe to a streamResponse
Request
{
"method": "UNSUBSCRIBE",
"params":
[
"BTC-210630-9000-P@ticker"
],
"id": 312
}
#
Listing SubscriptionsResponse
Request
{
"method": "LIST_SUBSCRIPTIONS",
"id": 3
}
#
Setting PropertiesCurrently, 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
Request
{
"method": "SET_PROPERTY",
"params":
[
"combined",
true
],
"id": 5
}
#
Retrieving PropertiesResponse
Request
{
"method": "GET_PROPERTY",
"params":
[
"combined"
],
"id": 2
}
#
Error MessagesError 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. ## Trade Streams |
#
Trade StreamsPayload:
The Trade Streams push raw trade information for specific symbol or underlying asset. E.g.ETH@trade
Stream Name:
<symbol>@trade
or <underlyingAsset>@trade
Update Speed: 50ms
#
Index Price StreamsPayload:
Underlying(e.g ETHUSDT) index stream.
Stream Name:
<symbol>@index
Update Speed: 1000ms
#
Mark PricePayload:
The mark price for all option symbols on specific underlying asset. E.g.ETH@markPrice
Stream Name:
<underlyingAsset>@markPrice
Update Speed: 1000ms
#
Kline/Candlestick StreamsPayload:
The Kline/Candlestick Stream push updates to the current klines/candlestick every 1000 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", "12h", "1d", "3d", "1w",
Stream Name:
<symbol>@kline_<interval>
Update Speed: 1000ms
#
24-hour TICKERPayload:
24hr ticker info for all symbols. Only symbols whose ticker info changed will be sent.
Stream Name:
<symbol>@ticker
Update Speed: 1000ms
#
24-hour TICKER by underlying asset and expiration dataPayload:
24hr ticker info by underlying asset and expiration date. E.g.ETH@ticker@220930
Stream Name:
<underlyingAsset>@ticker@<expirationDate>
Update Speed: 1000ms
#
Open InterestOption open interest for specific underlying asset on specific expiration date. E.g.ETH@openInterest@221125
Stream Name:
<underlyingAsset>@openInterest@<expirationDate>
Update Speed: 60s
#
New Symbol InfoNew symbol listing stream.
Stream Name:
option_pair
Update Speed: 50ms
#
Partial Book Depth StreamsPayload:
Top <levels> bids and asks, Valid levels are <levels> are 10, 20, 50, 100.
Stream Names: <symbol>@depth<levels>
OR <symbol>@depth<levels>@100ms
OR <symbol>@depth<levels>@1000ms
.
Update Speed: 100ms or 1000ms, 500ms(default when update speed isn't used)
#
Diff. Book Depth StreamsPayload:
When depth level is set to 1000, stream returns diff book depth pushed every 50ms. Please follow the subsequent instructions on how to manage a local order book correctly.
Stream Names: <symbol>@depth1000
Update Speed: 50ms
#
How to manage a local order book correctly- Open a diff. Book depth stream to wss://nbstream.binance.com/eoptions/stream?streams=ETH-221230-1200-P@depth1000.
- Buffer the events you receive from the stream. For same price, latest received update covers the previous one.
- Get a depth snapshot from https://eapi.binance.com/eapi/v1/depth?symbol=ETH-221230-1200-P&limit=1000 .
- Drop any event from the websocket stream where
u
is <= theu
from the step 3 - The first processed event should have
u
>u
from step 3 ANDpu
=u
from step 3 - 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.
User Data Streams
- The base API endpoint is: https://eapi.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. - 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. - Connection method for Websocket:
- Base Url: wss://nbstream.binance.com/eoptions/
- User Data Streams are accessed at /ws/\<listenKey>
- Example:
wss://nbstream.binance.com/eoptions/ws/XaEAKTsQSRLZAGH9tuIu37plSRsdjmlAVBoNYPUITlTAko1WI22PgmBMpI1rS8Yh
- 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:
POST /eapi/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.
Weight: 1
Parameters:
None
#
Keepalive User Data Stream (USER_STREAM)Response:
PUT /eapi/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.
Weight: 1
Parameters:
None
#
Close User Data Stream (USER_STREAM)Response:
DELETE /eapi/v1/listenKey
Close out a user data stream.
Weight: 1
Parameters:
None
#
Event: Account dataPayload:
- Update Speed: 50ms
- Update under the following conditions:
- Account deposit or withdrawal
- Position info change. Includes a P attribute if there are changes, otherwise does not include a P attribute.
- Greek update
#
Event: Order updatePayload:
- Update Speed: 50ms
- Update under the following conditions:
- Order fills
- Order placed
- Order cancelled
Market Maker Endpoints
Market maker endpoints only work for option market makers, api users will get error when send requests to these endpoints.
#
Option Margin Account Information (USER_DATA)Response:
GET /eapi/v1/marginAccount (HMAC SHA256)
Get current account information.
Weight: 3
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Set Market Maker Protection Config (TRADE)POST /eapi/v1/mmpSet (HMAC SHA256)
Set config for MMP. Market Maker Protection(MMP) is a set of protection mechanism for option market maker, this mechanism is able to prevent mass trading in short period time. Once market maker's account branches the threshold, the Market Maker Protection will be triggered. When Market Maker Protection triggers, all the current MMP orders will be canceled, new MMP orders will be rejected. Market maker can use this time to reevaluate market and modify order price.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | TRUE | underlying, e.g BTCUSDT |
windowTimeInMilliseconds | LONG | TRUE | MMP Interval in milliseconds; Range (0,5000] |
frozenTimeInMilliseconds | LONG | TRUE | MMP frozen time in milliseconds, if set to 0 manual reset is required |
qtyLimit | DECIMAL | TRUE | quantity limit |
deltaLimit | DECIMAL | TRUE | net delta limit |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Get Market Maker Protection Config (TRADE)Get /eapi/v1/mmp (HMAC SHA256)
Get config for MMP.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | TRUE | underlying, e.g BTCUSDT |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Reset Market Maker Protection Config (TRADE)POST /eapi/v1/mmpReset (HMAC SHA256)
Reset MMP, start MMP order again.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | TRUE | underlying, e.g BTCUSDT |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
#
Set Auto-Cancel All Open Orders (Kill-Switch) Config (TRADE)Response:
POST /eapi/v1/countdownCancelAll (HMAC SHA256)
This endpoint sets the parameters of the auto-cancel feature which cancels all open orders (both market maker protection and non market maker protection order types) of the underlying symbol at the end of the specified countdown time period if no heartbeat message is sent. After the countdown time period, all open orders will be cancelled and new orders will be rejected with error code -2010 until either a heartbeat message is sent or the auto-cancel feature is turned off by setting countdownTime to 0.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | YES | Option underlying, e.g BTCUSDT |
countdownTime | LONG | YES | Countdown time in milliseconds (ex. 1,000 for 1 second). 0 to disable the timer. Negative values (ex. -10000) are not accepted. Minimum acceptable value is 5,000 |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- This rest endpoint sets up the parameters to cancel your open orders in case of an outage or disconnection.
- Example usage: Call this endpoint with a countdownTime value of 10000 (10 seconds) to turn on the auto-cancel feature. If the corresponding countdownCancelAllHeartBeat endpoint is not called within 10 seconds with the specified underlying symbol, all open 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 1000 milliseconds, 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.
#
Get Auto-Cancel All Open Orders (Kill-Switch) Config (TRADE)Response:
GET /eapi/v1/countdownCancelAll (HMAC SHA256)
This endpoint returns the auto-cancel parameters for each underlying symbol. Note only active auto-cancel parameters will be returned, if countdownTime is set to 0 (ie. countdownTime has been turned off), the underlying symbol and corresponding countdownTime parameter will not be returned in the response.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlying | STRING | NO | Option underlying, e.g BTCUSDT |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- countdownTime = 0 means the function is disabled.
#
Auto-Cancel All Open Orders (Kill-Switch) Heartbeat (TRADE)Response:
POST /eapi/v1/countdownCancelAllHeartBeat (HMAC SHA256)
This endpoint resets the time from which the countdown will begin to the time this messaged is received. It should be called repeatedly as heartbeats. Multiple heartbeats can be updated at once by specifying the underlying symbols as a list (ex. BTCUSDT,ETHUSDT) in the underlyings parameter.
Weight: 10
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
underlyings | STRING | YES | Option Underlying Symbols, e.g BTCUSDT,ETHUSDT |
recvWindow | LONG | NO | |
timestamp | LONG | YES |
- The response will only include underlying symbols where the heartbeat has been successfully updated.
Error Codes
Here is the error JSON payload:
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 occurred 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.
#
-1008 TOO_MANY_REQUESTS- Too many requests queued.
- Too much request weight used; please use the websocket for live updates to avoid polling the API.
- Too much request weight used; current limit is %s request weight per %s %s. Please use the websocket for live updates to avoid polling the API.
- Way too much request weight used; IP banned until %s. Please use the websocket for live updates to avoid bans.
#
-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.
#
11xx - 2xxx Request issues#
-1100 ILLEGAL_CHARS- Illegal characters found in a parameter.
- Illegal characters found in a parameter. %s
- 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.
#
-1111 BAD_PRECISION- Precision is over the maximum defined for this asset.
#
-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.
#
-1125 INVALID_LISTEN_KEY- This listenKey does not exist.
#
-1127 MORE_THAN_XX_HOURS- Lookup interval is too big.
- More than %s hours between startTime and endTime.
#
-1128 BAD_CONTRACT- Invalid underlying
#
-1129 BAD_CURRENCY- Invalid asset。
#
-1130 INVALID_PARAMETER- Invalid data sent for a parameter.
- Data sent for paramter
%s
is not valid.
#
-1131 BAD_RECV_WINDOW- recvWindow must be less than 60000
#
-2010 NEW_ORDER_REJECTED- NEW_ORDER_REJECTED
#
-2013 NO_SUCH_ORDER- Order does not exist.
#
-2014 BAD_API_KEY_FMT- API-key format invalid.
#
-2015 INVALID_API_KEY- Invalid API-key, IP, or permissions for action.
#
-2018 BALANCE_NOT_SUFFICIENT- Balance is insufficient.
#
-2027 OPTION_MARGIN_NOT_SUFFICIENT- Option margin is insufficient.
#
3xxx-5xxx Filters and other issues#
-3029 TRANSFER_FAILED- Asset transfer fail.
#
-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.
#
-4013 PRICE_LESS_THAN_MIN_PRICE- Price less than min price.
#
-4029 INVALID_TICK_SIZE_PRECISION- Tick size precision is invalid.
#
-4030 INVALID_QTY_PRECISION- Step size precision is invalid.
#
-4055 AMOUNT_MUST_BE_POSITIVE- Amount must be positive.