Binance Connector JS
    Preparing search index...
    Index

    Constructors

    Methods

    • Cancel an active order.

      Weight(IP): 1

      Security Type: TRADE

      Notes: Data Source:* Matching Engine

      • Either orderId or origClientOrderId must be sent.
      • If both orderId and origClientOrderId are provided, the orderId is searched first, then the origClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected.
      • The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only orderId is sent. Sending origClientOrderId or both orderId + origClientOrderId will be slower.

      Parameters

      Returns Promise<RestApiResponse<DeleteOrderResponse>>

    • Current exchange trading rules and symbol information

      Weight(IP): 20

      Security Type: NONE

      Notes: Data Source:* Memory

      Notes:* If the value provided to symbol or symbols do not exist, the endpoint will throw an error saying the symbol is invalid. All parameters are optional. permissions can support single or multiple values (e.g. SPOT, ["MARGIN","LEVERAGED"]). This cannot be used in combination with symbol or symbols. If permissions parameter not provided, all symbols that have either SPOT, MARGIN, or LEVERAGED permission will be exposed. To display symbols with any permission you need to specify them explicitly in permissions: (e.g. ["SPOT","MARGIN",...].). See Account and Symbol Permissions for the full list.

      Examples of Symbol Permissions Interpretation from the Response:*

      [["A","B"]] means you may place an order if your account has either permission "A" or permission "B". [["A"],["B"]] means you can place an order if your account has permission "A" and permission "B". [["A"],["B","C"]] means you can place an order if your account has permission "A" and permission "B" or permission "C". (Inclusive or is applied here, not exclusive or, so your account may have both permission "B" and permission "C".)

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.ExchangeInfoResponse>>

    • Check an order's status.

      Weight(IP): 4

      Security Type: USER_DATA

      Notes: Data Source:* Memory => Database

      • Either orderId or origClientOrderId must be sent.
      • If both orderId and origClientOrderId are provided, the orderId is searched first, then the origClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected.
      • For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.

      Parameters

      Returns Promise<RestApiResponse<GetOrderResponse>>

    • Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

      Weight(IP): 2

      Security Type: NONE

      Notes: Data Source:* Database

      Supported kline intervals (case-sensitive):

      Interval interval value
      seconds 1s
      minutes 1m, 3m, 5m, 15m, 30m
      hours 1h, 2h, 4h, 6h, 8h, 12h
      days 1d, 3d
      weeks 1w
      months 1M

      Notes:*

      If startTime and endTime are not sent, the most recent klines are returned. Supported values for timeZone: Hours and minutes (e.g. -1:00, 05:45) Only hours (e.g. 0, 8, 4) Accepted range is strictly [-12:00 to +14:00] inclusive If timeZone provided, kline intervals are interpreted in that timezone instead of UTC. Note that startTime and endTime are always interpreted in UTC, regardless of timeZone.

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.KlinesResponse>>

    • Retrieves allocations resulting from SOR order placement.

      Weight(IP): 20

      Security Type: USER_DATA

      Notes: Data Source:* Database"

      Supported parameter combinations:

      Parameters Response
      symbol allocations from oldest to newest
      symbol + startTime oldest allocations since startTime
      symbol + endTime newest allocations until endTime
      symbol + startTime + endTime allocations within the time range
      symbol + fromAllocationId allocations by allocation ID
      symbol + orderId allocations related to an order starting with oldest
      symbol + orderId + fromAllocationId allocations related to an order by allocation ID

      Note:* The time between startTime and endTime can't be longer than 24 hours.

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.MyAllocationsResponse>>

    • Get trades for a specific account and symbol.

      Weight: Condition Weight
      Without orderId 20
      With orderId 5

      Security Type: USER_DATA

      Notes: Data Source:* Memory => Database

      *Notes:**:

      • If fromId is set, it will get trades >= that fromId. Otherwise most recent trades are returned.
      • The time between startTime and endTime can't be longer than 24 hours.
      • These are the supported combinations of all parameters:
      • symbol
      • symbol + orderId
      • symbol + startTime
      • symbol + endTime
      • symbol + fromId
      • symbol + startTime + endTime
      • symbol+ orderId + fromId

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.MyTradesResponse>>

    • Send in a new order.

      This adds 1 order to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.

      Weight(IP): 1

      Unfilled Order Count: 1

      Security Type: TRADE

      Notes: Data Source:* Matching Engine

      Some additional mandatory parameters based on order type:

      Type Additional mandatory parameters Additional Information
      LIMIT timeInForce, quantity, price
      MARKET quantity or quoteOrderQty MARKET orders using the quantity field specifies the amount of the base asset the user wants to buy or sell at the market price.
      E.g. MARKET order on BTCUSDT will specify how much BTC the user is buying or selling.

      MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty.
      E.g. Using the symbol BTCUSDT:
      BUY side, the order will buy as many BTC as quoteOrderQty USDT can.
      SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT.
      STOP_LOSS quantity, stopPrice or trailingDelta This will execute a MARKET order when the conditions are met. (e.g. stopPrice is met or trailingDelta is activated)
      STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice or trailingDelta
      TAKE_PROFIT quantity, stopPrice or trailingDelta This will execute a MARKET order when the conditions are met. (e.g. stopPrice is met or trailingDelta is activated)
      TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice or trailingDelta
      LIMIT_MAKER quantity, price This is a LIMIT order that will be rejected if the order immediately matches and trades as a taker.
      This is also known as a POST-ONLY order.

      Notes on using parameters for Pegged Orders: These parameters are allowed for LIMIT, LIMIT_MAKER, STOP_LOSS_LIMIT, TAKE_PROFIT_LIMIT orders. If pegPriceType is specified, price becomes optional. Otherwise, it is still mandatory. pegPriceType=PRIMARY_PEG means the primary peg, that is the best price on the same side of the order book as your order. pegPriceType=MARKET_PEG means the market peg, that is the best price on the opposite side of the order book from your order. Use pegOffsetType and pegOffsetValue to request a price level other than the best one. These parameters must be specified together.

      Other info: 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. For STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT_LIMIT and TAKE_PROFIT orders, trailingDelta can be combined with stopPrice. MARKET orders using quoteOrderQty will not break LOT_SIZE filter rules; the order will execute a quantity that will have the notional value as close as possible to quoteOrderQty. Trigger order price rules against market price for both MARKET and LIMIT versions: Price above market price: STOP_LOSS BUY, TAKE_PROFIT SELL Price below market price: STOP_LOSS SELL, TAKE_PROFIT BUY

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.NewOrderResponse>>

      • Cancels an existing order and places a new order on the same symbol.
      • Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs.
      • A new order that was not attempted (i.e. when newOrderResult: NOT_ATTEMPTED), will still increase the unfilled order count by 1.
      • You can only cancel an individual order from an orderList using this endpoint, but the result is the same as canceling the entire orderList.

      Weight(IP): 1

      Unfilled Order Count: 1

      Security Type: TRADE

      Notes: Data Source:* Matching Engine

      Similar to POST /api/v3/order, additional mandatory parameters are determined by type. Response format varies depending on whether the processing of the message succeeded, partially succeeded, or failed.

      Request Response
      cancelReplaceMode orderRateLimitExceededMode Unfilled Order Count cancelResult newOrderResult status
      STOP_ON_FAILURE DO_NOTHING Within Limits SUCCESS SUCCESS 200
      FAILURE NOT_ATTEMPTED 400
      SUCCESS FAILURE 409
      Exceeds Limits SUCCESS SUCCESS N/A
      FAILURE NOT_ATTEMPTED N/A
      SUCCESS FAILURE N/A
      CANCEL_ONLY Within Limits SUCCESS SUCCESS 200
      FAILURE NOT_ATTEMPTED 400
      SUCCESS FAILURE 409
      Exceeds Limits FAILURE NOT_ATTEMPTED 429
      SUCCESS FAILURE 429
      ALLOW_FAILURE DO_NOTHING Within Limits SUCCESS SUCCESS 200
      FAILURE FAILURE 400
      FAILURE SUCCESS 409
      SUCCESS FAILURE 409
      Exceeds Limits SUCCESS SUCCESS N/A
      FAILURE FAILURE N/A
      FAILURE SUCCESS N/A
      SUCCESS FAILURE N/A
      CANCEL_ONLY Within Limits SUCCESS SUCCESS 200
      FAILURE FAILURE 400
      FAILURE SUCCESS 409
      SUCCESS FAILURE 409
      Exceeds Limits SUCCESS SUCCESS N/A
      FAILURE FAILURE 400
      FAILURE SUCCESS N/A
      SUCCESS FAILURE 409

      Notes:*

      • The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only orderId is sent. Sending origClientOrderId or both orderId + origClientOrderId will be slower.

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.OrderCancelReplaceResponse>>

    • Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other.

      • An OCO has 2 orders called the above order and below order.
      • One of the orders must be a LIMIT_MAKER/TAKE_PROFIT/TAKE_PROFIT_LIMIT order and the other must be STOP_LOSS or STOP_LOSS_LIMIT order.
      • Price restrictions
      • If the OCO is on the SELL side:
      • LIMIT_MAKER/TAKE_PROFIT_LIMIT price > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice
      • TAKE_PROFIT stopPrice > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice
      • If the OCO is on the BUY side:
      • LIMIT_MAKER/TAKE_PROFIT_LIMIT price < Last Traded Price < stopPrice
      • TAKE_PROFIT stopPrice < Last Traded Price < STOP_LOSS/STOP_LOSS_LIMIT stopPrice * OCOs add 2 orders to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
      • OCOs add 2 orders to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.

      Weight(IP): 1

      Unfilled Order Count: 2

      Security Type: TRADE

      Notes: Data Source:* Matching Engine

      Parameters

      Returns Promise<RestApiResponse<OrderListOcoResponse>>

    • Place an OTO.

      • An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders.
      • The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book.
      • The second order is called the pending order. It can be any order type except for MARKET orders using parameter quoteOrderQty. The pending order is only placed on the order book when the working order gets fully filled.
      • If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired.
      • When the order list is placed, if the working order gets immediately fully filled, the placement response will show the working order as FILLED but the pending order will still appear as PENDING_NEW. You need to query the status of the pending order again to see its updated status.
      • OTOs add 2 orders to the EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter.

      Weight(IP): 1

      Unfilled Order Count: 2

      Security Type: TRADE

      Notes: Data Source:* Matching Engine

      Mandatory parameters based on pendingType or workingType*

      Depending on the pendingType or workingType, some optional parameters will become mandatory.

      Type Additional mandatory parameters Additional information
      workingType = LIMIT workingTimeInForce
      pendingType = LIMIT pendingPrice, pendingTimeInForce
      pendingType = STOP_LOSS or TAKE_PROFIT pendingStopPrice and/or pendingTrailingDelta
      pendingType = STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT pendingPrice, pendingStopPrice and/or pendingTrailingDelta, pendingTimeInForce

      Parameters

      Returns Promise<RestApiResponse<OrderListOtoResponse>>

    • Place an OTOCO.

      • An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders.
      • The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book.
      • The behavior of the working order is the same as the OTO.
      • OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets fully filled.
      • The rules of the pending above and pending below follow the same rules as the Order list OCO.
      • OTOCOs add 3 orders to the EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter.

      Weight(IP): 1

      Unfilled Order Count: 3

      Security Type: TRADE

      Notes: Data Source:* Matching Engine

      Mandatory parameters based on pendingAboveType, pendingBelowType or workingType*

      Depending on the pendingAboveType/pendingBelowType or workingType, some optional parameters will become mandatory.

      Type Additional mandatory parameters Additional information
      workingType = LIMIT workingTimeInForce
      pendingAboveType= LIMIT_MAKER pendingAbovePrice
      pendingAboveType = STOP_LOSS/TAKE_PROFIT pendingAboveStopPrice and/or pendingAboveTrailingDelta
      pendingAboveType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT pendingAbovePrice, pendingAboveStopPrice and/or pendingAboveTrailingDelta, pendingAboveTimeInForce
      pendingBelowType= LIMIT_MAKER pendingBelowPrice
      pendingBelowType= STOP_LOSS/TAKE_PROFIT pendingBelowStopPrice and/or pendingBelowTrailingDelta
      pendingBelowType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT pendingBelowPrice, pendingBelowStopPrice and/or pendingBelowTrailingDelta, pendingBelowTimeInForce

      Parameters

      Returns Promise<RestApiResponse<OrderListOtocoResponse>>

    • Send in a new OCO.

      • Price Restrictions:
      • SELL: Limit Price > Last Price > Stop Price
      • BUY: Limit Price < Last Price < Stop Price
      • Quantity Restrictions:
      • Both legs must have the same quantity.
      • ICEBERG quantities however do not have to be the same
      • OCO adds 2 orders to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.

      Weight(IP): 1

      Unfilled Order Count: 2

      Security Type: TRADE

      Notes: Data Source:* Matching Engine

      Parameters

      Returns Promise<RestApiResponse<OrderOcoResponse>>

    • Generic function to send a request.

      Type Parameters

      • T

      Parameters

      • endpoint: string

        The API endpoint to call.

      • method: "GET" | "POST" | "DELETE" | "PUT" | "PATCH"

        HTTP method to use (GET, POST, DELETE, etc.).

      • queryParams: Record<string, unknown> = {}

        Query parameters for the request.

      • bodyParams: Record<string, unknown> = {}

        Body parameters for the request.

      • timeUnit: TimeUnit = ...

        The time unit for the request.

      Returns Promise<RestApiResponse<T>>

      A promise resolving to the response data object.

    • Generic function to send a signed request.

      Type Parameters

      • T

      Parameters

      • endpoint: string

        The API endpoint to call.

      • method: "GET" | "POST" | "DELETE" | "PUT" | "PATCH"

        HTTP method to use (GET, POST, DELETE, etc.).

      • queryParams: Record<string, unknown> = {}

        Query parameters for the request.

      • bodyParams: Record<string, unknown> = {}

        Body parameters for the request.

      • timeUnit: TimeUnit = ...

        The time unit for the request.

      Returns Promise<RestApiResponse<T>>

      A promise resolving to the response data object.

    • Note: This endpoint differs from GET /api/v3/ticker/24hr.

      The statistical time range of this endpoint can be up to 59999ms longer than the requested windowSize.

      openTime starts at the beginning of a minute, while the end time is the current time. Therefore, the actual interval can be up to 59999ms longer than the requested window.

      For example, if closeTime is 1641287867099 (January 04, 2022 09:17:47:099 UTC) and windowSize is 1d, then openTime is 1641201420000 (January 3, 2022, 09:17:00 UTC).

      Weight: 4 for each requested symbol regardless of windowSize.

      The weight for this request will cap at 200 once the number of symbols in the request is more than 50.

      Security Type: NONE

      Notes: Data Source:* Database

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.TickerResponse>>

    • The request is similar to klines having the same parameters and response.

      uiKlines return modified kline data, optimized for presentation of candlestick charts.

      Weight(IP): 2

      Security Type: NONE

      Notes: Data Source:* Database

      • If startTime and endTime are not sent, the most recent klines are returned.
      • Supported values for timeZone:
      • Hours and minutes (e.g. -1:00, 05:45)
      • Only hours (e.g. 0, 8, 4)
      • Accepted range is strictly [-12:00 to +14:00] inclusive
      • If timeZone provided, kline intervals are interpreted in that timezone instead of UTC.
      • Note that startTime and endTime are always interpreted in UTC, regardless of timeZone.

      Parameters

      Returns Promise<RestApiResponse<SpotRestAPI.UiKlinesResponse>>