|
Binance C++ Connector 2.0.0
Official C++ connectors for the Binance APIs
|
A connection to the Spot WebSocket API, returned connected by WebsocketApi::connect(). More...
#include <websocket_api.hpp>
Public Member Functions | |
| const common::WebsocketApiConfig & | configuration () const noexcept |
| void | disconnect () |
| template<class CompletionToken> | |
| auto | async_disconnect (CompletionToken &&token) |
| bool | is_connected () const |
| void | ping_server () |
| Sends a ping frame on every open connection. | |
| template<class F> | |
| common::Subscription | on_event (F &&callback) |
| Registers a lifecycle callback (common::WebsocketEvent). | |
| template<class T> | |
| common::WebsocketApiResponse< T > | send_message (std::string method, common::Params payload={}) const |
| Calls a method the SDK does not wrap yet. T may be boost::json::value. | |
| template<class T> | |
| common::WebsocketApiResponse< T > | send_signed_message (std::string method, common::Params payload={}) const |
| Like send_message, but signed (adds apiKey, timestamp and signature). | |
| template<class T, class CompletionToken> | |
| auto | async_send_message (std::string method, common::Params payload, CompletionToken &&token) const |
| template<class T, class CompletionToken> | |
| auto | async_send_signed_message (std::string method, common::Params payload, CompletionToken &&token) const |
| common::WebsocketApiResponse< AccountCommissionResponseResult > | account_commission (const AccountCommissionParams ¶ms) const |
| Account Commission Rates (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_account_commission (const AccountCommissionParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< AccountRateLimitsOrdersResponseResultInner > > | account_rate_limits_orders (const AccountRateLimitsOrdersParams ¶ms={}) const |
| Unfilled Order Count (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_account_rate_limits_orders (const AccountRateLimitsOrdersParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< AccountStatusResponseResult > | account_status (const AccountStatusParams ¶ms={}) const |
| Account information (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_account_status (const AccountStatusParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< AllOrderListsResponseResultInner > > | all_order_lists (const AllOrderListsParams ¶ms={}) const |
| Account order list history (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_all_order_lists (const AllOrderListsParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< AllOrdersResponseResultInner > > | all_orders (const AllOrdersParams ¶ms) const |
| Account order history (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_all_orders (const AllOrdersParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< MyAllocationsResponseResultInner > > | my_allocations (const MyAllocationsParams ¶ms) const |
| Account allocations (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_my_allocations (const MyAllocationsParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< MyFiltersResponse > | my_filters (const MyFiltersParams ¶ms) const |
| Query Relevant Filters (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_my_filters (const MyFiltersParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< MyPreventedMatchesResponseResultInner > > | my_prevented_matches (const MyPreventedMatchesParams ¶ms) const |
| Account prevented matches (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_my_prevented_matches (const MyPreventedMatchesParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< MyTradesResponseResultInner > > | my_trades (const MyTradesParams ¶ms) const |
| Account trade history (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_my_trades (const MyTradesParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< OpenOrderListsStatusResponseResultInner > > | open_order_lists_status (const OpenOrderListsStatusParams ¶ms={}) const |
| Current open Order lists (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_open_order_lists_status (const OpenOrderListsStatusParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< OpenOrdersStatusResponseResultInner > > | open_orders_status (const OpenOrdersStatusParams ¶ms={}) const |
| Current open orders (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_open_orders_status (const OpenOrdersStatusParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< OrderAmendmentsResponseResultInner > > | order_amendments (const OrderAmendmentsParams ¶ms) const |
| Query Order Amendments (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_order_amendments (const OrderAmendmentsParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListStatusResponseResult > | order_list_status (const OrderListStatusParams ¶ms={}) const |
| Query Order list (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_order_list_status (const OrderListStatusParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderStatusResponseResult > | order_status (const OrderStatusParams ¶ms) const |
| Query order (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_order_status (const OrderStatusParams ¶ms, CompletionToken &&token) const |
| std::vector< common::WebsocketApiResponse< SessionLogonResponseResult > > | session_logon (const SessionLogonParams ¶ms={}) const |
| Log in with API key (USER_DATA). | |
| template<class CompletionToken> | |
| auto | async_session_logon (const SessionLogonParams ¶ms, CompletionToken &&token) const |
| std::vector< common::WebsocketApiResponse< SessionLogoutResponseResult > > | session_logout (const SessionLogoutParams ¶ms={}) const |
| Log out of the session. | |
| template<class CompletionToken> | |
| auto | async_session_logout (const SessionLogoutParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< SessionStatusResponseResult > | session_status (const SessionStatusParams ¶ms={}) const |
| Query session status. | |
| template<class CompletionToken> | |
| auto | async_session_status (const SessionStatusParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< ExchangeInfoResponse > | exchange_info (const ExchangeInfoParams ¶ms={}) const |
| Exchange information. | |
| template<class CompletionToken> | |
| auto | async_exchange_info (const ExchangeInfoParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< ExecutionRulesResponseResult > | execution_rules (const ExecutionRulesParams ¶ms={}) const |
| Query Execution Rules. | |
| template<class CompletionToken> | |
| auto | async_execution_rules (const ExecutionRulesParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< boost::json::value > | ping (const PingParams ¶ms={}) const |
| Test connectivity. | |
| template<class CompletionToken> | |
| auto | async_ping (const PingParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< TimeResponseResult > | time (const TimeParams ¶ms={}) const |
| Check server time. | |
| template<class CompletionToken> | |
| auto | async_time (const TimeParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< AvgPriceResponseResult > | avg_price (const AvgPriceParams ¶ms) const |
| Current average price. | |
| template<class CompletionToken> | |
| auto | async_avg_price (const AvgPriceParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< BlockTradesHistoricalResponseResultInner > > | block_trades_historical (const BlockTradesHistoricalParams ¶ms) const |
| Historical Block Trades. | |
| template<class CompletionToken> | |
| auto | async_block_trades_historical (const BlockTradesHistoricalParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< DepthResponseResult > | depth (const DepthParams ¶ms) const |
| Order book. | |
| template<class CompletionToken> | |
| auto | async_depth (const DepthParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > | klines (const KlinesParams ¶ms) const |
| Klines. | |
| template<class CompletionToken> | |
| auto | async_klines (const KlinesParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< ReferencePriceResponseResult > | reference_price (const ReferencePriceParams ¶ms) const |
| Query Reference Price. | |
| template<class CompletionToken> | |
| auto | async_reference_price (const ReferencePriceParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< ReferencePriceCalculationResponseResult > | reference_price_calculation (const ReferencePriceCalculationParams ¶ms) const |
| Query Reference Price Calculation. | |
| template<class CompletionToken> | |
| auto | async_reference_price_calculation (const ReferencePriceCalculationParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::variant< TickerResponse1Result, std::vector< TickerResponse2ResultInner >, boost::json::value > > | ticker (const TickerParams ¶ms={}) const |
| Rolling window price change statistics. | |
| template<class CompletionToken> | |
| auto | async_ticker (const TickerParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::variant< Ticker24hrResponse1Result, std::vector< Ticker24hrResponse2ResultInner >, boost::json::value > > | ticker24hr (const Ticker24hrParams ¶ms={}) const |
| 24hr ticker price change statistics | |
| template<class CompletionToken> | |
| auto | async_ticker24hr (const Ticker24hrParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::variant< TickerBookResponse1Result, std::vector< TickerBookResponse2ResultInner >, boost::json::value > > | ticker_book (const TickerBookParams ¶ms={}) const |
| Symbol order book ticker. | |
| template<class CompletionToken> | |
| auto | async_ticker_book (const TickerBookParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::variant< TickerPriceResponse1Result, std::vector< TickerPriceResponse2ResultInner >, boost::json::value > > | ticker_price (const TickerPriceParams ¶ms={}) const |
| Symbol price ticker. | |
| template<class CompletionToken> | |
| auto | async_ticker_price (const TickerPriceParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::variant< TickerTradingDayResponse1Result, std::vector< TickerTradingDayResponse2ResultInner >, boost::json::value > > | ticker_trading_day (const TickerTradingDayParams ¶ms={}) const |
| Trading Day Ticker. | |
| template<class CompletionToken> | |
| auto | async_ticker_trading_day (const TickerTradingDayParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< TradesAggregateResponseResultInner > > | trades_aggregate (const TradesAggregateParams ¶ms) const |
| Aggregate trades. | |
| template<class CompletionToken> | |
| auto | async_trades_aggregate (const TradesAggregateParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< TradesHistoricalResponseResultInner > > | trades_historical (const TradesHistoricalParams ¶ms) const |
| Historical trades. | |
| template<class CompletionToken> | |
| auto | async_trades_historical (const TradesHistoricalParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< TradesRecentResponseResultInner > > | trades_recent (const TradesRecentParams ¶ms) const |
| Recent trades. | |
| template<class CompletionToken> | |
| auto | async_trades_recent (const TradesRecentParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< std::vector< KlinesResponseResultInnerInner > > > | ui_klines (const UiKlinesParams ¶ms) const |
| UI Klines. | |
| template<class CompletionToken> | |
| auto | async_ui_klines (const UiKlinesParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< OpenOrdersCancelAllResponseResultInner > > | open_orders_cancel_all (const OpenOrdersCancelAllParams ¶ms) const |
| Cancel open orders (TRADE). | |
| template<class CompletionToken> | |
| auto | async_open_orders_cancel_all (const OpenOrdersCancelAllParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderAmendKeepPriorityResponseResult > | order_amend_keep_priority (const OrderAmendKeepPriorityParams ¶ms) const |
| Order Amend Keep Priority (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_amend_keep_priority (const OrderAmendKeepPriorityParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderCancelResponseResult > | order_cancel (const OrderCancelParams ¶ms) const |
| Cancel order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_cancel (const OrderCancelParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderCancelReplaceResponseResult > | order_cancel_replace (const OrderCancelReplaceParams ¶ms) const |
| Cancel and replace order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_cancel_replace (const OrderCancelReplaceParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListCancelResponseResult > | order_list_cancel (const OrderListCancelParams ¶ms) const |
| Cancel Order list (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_cancel (const OrderListCancelParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListPlaceResponseResult > | order_list_place (const OrderListPlaceParams ¶ms) const |
| Place new OCO - Deprecated (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place (const OrderListPlaceParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListPlaceOcoResponseResult > | order_list_place_oco (const OrderListPlaceOcoParams ¶ms) const |
| Place new Order list - OCO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_oco (const OrderListPlaceOcoParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListPlaceOpoResponseResult > | order_list_place_opo (const OrderListPlaceOpoParams ¶ms) const |
| OPO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_opo (const OrderListPlaceOpoParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListPlaceOpocoResponseResult > | order_list_place_opoco (const OrderListPlaceOpocoParams ¶ms) const |
| OPOCO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_opoco (const OrderListPlaceOpocoParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListPlaceOtoResponseResult > | order_list_place_oto (const OrderListPlaceOtoParams ¶ms) const |
| Place new Order list - OTO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_oto (const OrderListPlaceOtoParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderListPlaceOtocoResponseResult > | order_list_place_otoco (const OrderListPlaceOtocoParams ¶ms) const |
| Place new Order list - OTOCO (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_list_place_otoco (const OrderListPlaceOtocoParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderPlaceResponseResult > | order_place (const OrderPlaceParams ¶ms) const |
| Place new order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_place (const OrderPlaceParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< OrderTestResponseResult > | order_test (const OrderTestParams ¶ms) const |
| Test new order (TRADE). | |
| template<class CompletionToken> | |
| auto | async_order_test (const OrderTestParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< SorOrderPlaceResponseResultInner > > | sor_order_place (const SorOrderPlaceParams ¶ms) const |
| Place new order using SOR (TRADE). | |
| template<class CompletionToken> | |
| auto | async_sor_order_place (const SorOrderPlaceParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< SorOrderTestResponseResult > | sor_order_test (const SorOrderTestParams ¶ms) const |
| Test new order using SOR (TRADE). | |
| template<class CompletionToken> | |
| auto | async_sor_order_test (const SorOrderTestParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< std::vector< SessionSubscriptionsResponseResultInner > > | session_subscriptions (const SessionSubscriptionsParams ¶ms={}) const |
| Listing all subscriptions. | |
| template<class CompletionToken> | |
| auto | async_session_subscriptions (const SessionSubscriptionsParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiSubscription< UserDataStreamSubscribeResponseResult, UserDataStreamEventsResponse > | user_data_stream_subscribe (const UserDataStreamSubscribeParams ¶ms={}) const |
| Subscribe to User Data Stream (USER_STREAM). | |
| template<class CompletionToken> | |
| auto | async_user_data_stream_subscribe (const UserDataStreamSubscribeParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiSubscription< UserDataStreamSubscribeResponseResult, UserDataStreamEventsResponse > | user_data_stream_subscribe_signature (const UserDataStreamSubscribeSignatureParams ¶ms={}) const |
| Subscribe to User Data Stream through signature subscription (USER_STREAM). | |
| template<class CompletionToken> | |
| auto | async_user_data_stream_subscribe_signature (const UserDataStreamSubscribeSignatureParams ¶ms, CompletionToken &&token) const |
| common::WebsocketApiResponse< boost::json::value > | user_data_stream_unsubscribe (const UserDataStreamUnsubscribeParams ¶ms={}) const |
| Unsubscribe from User Data Stream. | |
| template<class CompletionToken> | |
| auto | async_user_data_stream_unsubscribe (const UserDataStreamUnsubscribeParams ¶ms, CompletionToken &&token) const |
Friends | |
| class | WebsocketApi |
A connection to the Spot WebSocket API, returned connected by WebsocketApi::connect().
Cheap to copy: copies share one common::WebsocketApi (connection pool and executor), which reconnects and renews its connections until disconnect().
Every method has a blocking form (name(params)) and an asynchronous form (async_name(params, token)) that accepts any Asio completion token.
|
inlinenodiscardnoexcept |
|
inline |
|
inline |
|
inlinenodiscard |
|
inline |
Sends a ping frame on every open connection.
|
inline |
Registers a lifecycle callback (common::WebsocketEvent).
Destroying the returned subscription removes it.
|
inlinenodiscard |
Calls a method the SDK does not wrap yet. T may be boost::json::value.
|
inlinenodiscard |
Like send_message, but signed (adds apiKey, timestamp and signature).
|
inline |
|
inline |
|
inlinenodiscard |
Account Commission Rates (USER_DATA).
account.commission.
Get current account commission rates.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Database
|
inline |
|
inlinenodiscard |
Unfilled Order Count (USER_DATA).
account.rateLimits.orders.
Query your current unfilled order count for all intervals.
Weight(IP): 40
Security Type: USER_DATA
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Account information (USER_DATA).
account.status.
Query information about your account.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Memory => Database
|
inline |
|
inlinenodiscard |
Account order list history (USER_DATA).
allOrderLists.
Query information about all your order lists, filtered by time range.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Database
Notes:
|
inline |
|
inlinenodiscard |
Account order history (USER_DATA).
allOrders.
Query information about all your orders – active, canceled, filled – filtered by time range.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Database
Notes:
If startTime and/or endTime are specified, orderId is ignored.
Orders are filtered by time of the last execution status update.
|
inline |
|
inlinenodiscard |
Account allocations (USER_DATA).
myAllocations.
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.
|
inline |
|
inlinenodiscard |
Query Relevant Filters (USER_DATA).
myFilters.
Retrieves the list of filters relevant to an account on a given symbol. This is the only method that shows if an account has MAX_ASSET filters applied to it.
Weight(IP): 40
Security Type: USER_DATA
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Account prevented matches (USER_DATA).
myPreventedMatches.
Displays the list of orders that were expired due to STP.
These are the combinations supported:
| Weight: Case | Weight |
|---|---|
| If symbol is invalid | 2 |
| Querying by preventedMatchId | 2 |
| Querying by orderId | 20 |
Security Type: USER_DATA
Notes: Data Source: Database
|
inline |
|
inlinenodiscard |
Account trade history (USER_DATA).
myTrades.
Query information about all your trades, filtered by time range.
| Weight: Condition | Weight |
|---|---|
| Without orderId | 20 |
| With orderId | 5 |
Security Type: USER_DATA
Notes: Data Source: Memory => Database
Notes:
|
inline |
|
inlinenodiscard |
Current open Order lists (USER_DATA).
openOrderLists.status.
Query execution status of all open order lists.
If you need to continuously monitor order status updates, please consider using WebSocket Streams:
Weight(IP): 6
Security Type: USER_DATA
Notes: Data Source: Memory -> Database
|
inline |
|
inlinenodiscard |
Current open orders (USER_DATA).
openOrders.status.
Query execution status of all open orders.
If you need to continuously monitor order status updates, please consider using WebSocket Streams:
Weight: | Parameter | Weight | | ------— | ---— | | symbol | 6 | | none | 80 |
Security Type: USER_DATA
Notes: Data Source: Memory => Database
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Query Order Amendments (USER_DATA).
order.amendments.
Queries all amendments of a single order.
Weight(IP): 4
Security Type: USER_DATA
Notes: Data Source: Database
|
inline |
|
inlinenodiscard |
Query Order list (USER_DATA).
orderList.status.
Check execution status of an Order list.
For execution status of individual orders, use order.status.
Weight(IP): 4
Security Type: USER_DATA
Notes: Data Source: Database
Notes:
|
inline |
|
inlinenodiscard |
Query order (USER_DATA).
order.status.
Check execution status of an order.
Weight(IP): 4
Security Type: USER_DATA
Notes: Data Source: Memory => Database
Notes:
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Log in with API key (USER_DATA).
session.logon.
Authenticate WebSocket connection using the provided API key.
After calling session.logon, you can omit apiKey and signature parameters for future requests that require them.
Note that only one API key can be authenticated.
Calling session.logon multiple times changes the current authenticated API key.
Note: Only Ed25519 keys are supported for this feature.
Weight(IP): 2
Security Type: USER_DATA
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Log out of the session.
session.logout.
Forget the API key previously authenticated. If the connection is not authenticated, this request does nothing.
Note that the WebSocket connection stays open after session.logout request. You can continue using the connection, but now you will have to explicitly provide the apiKey and signature parameters where needed.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Query session status.
session.status.
Query the status of the WebSocket connection, inspecting which API key (if any) is used to authorize requests.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Exchange information.
exchangeInfo.
Query current exchange trading rules, rate limits, and symbol information.
Weight(IP): 20
Security Type: NONE
Notes: Data Source: Memory
Notes:
Examples of Symbol Permissions Interpretation from the Response:
|
inline |
|
inlinenodiscard |
Query Execution Rules.
executionRules.
Query execution rules for symbols.
| Weight: Parameter | Weight |
|---|---|
| symbol | 2 |
| symbols | 2 for each symbol, capped at a max of 40 |
| symbolStatus | 40 |
| None | 40 |
Security Type: NONE
Notes: Data Source: Memory
Note: No combination of multiple parameters is allowed.
|
inline |
|
inlinenodiscard |
Test connectivity.
ping.
Test connectivity to the WebSocket API.
Note: You can use regular WebSocket ping frames to test connectivity as well, WebSocket API will respond with pong frames as soon as possible. ping request along with time is a safe way to test request-response handling in your application.
Weight(IP): 1
Security Type: NONE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/general#ping
|
inline |
|
inlinenodiscard |
Check server time.
time.
Test connectivity to the WebSocket API and get the current server time.
Weight(IP): 1
Security Type: NONE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/general#time
|
inline |
|
inlinenodiscard |
Current average price.
avgPrice.
Get current average price for a symbol.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#avg-price
|
inline |
|
inlinenodiscard |
Historical Block Trades.
blockTrades.historical.
Get block trades.
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Database
|
inline |
|
inlinenodiscard |
Order book.
Get current order book.
Note that this request returns limited market depth.
If you need to continuously monitor order book updates, please consider using WebSocket Streams:
You can use depth request together with <symbol>@depth streams to maintain a local order book.
Weight: Adjusted based on the limit:
| Limit | Request Weight |
|---|---|
| 1-100 | 5 |
| 101-500 | 25 |
| 501-1000 | 50 |
| 1001-5000 | 250 |
| 5001-7500 | 500 |
Security Type: NONE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#depth
|
inline |
|
inlinenodiscard |
Klines.
Get klines (candlestick bars).
Klines are uniquely identified by their open & close time.
If you need access to real-time kline updates, please consider using WebSocket Streams:
If you need historical kline data, please consider using data.binance.vision.
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:
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#klines
|
inline |
|
inlinenodiscard |
Query Reference Price.
referencePrice.
Query Reference Price
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
If the symbol has never had a reference price set, the request is rejected with:
|
inline |
|
inlinenodiscard |
Query Reference Price Calculation.
referencePrice.calculation.
Query Reference Price Calculation
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Rolling window price change statistics.
Get rolling window price change statistics with a custom window.
This request is similar to ticker.24hr but statistics are computed on demand using the arbitrary window you specify.
Note: Window size precision is limited to 1 minute. While the closeTime is the current time of the request, openTime always start on a minute boundary. As such, the effective window might be up to 59999 ms wider than the requested windowSize.
Window computation example
For example, a request for "windowSize": "7d" might result in the following window:
Time of the request – closeTime – is 1660184865291 (August 11, 2022 02:27:45.291). Requested window size should put the openTime 7 days before that – August 4, 02:27:45.291 – but due to limited precision it ends up a bit earlier: 1659580020000 (August 4, 2022 02:27:00), exactly at the start of a minute.
If you need to continuously monitor trading statistics, please consider using WebSocket Streams:
Weight: Adjusted based on the number of requested symbols:
| Symbols | Weight |
|---|---|
| 1–50 | 4 per symbol |
| 51–100 | 200 |
Security Type: NONE
Notes: Data Source: Database
Supported window sizes:
| Unit | windowSize value |
|---|---|
| minutes | 1m, 2m ... 59m |
| hours | 1h, 2h ... 23h |
| days | 1d, 2d ... 7d |
Notes:
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker
|
inline |
|
inlinenodiscard |
24hr ticker price change statistics
ticker.24hr.
Get 24-hour rolling window price change statistics.
If you need to continuously monitor trading statistics, please consider using WebSocket Streams:
If you need different window sizes,
use the ticker request.
Weight: Adjusted based on the number of requested symbols:
| Parameter | Symbols Provided | Weight |
|---|---|---|
| symbol | 1 | 2 |
| omitted | 80 | |
| symbols | 1-20 | 2 |
| 21-100 | 40 | |
| 101+ | 80 | |
| omitted | 80 |
Security Type: NONE
Notes: Data Source: Memory
Notes:
|
inline |
|
inlinenodiscard |
Symbol order book ticker.
ticker.book.
Get the current best price and quantity on the order book.
If you need access to real-time order book ticker updates, please consider using WebSocket Streams:
Weight: Adjusted based on the number of requested symbols:
| Parameter | Symbols Provided | Weight |
|---|---|---|
| symbol | 1 | 2 |
| omitted | 4 | |
| symbols | Any | 4 |
Security Type: NONE
Notes: Data Source: Memory
Notes:
|
inline |
|
inlinenodiscard |
Symbol price ticker.
ticker.price.
Get the latest market price for a symbol.
If you need access to real-time price updates, please consider using WebSocket Streams:
Weight: Adjusted based on the number of requested symbols:
| Parameter | Symbols Provided | Weight |
|---|---|---|
| symbol | 1 | 2 |
| omitted | 4 | |
| symbols | Any | 4 |
Security Type: NONE
Notes: Data Source: Memory
Notes:
|
inline |
|
inlinenodiscard |
Trading Day Ticker.
ticker.tradingDay.
Price change statistics for a trading day.
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
Notes:
|
inline |
|
inlinenodiscard |
Aggregate trades.
trades.aggregate.
Get aggregate trades.
An aggregate trade (aggtrade) represents one or more individual trades.
Trades that fill at the same time, from the same taker order, with the same price –
those trades are collected into an aggregate trade with total quantity of the individual trades.
If you need access to real-time trading activity, please consider using WebSocket Streams:
If you need historical aggregate trade data, please consider using data.binance.vision.
Weight(IP): 4
Security Type: NONE
Notes: Data Source: Database
|
inline |
|
inlinenodiscard |
Historical trades.
trades.historical.
Get historical trades.
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Database
Notes:
|
inline |
|
inlinenodiscard |
Recent trades.
trades.recent.
Get recent trades.
If you need access to real-time trading activity, please consider using WebSocket Streams:
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
UI Klines.
uiKlines.
Get klines (candlestick bars) optimized for presentation.
This 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
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ui-klines
|
inline |
|
inlinenodiscard |
Cancel open orders (TRADE).
openOrders.cancelAll.
Cancel all open orders on a symbol. This includes orders that are part of an order list.
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Order Amend Keep Priority (TRADE).
order.amend.keepPriority.
Reduce the quantity of an existing open order.
This adds 0 orders to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
Read Order Amend Keep Priority FAQ to learn more.
Weight(IP): 4
Unfilled Order Count: 0
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Cancel order (TRADE).
order.cancel.
Cancel an active order.
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Notes:
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
Regarding cancelRestrictions
|
inline |
|
inlinenodiscard |
Cancel and replace order (TRADE).
order.cancelReplace.
Weight(IP): 1
Unfilled Order Count: 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Similar to the order.place request, additional mandatory parameters (*) are determined by the new order type.
Available cancelReplaceMode options:
Notes:
newClientOrderId specifies clientOrderId value for the placed order.
A new order with the same clientOrderId is accepted only when the previous one is filled or expired.
The new order can reuse old clientOrderId of the canceled order.
This cancel-replace operation is not transactional.
If one operation succeeds but the other one fails, the successful operation is still executed.
For example, in STOP_ON_FAILURE mode, if the new order placement fails, the old order is still canceled.
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Cancel Order list (TRADE).
orderList.cancel.
Cancel an active order list.
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Notes:
|
inline |
|
inlinenodiscard |
Place new OCO - Deprecated (TRADE).
orderList.place.
Send in a new one-cancels-the-other (OCO) pair: LIMIT_MAKER + STOP_LOSS/STOP_LOSS_LIMIT orders (called legs), where activation of one order immediately cancels the other.
This adds 1 order to 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
Notes:
listClientOrderId parameter specifies listClientOrderId for the OCO pair.
A new OCO with the same listClientOrderId is accepted only when the previous one is filled or completely expired.
listClientOrderId is distinct from clientOrderId of individual orders.
limitClientOrderId and stopClientOrderId specify clientOrderId values for both legs of the OCO.
A new order with the same clientOrderId is accepted only when the previous one is filled or expired.
| side | Price relation |
|---|---|
| BUY | price < market price < stopPrice |
| SELL | price > market price > stopPrice |
Both legs have the same quantity.
However, you can set different iceberg quantity for individual legs.
If stopIcebergQty is used, stopLimitTimeInForce must be GTC.
Deprecated: this endpoint may be removed in a future version.
|
inline |
|
inlinenodiscard |
Place new Order list - OCO (TRADE).
orderList.place.oco.
Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
|
inline |
|
inlinenodiscard |
OPO (TRADE).
orderList.place.opo.
Place an OPO.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
OPOCO (TRADE).
orderList.place.opoco.
Place an OPOCO.
Weight(IP): 1
Unfilled Order Count: 3
Security Type: TRADE
Notes: Data Source: Matching Engine
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Place new Order list - OTO (TRADE).
orderList.place.oto.
Places an OTO.
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|
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Place new Order list - OTOCO (TRADE).
orderList.place.otoco.
Place an OTOCO.
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|
Response Notes: Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
|
inline |
|
inlinenodiscard |
Place new order (TRADE).
order.place.
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
Certain parameters (*) become mandatory based on the order type:
Supported order types:
, Buy or sell quantity at the specified price or better.,
, LIMIT order that will be rejected if it immediately matches and trades as a taker.,
,
, This order type is also known as a POST-ONLY order.,
, Buy or sell at the best available market price.,
, ,
, MARKET order with quantity parameter, specifies the amount of the base asset you want to buy or sell., Actually executed quantity of the quote asset will be determined by available market liquidity.,
,
, E.g., a MARKET BUY order on BTCUSDT for "quantity": "0.1000", specifies that you want to buy 0.1 BTC at the best available price., If there is not enough BTC at the best price, keep buying at the next best price,, until either your order is filled, or you run out of USDT, or market runs out of BTC.,
, ,
, MARKET order with quoteOrderQty parameter, specifies the amount of the quote asset you want to spend (when buying) or receive (when selling)., Actually executed quantity of the base asset will be determined by available market liquidity.,
,
, E.g., a MARKET BUY on BTCUSDT for "quoteOrderQty": "100.00", specifies that you want to buy as much BTC as you can for 100 USDT at the best available price., Similarly, a SELL order will sell as much available BTC as needed for you to receive 100 USDT, (before commission).,
, ,
, Execute a MARKET order for given quantity when specified conditions are met.,
,
, I.e., when stopPrice is reached, or when trailingDelta is activated.,
, Place a LIMIT order with given parameters when specified conditions are met.,
, Like STOP_LOSS but activates when market price moves in the favorable direction.,
, Like STOP_LOSS_LIMIT but activates when market price moves in the favorable direction.,
Notes on using parameters for Pegged Orders:
Available timeInForce options, setting how long the order should be active before expiration:
| TIF | Description |
|---|---|
| GTC | Good 'til Canceled – the order will remain on the book until you cancel it, or |
| the order is completely filled. IOC | Immediate or Cancel – the order will be filled |
| for as much as possible, the unfilled quantity immediately expires. FOK | Fill or Kill |
– the order will expire unless it cannot be immediately filled for the entire quantity.
Notes:
newClientOrderId specifies clientOrderId value for the order.
A new order with the same clientOrderId is accepted only when the previous one is filled or expired.
Any LIMIT or LIMIT_MAKER order can be made into an iceberg order by specifying the icebergQty.
An order with an icebergQty must have timeInForce set to GTC.
MARKET orders using quoteOrderQty follow LOT_SIZE filter rules.
The order will execute a quantity that has notional value as close as possible to requested quoteOrderQty.
|
inline |
|
inlinenodiscard |
Test new order (TRADE).
order.test.
Test order placement.
Validates new order parameters and verifies your signature but does not send the order into the matching engine.
Weight: | Condition | Request Weight | | — | — | | Without computeCommissionRates | 1 | | With computeCommissionRates | 20 |
Security Type: TRADE
Notes: Data Source: Memory
See https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-test
|
inline |
|
inlinenodiscard |
Place new order using SOR (TRADE).
sor.order.place.
Places an order using smart order routing (SOR).
This adds 1 order to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
Read SOR FAQ to learn more.
Weight(IP): 1
Unfilled Order Count: 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Note: sor.order.place only supports LIMIT and MARKET orders. quoteOrderQty is not supported.
|
inline |
|
inlinenodiscard |
Test new order using SOR (TRADE).
sor.order.test.
Test new order creation and signature/recvWindow using smart order routing (SOR). Creates and validates a new order but does not send it into the matching engine.
Weight: | Condition | Request Weight | | — | — | | Without computeCommissionRates | 1 | | With computeCommissionRates | 20 |
Security Type: TRADE
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Listing all subscriptions.
session.subscriptions.
Note:
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Subscribe to User Data Stream (USER_STREAM).
userDataStream.subscribe.
Subscribe to the User Data Stream in the current WebSocket connection.
Notes:
Weight(IP): 2
Security Type: USER_STREAM
|
inline |
|
inlinenodiscard |
Subscribe to User Data Stream through signature subscription (USER_STREAM).
userDataStream.subscribe.signature.
Weight(IP): 2
Security Type: USER_STREAM
Notes: Data Source: Memory
|
inline |
|
inlinenodiscard |
Unsubscribe from User Data Stream.
userDataStream.unsubscribe.
Stop listening to the User Data Stream in the current WebSocket connection.
Note that session.logout will only close the subscription created with userDataStream.subscribe but not subscriptions opened with userDataStream.subscribe.signature.
Weight(IP): 2
|
inline |
|
friend |