- Binance
- Usage/Example
- REST APIs
- ping([callback function])
- time([callback function])
- exchangeInfo([callback funcion])
- depth(query object|string, [callback function])
- trades(query object|string, [callback function])
- historicalTrades(query object|string, [callback function])
- aggTrades(query object|string, [callback function])
- klines(query object, [callback function])
- ticker24hr(query object|string, [callback function])
- tickerPrice(query object|string, [callback function])
- bookTicker(query object|string, [callback function])
- newOrder(query object, [callback function])
- testOrder(query object, [callback function])
- queryOrder(query object, [callback function])
- cancelOrder(query object, [callback function])
- openOrders(query object|string, [callback function])
- allOrders(query object|string, [callback function])
- account([callback function])
- myTrades(query object|string, [callback function])
- withdraw(query object|string, [callback function])
- withdrawHistory(query object|string, [callback function])
- depositHistory(query object|string, [callback function])
- depositAddress(query object|string, [callback function])
- accountStatus([callback function])
- startUserDataStream([callback function])
- keepAliveUserDataStream(query object, [callback function])
- closeUserDataStream(query object, [callback function])
- allPrices([callback function])
- allBookTickers([callback function])
- WebSocket APIs
- onDepthUpdate(symbol, eventHandler)
- onDepthLevelUpdate(symbol, eventHandler)
- onKline(symbol, interval, eventHandler)
- onAggTrade(symbol, eventHandler)
- onTrade(symbol, eventHandler)
- onTicker(symbol, eventHandler)
- onAllTickers(eventHandler)
- onCombinedStream(streams, eventHandler)
- onUserData(binanceRest, eventHandler, [interval])
- Processing
- Filters
- Timestamp errors
- binance-api-node
- Installation
- Getting started
- Table of Contents
- Public REST Endpoints
- exchangeInfo
- candles
- aggTrades
- trades
- dailyStats
- avgPrice
- prices
- allBookTickers
- Futures Public REST Endpoints
- futures ping
- futures time
- futures exchangeInfo
- futures book
- futures candles
- futures aggTrades
- futures trades
- futures dailyStats
- futures prices
- futures allBookTickers
- futures markPrice
- futures AllForceOrders
- Authenticated REST Endpoints
- order
- orderTest
- orderOco
- getOrder
- getOrderOco
- cancelOrder
- cancelOrderOco
- cancelOpenOrders
- openOrders
- allOrders
- allOrdersOCO
- accountInfo
- myTrades
- dailyAccountSnapshot
- tradesHistory
- withdrawHistory
- withdraw
- depositAddress
- depositHistory
- tradeFee
- capitalConfigs
- universalTransfer
- universalTransferHistory
- assetDetail
- getBnbBurn
- setBnbBurn
- dustTransfer
- accountCoins
- Margin
- marginLoan
- marginRepay
- marginIsolatedAccount
- marginMaxBorrow
- marginCreateIsolated
- marginIsolatedTransfer
- marginIsolatedTransferHistory
- Futures Authenticated REST endpoints
- futuresGetOrder
- futuresAllOrders
- futuresLeverage
- futuresMarginType
- futuresPositionMargin
- futuresMarginHistory
- futuresIncome
- futuresAccountBalance
- futuresUserTrades
- futuresLeverageBracket
- WebSockets
- depth
- customSubStream
- partialDepth
- ticker
- allTickers
- miniTicker
- allMiniTickers
- candles
- trades
- aggTrades
- Futures WebSockets
- futuresDepth
- futuresPartialDepth
- futuresTicker
- futuresAllTickers
- futuresCandles
- futuresAggTrades
- futuresLiquidations
- futuresAllLiquidations
- futuresCustomSubStream
- futuresUser
- Common
- getInfo
- ErrorCodes
Binance
A wrapper for the Binance REST and WebSocket APIs. Uses promises and beautifies the binance API responses that normally use lots of one letter property names. For more information on the API and parameters for requests visit https://github.com/binance-exchange/binance-official-api-docs
Usage/Example
REST APIs
Example responses are only included for routes where the response is beautified, and therefore different than the official docs. Click on any function call to see the related route information in the official documentation.
ping([callback function])
For testing connectivity.
time([callback function])
Retrieves the current server time.
exchangeInfo([callback funcion])
Retrieves the current exchange trading rules and symbol information. Includes rate limits for request and orders, as well as restrictions placed on various values when ordering.
depth(query object|string, [callback function])
Retrieves the order book for a given symbol.
trades(query object|string, [callback function])
Retrieves the most recent trades for a given symbol(up to 500).
historicalTrades(query object|string, [callback function])
Retrieves historical trades by tradeId. If no tradeId is specified the most recent trades are returned.
aggTrades(query object|string, [callback function])
Get compressed, aggregate trades. Trades that fill at the same time, from the same order, with the same price will have the quantity aggregated.
klines(query object, [callback function])
Retrieve kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
ticker24hr(query object|string, [callback function])
Retrieve 24 hour price change statistics.
tickerPrice(query object|string, [callback function])
Retrieve latest price for a symbol or symbols.
bookTicker(query object|string, [callback function])
Retrieve best price/qty on the order book for a symbol or symbols.
newOrder(query object, [callback function])
Places a new order. Example:
testOrder(query object, [callback function])
Places a test order.
queryOrder(query object, [callback function])
Check an order’s status.
cancelOrder(query object, [callback function])
Cancel an open order.
openOrders(query object|string, [callback function])
Get all open orders for a symbol, or all symbols. Careful when accessing this with no symbol as the number of requests counted against the rate limiter is equal to the number of symbols currently trading on the exchange.
allOrders(query object|string, [callback function])
Retrieve all orders on an account, whether active, cancelled, or filled.
account([callback function])
Retrieve current account information including commision rates, trading permissions, and free/locked balances.
myTrades(query object|string, [callback function])
Retrieve all trades made by an account.
withdraw(query object|string, [callback function])
Make a withdrawal.
withdrawHistory(query object|string, [callback function])
Retrieve withdrawal history for an account for a specific asset, or all assets. Includes status.
depositHistory(query object|string, [callback function])
Retrieve deposit history for an account for a specific asset, or all assets. Includes status.
depositAddress(query object|string, [callback function])
Generate and retrieve a deposit address for a given asset.
accountStatus([callback function])
Retrieve account status.
startUserDataStream([callback function])
For use in conjunction with the user data websocket. Returns a listen key that must be specified. onUserData() will handle this for you when you pass it an instance of BinanceRest .
keepAliveUserDataStream(query object, [callback function])
The keep alive request needed to keep a user data websocket open. Will be automatically sent at a specified interval if using onUserData() .
closeUserDataStream(query object, [callback function])
Closes the user data stream.
allPrices([callback function])
Returns the latest price for all symbols. This route appears on the old API document, but does not appear in the most recent set of docs. You should probably use tickerPrice() instead as it utilizes a route with a newer version.
allBookTickers([callback function])
Returns the best price/qty on the order book for all symbols. This route appears on an old API document, but does not appear in the most recent set of docs. You should probably use bookTicker() instead as it utilizes a route with a newer version.
WebSocket APIs
onDepthUpdate(symbol, eventHandler)
Order book price and quantity depth updates used to locally manage an order book, pushed every second. Function call returns the websocket, an instance of https://www.npmjs.com/package/ws
Stream Name: @depth
onDepthLevelUpdate(symbol, eventHandler)
Top bids and asks, pushed every second. Valid are 5, 10, or 20. Function call returns the websocket, an instance of https://www.npmjs.com/package/ws. See official docs for response.
Stream Name: @depth
onKline(symbol, interval, eventHandler)
Pushes updates to the current klines/candlesticks every second. Valid intervals are described here. Returns the websocket, an instance of https://www.npmjs.com/package/ws
Stream Name: @kline_
onAggTrade(symbol, eventHandler)
Pushes trade information that is aggregated for a single taker order. Returns the websocket, an instance of https://www.npmjs.com/package/ws
Stream Name: @aggTrade
onTrade(symbol, eventHandler)
Pushes raw trade information, with each trade having a unique buyer and seller. Returns the websocket, an instance of https://www.npmjs.com/package/ws
Stream Name: @trade
onTicker(symbol, eventHandler)
24 hour ticker stats for a single symbol pushed every second. Returns the websocket, an instance of https://www.npmjs.com/package/ws
Stream Name: @ticker
onAllTickers(eventHandler)
24hr Ticker statistics for all symbols in an array, pushed every second. Returns the websocket, an instance of https://www.npmjs.com/package/ws
Stream Name: !ticker@arr
onCombinedStream(streams, eventHandler)
streams should be an array of stream names. You may specify these explicitly, or you can use some helper functions to generate them:
onUserData(binanceRest, eventHandler, [interval])
Will return the websocket via promise, interval defaults to 60000(ms), and is the amount of time between calls made to keep the user stream alive. binanceRest should be an instance of BinanceRest that will be used to get the listenKey and keep the stream alive.
Processing
Filters
Quantities and prices used when creating orders must fall within the guidelines provided by the filters in symbolInfo responses. The code below shows how to turn a quantity and price into acceptable values for creating an order. The results vary depending on the symbol used, since different symbols have different filters.
Symbol information can be obtained from exchangeInfo([callback funcion])
Timestamp errors
Most can be resolved by adjusting your recvWindow a bit larger, but if your clock is constantly or intermittently going out of sync with the server, the library is capable of calculating the drift and adjusting the timestamps. You have some options. The first is to add the handleDrift option to the constructor, setting it to true .
In this case, if your clock is ahead of the server’s, or falls behind and is outside the recvWindow , and a request fails, the library will calculate the drift of your clock and reattempt the request. It will also use the drift value to adjust all subsequent calls. This may add more time to the initial requests that fail, and could potentially affect highly time sensitive trades.
The alternative is to use the startTimeSync(interval_in_ms) and endTimeSync functions. The former will begin an interval, and each time it’s called the drift will be calculated and used on all subsequent requests. The default interval is 5 minutes, and it should be specified in milliseconds. The latter will clear the interval. You may also calculate the drift manually by calling calculateDrift() . The resulting value will be stored internally and used on all subsequent calls.
Источник
binance-api-node
A complete API wrapper for the Binance API.
Note: This wrapper uses Promises, if they are not supported in your environment, you might want to add a polyfill for them.
For PRs or issues, head over to the source repository.
Installation
Getting started
Import the module and create a new client. Passing api keys is optional only if you don’t plan on doing authenticated calls. You can create an api key here.
If you do not have an appropriate babel config, you will need to use the basic commonjs requires.
Every REST method returns a Promise, making this library async await ready. Following examples will use the await form, which requires some configuration you will have to lookup.
Table of Contents
Param | Type | Required | Info |
---|---|---|---|
apiKey | String | false | Required when making private calls |
apiSecret | String | false | Required when making private calls |
getTime | Function | false | Time generator, defaults to () => Date.now() |
httpBase | String | false | Changes the default endpoint |
httpFutures | String | false | Changes the default endpoint |
wsBase | String | false | Changes the default endpoint |
wsFutures | String | false | Changes the default endpoint |
Public REST Endpoints
Test connectivity to the API.
Test connectivity to the Rest API and get the current server time.
exchangeInfo
Get the current exchange trading rules and symbol information. You can optionally pass a symbol to only retrieve info of this specific one.
Param | Type | Required | Default |
---|---|---|---|
symbol | String | false |
Output
Get the order book for a symbol.
Param | Type | Required | Default |
---|---|---|---|
symbol | String | true | |
limit | Number | false | 100 |
Output
candles
Retrieves Candlestick for a symbol. Candlesticks are uniquely identified by their open time.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
interval | String | false | 5m | 1m , 3m , 5m , 15m , 30m , 1h , 2h , 4h , 6h , 8h , 12h , 1d , 3d , 1w , 1M |
limit | Number | false | 500 | Max 1000 |
startTime | Number | false | ||
endTime | Number | false |
Output
aggTrades
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
fromId | String | false | ID to get aggregate trades from INCLUSIVE. | |
startTime | Number | false | Timestamp in ms to get aggregate trades from INCLUSIVE. | |
endTime | Number | false | Timestamp in ms to get aggregate trades until INCLUSIVE. | |
limit | Number | false | 500 | Max 500 |
Note: If both startTime and endTime are sent, limit should not be sent AND the distance between startTime and endTime must be less than 24 hours.
Note: If frondId , startTime , and endTime are not sent, the most recent aggregate trades will be returned.
trades
Get recent trades of a symbol.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 500 |
Output
dailyStats
24 hour price change statistics, not providing a symbol will return all tickers and is resource-expensive.
Param | Type | Required |
---|---|---|
symbol | String | false |
Output
avgPrice
Current average price for a symbol.
Param | Type | Required |
---|---|---|
symbol | String | true |
Output
prices
Latest price for a symbol, not providing the symbol will return prices for all symbols.
Param | Type | Required |
---|---|---|
symbol | String | false |
Output
allBookTickers
Best price/qty on the order book for all symbols.
Futures Public REST Endpoints
futures ping
Test connectivity to the API.
futures time
Test connectivity to the Rest API and get the current server time.
futures exchangeInfo
Get the current exchange trading rules and symbol information.
futures book
Get the order book for a symbol.
Param | Type | Required | Default |
---|---|---|---|
symbol | String | true | |
limit | Number | false | 100 |
Output
futures candles
Retrieves Candlestick for a symbol. Candlesticks are uniquely identified by their open time.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
interval | String | false | 5m | 1m , 3m , 5m , 15m , 30m , 1h , 2h , 4h , 6h , 8h , 12h , 1d , 3d , 1w , 1M |
limit | Number | false | 500 | Max 1000 |
startTime | Number | false | ||
endTime | Number | false |
Output
futures aggTrades
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
fromId | String | false | ID to get aggregate trades from INCLUSIVE. | |
startTime | Number | false | Timestamp in ms to get aggregate trades from INCLUSIVE. | |
endTime | Number | false | Timestamp in ms to get aggregate trades until INCLUSIVE. | |
limit | Number | false | 500 | Max 500 |
Note: If both startTime and endTime are sent, limit should not be sent AND the distance between startTime and endTime must be less than 24 hours.
Note: If frondId , startTime , and endTime are not sent, the most recent aggregate trades will be returned.
futures trades
Get recent trades of a symbol.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 500 |
Output
futures dailyStats
24 hour price change statistics, not providing a symbol will return all tickers and is resource-expensive.
Param | Type | Required |
---|---|---|
symbol | String | false |
Output
futures prices
Latest price for all symbols.
futures allBookTickers
Best price/qty on the order book for all symbols.
futures markPrice
Mark Price and Funding Rate.
futures AllForceOrders
Get all Liquidation Orders.
Param | Type | Required |
---|---|---|
symbol | String | false |
startTime | Long | false |
endTime | Long | false |
limit | Long | false |
Output
Authenticated REST Endpoints
Note that for all authenticated endpoints, you can pass an extra parameter useServerTime set to true in order to fetch the server time before making the request.
order
Creates a new order.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
side | String | true | BUY , SELL | |
type | String | false | LIMIT | LIMIT , MARKET |
quantity | String | true | ||
price | String | true | Optional for MARKET orders | |
timeInForce | String | false | GTC | FOK , GTC , IOC |
newClientOrderId | String | false | A unique id for the order. Automatically generated if not sent. | |
stopPrice | Number | false | Used with stop orders | |
activationPrice | Number | false | Used with TRAILING_STOP_MARKET | |
callbackRate | Number | false | Used with TRAILING_STOP_MARKET | |
newOrderRespType | String | false | RESULT | Returns more complete info of the order. ACK , RESULT , or FULL |
icebergQty | Number | false | Used with iceberg orders | |
recvWindow | Number | false |
Additional mandatory parameters based on type :
Type | Additional mandatory parameters |
---|---|
LIMIT | timeInForce , quantity , price |
MARKET | quantity |
STOP | quantity , price , stopPrice |
STOP_LOSS_LIMIT | timeInForce , quantity , price , stopPrice |
STOP_LOSS_MARKET | stopPrice |
TAKE_PROFIT | quantity , price , stopPrice |
TAKE_PROFIT_MARKET | stopPrice |
STOP_PROFIT_LIMIT | timeInForce , quantity , price , stopPrice |
LIMIT_MAKER | quantity , price |
TRAILING_STOP_MARKET | callbackRate , activationPrice |
- LIMIT_MAKER are LIMIT orders that will be rejected if they would immediately match and trade as a taker.
- STOP and TAKE_PROFIT will execute a MARKET order when the stopPrice is reached.
- Any LIMIT or LIMIT_MAKER type order can be made an iceberg order by sending an icebergQty .
- Any order with an icebergQty MUST have timeInForce set to GTC .
Output
orderTest
Test new order creation and signature/recvWindow. Creates and validates a new order but does not send it into the matching engine.
Same API as above, but does not return any output on success.
orderOco
Creates a new OCO order.
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
listClientOrderId | String | false | A unique Id for the entire orderList |
side | String | true | BUY , SELL |
quantity | Number | true | |
limitClientOrderId | String | false | A unique Id for the limit order |
price | Number | true | |
limitIcebergQty | Number | false | Used to make the LIMIT_MAKER leg an iceberg order. |
stopClientOrderId | String | false | A unique Id for the stop loss/stop loss limit leg |
stopPrice | Number | true | |
stopLimitPrice | Number | false | If provided, stopLimitTimeInForce is required. |
stopIcebergQty | Number | false | Used with STOP_LOSS_LIMIT leg to make an iceberg order. |
stopLimitTimeInForce | String | false | FOK , GTC , IOC |
newOrderRespType | String | false | Returns more complete info of the order. ACK , RESULT , or FULL |
recvWindow | Number | false | The value cannot be greater than 60000 |
- Price Restrictions:
- SELL : Limit Price > Last Price > Stop Price
- BUY : Limit Price ICEBERG quantities however do not have to be the same
Output
getOrder
Check an order’s status.
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderId | Number | true | Not required if origClientOrderId is used |
origClientOrderId | String | false | |
recvWindow | Number | false |
Output
getOrderOco
Retrieves a specific OCO based on provided optional parameters
Param | Type | Required | Description |
---|---|---|---|
orderListId | Number | true | Not required if listClientOrderId is used |
listClientOrderId | String | false | |
recvWindow | Number | false |
Output
cancelOrder
Cancels an active order.
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderId | Number | true | Not required if origClientOrderId is used |
origClientOrderId | String | false | |
newClientOrderId | String | false | Used to uniquely identify this cancel. Automatically generated by default. |
recvWindow | Number | false |
Output
cancelOrderOco
Cancel an entire Order List.
Param | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
orderListId | Number | true | Not required if listClientOrderId is used |
listClientOrderId | String | false | |
newClientOrderId | String | false | Used to uniquely identify this cancel. Automatically generated by default. |
recvWindow | Number | false |
Output
cancelOpenOrders
Cancels all active orders on a symbol. This includes OCO orders.
Param | Type | Required |
---|---|---|
symbol | String | true |
Output
openOrders
Get all open orders on a symbol.
Param | Type | Required |
---|---|---|
symbol | String | true |
recvWindow | Number | false |
Output
allOrders
Get all account orders on a symbol; active, canceled, or filled.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
orderId | Number | false | If set, it will get orders >= that orderId. Otherwise most recent orders are returned. | |
limit | Number | false | 500 | Max 500 |
recvWindow | Number | false |
Output
allOrdersOCO
Retrieves all OCO based on provided optional parameters
Param | Type | Required | Default | Description |
---|---|---|---|---|
timestamp | Number | true | ||
startTime | Number | false | ||
endTime | Number | false | ||
limit | Integer | false | 500 | Max 1000 |
recvWindow | Number | false | The value cannot be greater than 60000 | |
formId | Number | false | If supplied, neither startTime or endTime can be provided |
Output
accountInfo
Get current account information.
Param | Type | Required |
---|---|---|
recvWindow | Number | false |
Output
myTrades
Get trades for the current authenticated account and symbol.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 500 |
fromId | Number | false | TradeId to fetch from. Default gets most recent trades. | |
recvWindow | Number | false |
Output
dailyAccountSnapshot
Get asset snapshot for the current authenticated account.
Param | Type | Required | Default | Description |
---|---|---|---|---|
type | String | true | ||
startTime | Number | false | ||
endTime | Number | false | ||
limit | Number | false | 5 | min 5 , max 30 , default 5 |
recvWindow | Number | false |
Output
tradesHistory
Lookup symbol trades history.
Param | Type | Required | Default | Description |
---|---|---|---|---|
symbol | String | true | ||
limit | Number | false | 500 | Max 500 |
fromId | Number | false | null | TradeId to fetch from. Default gets most recent trades. |
Output
withdrawHistory
Get the account withdraw history.
Param | Type | Required | Description |
---|---|---|---|
asset | String | false | |
status | Number | false | 0 (0: Email Sent, 1: Cancelled 2: Awaiting Approval, 3: Rejected, 4: Processing, 5: Failure, 6: Completed) |
offset | Number | false | |
limit | Number | false | |
startTime | Number | false | |
endTime | Number | false | |
recvWindow | Number | false |
Output
withdraw
Triggers the withdraw process (untested for now).
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | |
address | String | true | |
amount | Number | true | |
name | String | false | Description of the address |
recvWindow | Number | false |
Output
depositAddress
Fetch deposit address with network.
Param | Type | Required | Description |
---|---|---|---|
coin | String | true | The coin name |
network | String | false | The network name |
Output
depositHistory
Fetch deposit address with network.
Param | Type | Required | Description |
---|---|---|---|
coin | String | false | The coin name |
status | Number | false | 0 (0:pending, 6: credited but cannot withdraw, 1:success) |
startTime | Number | false | Default: 90 days from current timestamp |
endTime | Number | false | Default: present timestamp |
offset | Number | false | default: 0 |
limit | Number | false | |
recvWindow | Number | false |
Output
tradeFee
Retrieve the account trade Fee per asset.
capitalConfigs
Get information of coins (available for deposit and withdraw) for user.
universalTransfer
You need to enable Permits Universal Transfer option for the api key which requests this endpoint.
Param | Type | Required | Description |
---|---|---|---|
type | String | true | |
asset | String | true | |
amount | String | true | |
recvWindow | Number | false |
Output
universalTransferHistory
Param | Type | Required | Description |
---|---|---|---|
type | String | true | |
startTime | Number | false | |
endTime | Number | false | |
current | Number | false | Default 1 |
size | Number | false | Default 10, Max 100 |
recvWindow | Number | false |
Output
assetDetail
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false |
Output
getBnbBurn
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false | No more than 60000 |
Output
setBnbBurn
Param | Type | Required | Description |
---|---|---|---|
spotBNBBurn | String | false | «true» or «false»; Determines whether to use BNB to pay for trading fees on SPOT |
interestBNBBurn | String | false | «true» or «false»; Determines whether to use BNB to pay for margin loan’s interest |
recvWindow | Number | false | No more than 60000 |
Output
dustTransfer
Param | Type | Required | Description |
---|---|---|---|
asset | [String] | true | |
recvWindow | Number | false |
Output
accountCoins
Retrieve account coins related information. Implemented as getAll in Binance Docs.
Param | Type | Required | Description |
---|---|---|---|
recvWindow | Number | false |
Output
Margin
marginLoan
Create a loan for margin account.
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | The asset name |
amount | Number | true |
Output
marginRepay
Repay loan for margin account.
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | The asset name |
amount | Number | true |
Output
marginIsolatedAccount
Query Isolated Margin Account Info
Param | Type | Required | Description |
---|---|---|---|
symbols | String | false | Max 5 symbols can be sent; separated by «,» |
recvWindow | Number | false | No more than 60000 |
Output
marginMaxBorrow
If isolatedSymbol is not sent, crossed margin data will be sent.
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | |
isolatedSymbol | String | false | |
recvWindow | Number | false | No more than 60000 |
Output
marginCreateIsolated
Param | Type | Required | Description |
---|---|---|---|
base | String | true | Base asset of symbol |
quote | String | true | Quote asset of symbol |
recvWindow | Number | false | No more than 60000 |
Output
marginIsolatedTransfer
Param | Type | Required | Description |
---|---|---|---|
asset | String | true | asset,such as BTC |
symbol | String | true | |
transFrom | String | true | «SPOT», «ISOLATED_MARGIN» |
transTo | String | true | «SPOT», «ISOLATED_MARGIN» |
amount | Number | true | |
recvWindow | Number | false | No more than 60000 |
Output
marginIsolatedTransferHistory
Param | Type | Required | Description |
---|---|---|---|
asset | String | false | asset,such as BTC |
symbol | String | true | |
transFrom | String | false | «SPOT», «ISOLATED_MARGIN» |
transTo | String | false | «SPOT», «ISOLATED_MARGIN» |
startTime | Number | false | |
endTime | Number | false | |
current | Number | false | Current page, default 1 |
size | Number | false | Default 10, max 100 |
recvWindow | Number | false | No more than 60000 |
Output
Futures Authenticated REST endpoints
futuresGetOrder
Check an order’s status.
- These orders will not be found
- order status is CANCELED or EXPIRED, AND
- order has NO filled trade, AND
- created time + 7 days Output
futuresAllOrders
Get all account orders; active, canceled, or filled.
- These orders will not be found
- order status is CANCELED or EXPIRED, AND
- order has NO filled trade, AND
- created time + 7 days = that orderId. Otherwise most recent orders are returned.
futuresLeverage
Change user’s initial leverage of specific symbol market.
Name Type Mandatory Description symbol STRING YES The pair name leverage INT YES target initial leverage: int from 1 to 125 recvWindow LONG NO futuresMarginType
Change margin type.
Name Type Mandatory Description symbol STRING YES The pair name marginType ENUM YES ISOLATED, CROSSED recvWindow LONG NO futuresPositionMargin
Modify isolated position margin.
Name Type Mandatory Description symbol STRING YES The pair name 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 Only for isolated symbol.
futuresMarginHistory
Get position margin change history.
Name Type Mandatory Description symbol STRING YES The pair name type INT NO 1: Add position marginпјЊ2: Reduce position margin startTime LONG NO endTime LONG NO limit INT NO Default 500; recvWindow LONG NO futuresIncome
Get income history.
Name Type Mandatory Description symbol STRING NO The pair name incomeType STRING NO «TRANSFER»пјЊ»WELCOME_BONUS», «REALIZED_PNL»пјЊ
«FUNDING_FEE», «COMMISSION», and «INSURANCE_CLEAR»startTime LONG NO Timestamp in ms to get funding from INCLUSIVE. endTime LONG NO Timestamp in ms to get funding until INCLUSIVE. limit INT NO Default 100; max 1000 recvWindow LONG NO - If incomeType is not sent, all kinds of flow will be returned
- «trandId» is unique in the same incomeType for a user
futuresAccountBalance
Get futures account balance
futuresUserTrades
Get trades for a specific account and symbol.
Param Type Mandatory Description symbol STRING YES startTime LONG NO endTime LONG NO limit INT NO Default 500; max 1000. fromId LONG NO Trade id to fetch from. Default gets most recent trades. recvWindow LONG NO Output
futuresLeverageBracket
Get notional and leverage brackets.
Param Type Mandatory Description symbol STRING NO Use if you are only interested in brackets for one symbol recvWindow LONG NO Output
WebSockets
Every websocket utility returns a function you can call to close the opened connection and avoid memory issues.
depth
Live depth market data feed. The first parameter can either be a single symbol string or an array of symbols. If you wish to specify the update speed (can either be 1000ms or 100ms ) of the stream then append the speed at the end of the symbol string as follows: ETHBTC@100ms
customSubStream
You can add custom sub streams by view docs
partialDepth
Top levels bids and asks, pushed every second. Valid levels are 5, 10, or 20. Accepts an array of objects for multiple depths. If you wish to specify the update speed (can either be 1000ms or 100ms ) of the stream then append the speed at the end of the symbol string as follows: ETHBTC@100ms
ticker
24hr Ticker statistics for a symbol pushed every second. Accepts an array of symbols.
allTickers
Retrieves all the tickers.
miniTicker
24hr Mini Ticker statistics for a symbol pushed every second. Accepts an array of symbols.
allMiniTickers
Retrieves all the mini tickers.
candles
Live candle data feed for a given interval. You can pass either a symbol string or a symbol array.
trades
Live trade data feed. Pass either a single symbol string or an array of symbols. The trade streams push raw trade information; each trade has a unique buyer and seller.
aggTrades
Live trade data feed. Pass either a single symbol string or an array of symbols. The aggregate trade streams push trade information that is aggregated for a single taker order.
Live user messages data feed.
Requires authentication
There is also equivalent function to query the margin wallet:
Note that this method return a promise which will resolve the clean callback.
Futures WebSockets
Every websocket utility returns a function you can call to close the opened connection and avoid memory issues.
Each websocket utility supports the ability to get a clean callback without data transformation, for this, pass the third attribute FALSE.
futuresDepth
Live futuresDepth market data feed. The first parameter can either be a single symbol string or an array of symbols.
futuresPartialDepth
Top levels bids and asks, pushed every second. Valid levels are 5, 10, or 20. Accepts an array of objects for multiple depths.
futuresTicker
24hr Ticker statistics for a symbol pushed every 500ms. Accepts an array of symbols.
futuresAllTickers
Retrieves all the tickers.
futuresCandles
Live candle data feed for a given interval. You can pass either a symbol string or a symbol array.
futuresAggTrades
Live trade data feed. Pass either a single symbol string or an array of symbols. The Aggregate Trade Streams push trade information that is aggregated for a single taker order every 100 milliseconds.
futuresLiquidations
Live liquidation data feed. Pass either a single symbol string or an array of symbols. The Liquidation Order Streams push force liquidation order information for specific symbol(s).
futuresAllLiquidations
Live liquidation data feed. Pass either a single symbol string or an array of symbols. The All Liquidation Order Streams push force liquidation order information for all symbols in the market.
futuresCustomSubStream
You can add custom sub streams by view docs
futuresUser
Live user messages data feed.
Requires authentication
Common
getInfo
To get information about limits from response headers call getInfo()
ErrorCodes
An utility error code map is also being exported by the package in order for you to make readable conditionals upon specific errors that could occur while using the API.
Источник