pub struct RestApi { /* private fields */ }Implementations§
Source§impl RestApi
impl RestApi
pub fn new(configuration: ConfigurationRestApi) -> Self
Sourcepub async fn send_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> Result<RestApiResponse<R>>
pub async fn send_request<R: DeserializeOwned + Send + 'static>( &self, endpoint: &str, method: Method, query_params: BTreeMap<String, Value>, body_params: BTreeMap<String, Value>, ) -> Result<RestApiResponse<R>>
Send an unsigned request to the API
§Arguments
endpoint- The API endpoint to send the request tomethod- The HTTP method to use for the requestquery_params- A map of query parameters to send with the requestbody_params- A map of body parameters to send with the request
§Returns
A RestApiResponse containing the deserialized response data on success, or an error if the request fails
§Errors
Returns an anyhow::Error if the HTTP request fails or if parsing the response fails
Sourcepub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> Result<RestApiResponse<R>>
pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>( &self, endpoint: &str, method: Method, query_params: BTreeMap<String, Value>, body_params: BTreeMap<String, Value>, ) -> Result<RestApiResponse<R>>
Send a signed request to the API
§Arguments
endpoint- The API endpoint to send the request tomethod- The HTTP method to use for the requestquery_params- A map of query parameters to send with the requestbody_params- A map of body parameters to send with the request
§Returns
A RestApiResponse containing the deserialized response data on success, or an error if the request fails
§Errors
Returns an anyhow::Error if the HTTP request fails or if parsing the response fails
Sourcepub async fn account_commission(
&self,
params: AccountCommissionParams,
) -> Result<RestApiResponse<AccountCommissionResponse>>
pub async fn account_commission( &self, params: AccountCommissionParams, ) -> Result<RestApiResponse<AccountCommissionResponse>>
Query Commission Rates (USER_DATA)
Get current account commission rates.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Database
§Arguments
params:AccountCommissionParamsThe parameters for this operation.
§Returns
RestApiResponse<models::AccountCommissionResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn all_order_list(
&self,
params: AllOrderListParams,
) -> Result<RestApiResponse<Vec<AllOrderListResponseInner>>>
pub async fn all_order_list( &self, params: AllOrderListParams, ) -> Result<RestApiResponse<Vec<AllOrderListResponseInner>>>
Query all Order lists (USER_DATA)
Retrieves all order lists based on provided optional parameters.
Note that the time between startTime and endTime can’t be longer
than 24 hours.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Database
§Arguments
params:AllOrderListParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::AllOrderListResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn all_orders(
&self,
params: AllOrdersParams,
) -> Result<RestApiResponse<Vec<AllOrdersResponseInner>>>
pub async fn all_orders( &self, params: AllOrdersParams, ) -> Result<RestApiResponse<Vec<AllOrdersResponseInner>>>
All orders (USER_DATA)
Get all account orders; active, canceled, or filled.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Database
- If
orderIdis set, it will get orders >= thatorderId. Otherwise most recent orders are returned. - For some historical orders
cummulativeQuoteQtywill be < 0, meaning the data is not available at this time. - If
startTimeand/orendTimeprovided,orderIdis not required. - The time between
startTimeandendTimecan’t be longer than 24 hours.
§Arguments
params:AllOrdersParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::AllOrdersResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn get_account(
&self,
params: GetAccountParams,
) -> Result<RestApiResponse<GetAccountResponse>>
pub async fn get_account( &self, params: GetAccountParams, ) -> Result<RestApiResponse<GetAccountResponse>>
Account information (USER_DATA)
Get current account information.
Weight(IP): 20
Security Type: USER_DATA
Notes: Data Source: Memory => Database
§Arguments
params:GetAccountParamsThe parameters for this operation.
§Returns
RestApiResponse<models::GetAccountResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn get_open_orders(
&self,
params: GetOpenOrdersParams,
) -> Result<RestApiResponse<Vec<GetOpenOrdersResponseInner>>>
pub async fn get_open_orders( &self, params: GetOpenOrdersParams, ) -> Result<RestApiResponse<Vec<GetOpenOrdersResponseInner>>>
Current open orders (USER_DATA)
Get all open orders on a symbol. Careful when accessing this with no symbol.
Weight: 6 for a single symbol; 80 when the symbol parameter is omitted
Security Type: USER_DATA
Notes: Data Source: Memory => Database
- If the symbol is not sent, orders for all symbols will be returned in an array.
§Arguments
params:GetOpenOrdersParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::GetOpenOrdersResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn get_order(
&self,
params: GetOrderParams,
) -> Result<RestApiResponse<GetOrderResponse>>
pub async fn get_order( &self, params: GetOrderParams, ) -> Result<RestApiResponse<GetOrderResponse>>
Query order (USER_DATA)
Check an order’s status.
Weight(IP): 4
Security Type: USER_DATA
Notes: Data Source: Memory => Database
- Either
orderIdororigClientOrderIdmust be sent. - If both
orderIdandorigClientOrderIdare provided, theorderIdis searched first, then theorigClientOrderIdfrom that result is checked against that order. If both conditions are not met the request will be rejected. - For some historical orders
cummulativeQuoteQtywill be < 0, meaning the data is not available at this time.
§Arguments
params:GetOrderParamsThe parameters for this operation.
§Returns
RestApiResponse<models::GetOrderResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn get_order_list(
&self,
params: GetOrderListParams,
) -> Result<RestApiResponse<GetOrderListResponse>>
pub async fn get_order_list( &self, params: GetOrderListParams, ) -> Result<RestApiResponse<GetOrderListResponse>>
Query Order list (USER_DATA)
Retrieves a specific order list based on provided optional parameters.
Weight(IP): 4
Security Type: USER_DATA
Notes: Data Source: Database
§Arguments
params:GetOrderListParamsThe parameters for this operation.
§Returns
RestApiResponse<models::GetOrderListResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn my_allocations(
&self,
params: MyAllocationsParams,
) -> Result<RestApiResponse<Vec<MyAllocationsResponseInner>>>
pub async fn my_allocations( &self, params: MyAllocationsParams, ) -> Result<RestApiResponse<Vec<MyAllocationsResponseInner>>>
Query Allocations (USER_DATA)
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.
§Arguments
params:MyAllocationsParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::MyAllocationsResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn my_filters(
&self,
params: MyFiltersParams,
) -> Result<RestApiResponse<MyFiltersResponse>>
pub async fn my_filters( &self, params: MyFiltersParams, ) -> Result<RestApiResponse<MyFiltersResponse>>
Query relevant filters (USER_DATA)
Retrieves the list of filters relevant to an account on a given symbol. This is the only endpoint that shows if an account has MAX_ASSET filters applied to it.
Weight(IP): 40
Security Type: USER_DATA
Notes: Data Source: Memory
§Arguments
params:MyFiltersParamsThe parameters for this operation.
§Returns
RestApiResponse<models::MyFiltersResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn my_prevented_matches(
&self,
params: MyPreventedMatchesParams,
) -> Result<RestApiResponse<Vec<MyPreventedMatchesResponseInner>>>
pub async fn my_prevented_matches( &self, params: MyPreventedMatchesParams, ) -> Result<RestApiResponse<Vec<MyPreventedMatchesResponseInner>>>
Query Prevented Matches (USER_DATA)
Displays the list of orders that were expired due to STP.
These are the combinations supported:
symbol+preventedMatchIdsymbol+orderIdsymbol+orderId+fromPreventedMatchId(limitwill default to 500)symbol+orderId+fromPreventedMatchId+limit
| Weight: Case | Weight |
|---|---|
If symbol is invalid | 2 |
Querying by preventedMatchId | 2 |
Querying by orderId | 20 |
Security Type: USER_DATA
Notes: Data Source: Database
§Arguments
params:MyPreventedMatchesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::MyPreventedMatchesResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn my_trades(
&self,
params: MyTradesParams,
) -> Result<RestApiResponse<Vec<MyTradesResponseInner>>>
pub async fn my_trades( &self, params: MyTradesParams, ) -> Result<RestApiResponse<Vec<MyTradesResponseInner>>>
Account trade list (USER_DATA)
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
fromIdis set, it will get trades >= thatfromId. Otherwise most recent trades are returned. - The time between
startTimeandendTimecan’t be longer than 24 hours. - These are the supported combinations of all parameters:
symbolsymbol+orderIdsymbol+startTimesymbol+endTimesymbol+fromIdsymbol+startTime+endTimesymbol+orderId+fromId
§Arguments
params:MyTradesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::MyTradesResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn open_order_list(
&self,
params: OpenOrderListParams,
) -> Result<RestApiResponse<Vec<OpenOrderListResponseInner>>>
pub async fn open_order_list( &self, params: OpenOrderListParams, ) -> Result<RestApiResponse<Vec<OpenOrderListResponseInner>>>
Query Open Order lists (USER_DATA)
Query Open Order lists
Weight(IP): 6
Security Type: USER_DATA
Notes: Data Source: Memory -> Database
§Arguments
params:OpenOrderListParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::OpenOrderListResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_amendments(
&self,
params: OrderAmendmentsParams,
) -> Result<RestApiResponse<Vec<OrderAmendmentsResponseInner>>>
pub async fn order_amendments( &self, params: OrderAmendmentsParams, ) -> Result<RestApiResponse<Vec<OrderAmendmentsResponseInner>>>
Query Order Amendments (USER_DATA)
Queries all amendments of a single order.
Weight(IP): 4
Security Type: USER_DATA
Notes: Data Source: Database
§Arguments
params:OrderAmendmentsParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::OrderAmendmentsResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn rate_limit_order(
&self,
params: RateLimitOrderParams,
) -> Result<RestApiResponse<Vec<RateLimitOrderResponseInner>>>
pub async fn rate_limit_order( &self, params: RateLimitOrderParams, ) -> Result<RestApiResponse<Vec<RateLimitOrderResponseInner>>>
Query Unfilled Order Count (USER_DATA)
Displays the user’s unfilled order count for all intervals.
Weight(IP): 40
Security Type: USER_DATA
Notes: Data Source: Memory
§Arguments
params:RateLimitOrderParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::RateLimitOrderResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn exchange_info(
&self,
params: ExchangeInfoParams,
) -> Result<RestApiResponse<ExchangeInfoResponse>>
pub async fn exchange_info( &self, params: ExchangeInfoParams, ) -> Result<RestApiResponse<ExchangeInfoResponse>>
Exchange information
Current exchange trading rules and symbol information
Weight(IP): 20
Security Type: NONE
Notes: Data Source: Memory
Notes:
- If the value provided to
symbolorsymbolsdo not exist, the endpoint will throw an error saying the symbol is invalid. - All parameters are optional.
permissionscan support single or multiple values (e.g.SPOT,["MARGIN","LEVERAGED"]). This cannot be used in combination withsymbolorsymbols.- If
permissionsparameter not provided, all symbols that have eitherSPOT,MARGIN, orLEVERAGEDpermission 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”.)
§Arguments
params:ExchangeInfoParamsThe parameters for this operation.
§Returns
RestApiResponse<models::ExchangeInfoResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn execution_rules(
&self,
params: ExecutionRulesParams,
) -> Result<RestApiResponse<ExecutionRulesResponse>>
pub async fn execution_rules( &self, params: ExecutionRulesParams, ) -> Result<RestApiResponse<ExecutionRulesResponse>>
Query Execution Rules
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.
§Arguments
params:ExecutionRulesParamsThe parameters for this operation.
§Returns
RestApiResponse<models::ExecutionRulesResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn ping(&self) -> Result<RestApiResponse<Value>>
pub async fn ping(&self) -> Result<RestApiResponse<Value>>
Test connectivity
Test connectivity to the Rest API.
Weight(IP): 1
Security Type: NONE
§Arguments
params: [PingParams] The parameters for this operation.
§Returns
RestApiResponse<Value> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn time(&self) -> Result<RestApiResponse<TimeResponse>>
pub async fn time(&self) -> Result<RestApiResponse<TimeResponse>>
Check server time
Test connectivity to the Rest API and get the current server time.
Weight(IP): 1
Security Type: NONE
§Arguments
params: [TimeParams] The parameters for this operation.
§Returns
RestApiResponse<models::TimeResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn agg_trades(
&self,
params: AggTradesParams,
) -> Result<RestApiResponse<Vec<AggTradesResponseInner>>>
pub async fn agg_trades( &self, params: AggTradesParams, ) -> Result<RestApiResponse<Vec<AggTradesResponseInner>>>
Compressed/Aggregate trades list
Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.
Weight(IP): 4
Security Type: NONE
Notes: Data Source: Database
- If fromId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.
§Arguments
params:AggTradesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::AggTradesResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn avg_price(
&self,
params: AvgPriceParams,
) -> Result<RestApiResponse<AvgPriceResponse>>
pub async fn avg_price( &self, params: AvgPriceParams, ) -> Result<RestApiResponse<AvgPriceResponse>>
Current average price
Current average price for a symbol.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:AvgPriceParamsThe parameters for this operation.
§Returns
RestApiResponse<models::AvgPriceResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn depth(
&self,
params: DepthParams,
) -> Result<RestApiResponse<DepthResponse>>
pub async fn depth( &self, params: DepthParams, ) -> Result<RestApiResponse<DepthResponse>>
Order book
Order book
Weight: Adjusted based on the limit:
| Limit | Request Weight |
|---|---|
| 1-100 | 5 |
| 101-500 | 25 |
| 501-1000 | 50 |
| 1001-5000 | 250 |
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:DepthParamsThe parameters for this operation.
§Returns
RestApiResponse<models::DepthResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn get_trades(
&self,
params: GetTradesParams,
) -> Result<RestApiResponse<Vec<GetTradesResponseInner>>>
pub async fn get_trades( &self, params: GetTradesParams, ) -> Result<RestApiResponse<Vec<GetTradesResponseInner>>>
Recent trades list
Get recent trades.
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:GetTradesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::GetTradesResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn historical_block_trades(
&self,
params: HistoricalBlockTradesParams,
) -> Result<RestApiResponse<Vec<HistoricalBlockTradesResponseInner>>>
pub async fn historical_block_trades( &self, params: HistoricalBlockTradesParams, ) -> Result<RestApiResponse<Vec<HistoricalBlockTradesResponseInner>>>
Historical Block Trades (MARKET_DATA)
Get block trades.
Weight(IP): 25
Security Type: MARKET_DATA
Notes:
- Data Source: Database
§Arguments
params:HistoricalBlockTradesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::HistoricalBlockTradesResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn historical_trades(
&self,
params: HistoricalTradesParams,
) -> Result<RestApiResponse<Vec<GetTradesResponseInner>>>
pub async fn historical_trades( &self, params: HistoricalTradesParams, ) -> Result<RestApiResponse<Vec<GetTradesResponseInner>>>
Old trade lookup
Get older trades.
Weight(IP): 25
Security Type: NONE
Notes: Data Source: Database
§Arguments
params:HistoricalTradesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::GetTradesResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn klines(
&self,
params: KlinesParams,
) -> Result<RestApiResponse<Vec<Vec<KlinesItemInner>>>>
pub async fn klines( &self, params: KlinesParams, ) -> Result<RestApiResponse<Vec<Vec<KlinesItemInner>>>>
Kline/Candlestick data
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
startTimeandendTimeare 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
timeZoneprovided, kline intervals are interpreted in that timezone instead of UTC. - Note that
startTimeandendTimeare always interpreted in UTC, regardless oftimeZone.
§Arguments
params:KlinesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<Vec<models::KlinesItemInner>>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn reference_price(
&self,
params: ReferencePriceParams,
) -> Result<RestApiResponse<ReferencePriceResponse>>
pub async fn reference_price( &self, params: ReferencePriceParams, ) -> Result<RestApiResponse<ReferencePriceResponse>>
Query Reference Price
Query the reference price for a symbol.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:ReferencePriceParamsThe parameters for this operation.
§Returns
RestApiResponse<models::ReferencePriceResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn reference_price_calculation(
&self,
params: ReferencePriceCalculationParams,
) -> Result<RestApiResponse<ReferencePriceCalculationResponse>>
pub async fn reference_price_calculation( &self, params: ReferencePriceCalculationParams, ) -> Result<RestApiResponse<ReferencePriceCalculationResponse>>
Query Reference Price Calculation
Describes how reference price is calculated for a given symbol.
Weight(IP): 2
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:ReferencePriceCalculationParamsThe parameters for this operation.
§Returns
RestApiResponse<models::ReferencePriceCalculationResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn ticker(
&self,
params: TickerParams,
) -> Result<RestApiResponse<TickerResponse>>
pub async fn ticker( &self, params: TickerParams, ) -> Result<RestApiResponse<TickerResponse>>
Rolling window price change statistics
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
§Arguments
params:TickerParamsThe parameters for this operation.
§Returns
RestApiResponse<models::TickerResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn ticker24hr(
&self,
params: Ticker24hrParams,
) -> Result<RestApiResponse<Ticker24hrResponse>>
pub async fn ticker24hr( &self, params: Ticker24hrParams, ) -> Result<RestApiResponse<Ticker24hrResponse>>
24hr ticker price change statistics
24 hour rolling window price change statistics. Careful when accessing this with no symbol.
Weight:
| Parameter | Symbols Provided | Weight |
|---|---|---|
| symbol | 1 | 2 |
| symbol parameter is omitted | 80 | |
| symbols | 1-20 | 2 |
| 21-100 | 40 | |
| 101 or more | 80 | |
| symbols parameter is omitted | 80 |
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:Ticker24hrParamsThe parameters for this operation.
§Returns
RestApiResponse<models::Ticker24hrResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn ticker_book_ticker(
&self,
params: TickerBookTickerParams,
) -> Result<RestApiResponse<TickerBookTickerResponse>>
pub async fn ticker_book_ticker( &self, params: TickerBookTickerParams, ) -> Result<RestApiResponse<TickerBookTickerResponse>>
Symbol order book ticker
Best price/qty on the order book for a symbol or symbols.
Weight: |Parameter|Symbols Provided|Weight| |—|—|—| |symbol| 1 |2| | |omitted| 4| |symbols| Any |4|
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:TickerBookTickerParamsThe parameters for this operation.
§Returns
RestApiResponse<models::TickerBookTickerResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn ticker_price(
&self,
params: TickerPriceParams,
) -> Result<RestApiResponse<TickerPriceResponse>>
pub async fn ticker_price( &self, params: TickerPriceParams, ) -> Result<RestApiResponse<TickerPriceResponse>>
Symbol price ticker
Latest price for a symbol or symbols.
Weight: |Parameter|Symbols Provided|Weight| |—|—|—| |symbol| 1 |2| | |omitted| 4| |symbols| Any |4|
Security Type: NONE
Notes: Data Source: Memory
§Arguments
params:TickerPriceParamsThe parameters for this operation.
§Returns
RestApiResponse<models::TickerPriceResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn ticker_trading_day(
&self,
params: TickerTradingDayParams,
) -> Result<RestApiResponse<TickerTradingDayResponse>>
pub async fn ticker_trading_day( &self, params: TickerTradingDayParams, ) -> Result<RestApiResponse<TickerTradingDayResponse>>
Trading Day Ticker
Price change statistics for a trading day.
Weight: 4 for each requested symbol. 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::
- Supported values for
timeZone: - Hours and minutes (e.g.
-1:00,05:45) - Only hours (e.g.
0,8,4)
§Arguments
params:TickerTradingDayParamsThe parameters for this operation.
§Returns
RestApiResponse<models::TickerTradingDayResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn ui_klines(
&self,
params: UiKlinesParams,
) -> Result<RestApiResponse<Vec<Vec<KlinesItemInner>>>>
pub async fn ui_klines( &self, params: UiKlinesParams, ) -> Result<RestApiResponse<Vec<Vec<KlinesItemInner>>>>
UIKlines
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
startTimeandendTimeare 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
timeZoneprovided, kline intervals are interpreted in that timezone instead of UTC. - Note that
startTimeandendTimeare always interpreted in UTC, regardless oftimeZone.
§Arguments
params:UiKlinesParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<Vec<models::KlinesItemInner>>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn delete_open_orders(
&self,
params: DeleteOpenOrdersParams,
) -> Result<RestApiResponse<Vec<DeleteOpenOrdersResponseInner>>>
pub async fn delete_open_orders( &self, params: DeleteOpenOrdersParams, ) -> Result<RestApiResponse<Vec<DeleteOpenOrdersResponseInner>>>
Cancel All Open Orders on a Symbol (TRADE)
Cancels all active 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
§Arguments
params:DeleteOpenOrdersParamsThe parameters for this operation.
§Returns
RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn delete_order(
&self,
params: DeleteOrderParams,
) -> Result<RestApiResponse<DeleteOrderResponse>>
pub async fn delete_order( &self, params: DeleteOrderParams, ) -> Result<RestApiResponse<DeleteOrderResponse>>
Cancel order (TRADE)
Cancel an active order.
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
- Either
orderIdororigClientOrderIdmust be sent. - If both
orderIdandorigClientOrderIdare provided, theorderIdis searched first, then theorigClientOrderIdfrom 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
orderIdis sent. SendingorigClientOrderIdor bothorderId+origClientOrderIdwill be slower.
§Arguments
params:DeleteOrderParamsThe parameters for this operation.
§Returns
RestApiResponse<models::DeleteOrderResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn delete_order_list(
&self,
params: DeleteOrderListParams,
) -> Result<RestApiResponse<DeleteOrderListResponse>>
pub async fn delete_order_list( &self, params: DeleteOrderListParams, ) -> Result<RestApiResponse<DeleteOrderListResponse>>
Cancel Order list (TRADE)
Cancel an entire Order list
Weight(IP): 1
Security Type: TRADE
Notes: Data Source: Matching Engine
Notes:
- Canceling an individual order from an order list will cancel the entire order list.
- If both orderListId and listClientOrderId parameters are provided, the orderListId is searched first, then the listClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected.
§Arguments
params:DeleteOrderListParamsThe parameters for this operation.
§Returns
RestApiResponse<models::DeleteOrderListResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn new_order(
&self,
params: NewOrderParams,
) -> Result<RestApiResponse<NewOrderResponse>>
pub async fn new_order( &self, params: NewOrderParams, ) -> Result<RestApiResponse<NewOrderResponse>>
New order (TRADE)
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_LIMITorders. - If
pegPriceTypeis specified,pricebecomes optional. Otherwise, it is still mandatory. pegPriceType=PRIMARY_PEGmeans the primary peg, that is the best price on the same side of the order book as your order.pegPriceType=MARKET_PEGmeans the market peg, that is the best price on the opposite side of the order book from your order.- Use
pegOffsetTypeandpegOffsetValueto request a price level other than the best one. These parameters must be specified together.
Other info:
- Any
LIMITorLIMIT_MAKERtype order can be made an iceberg order by sending anicebergQty. - Any order with an
icebergQtyMUST havetimeInForceset toGTC. - For
STOP_LOSS,STOP_LOSS_LIMIT,TAKE_PROFIT_LIMITandTAKE_PROFITorders,trailingDeltacan be combined withstopPrice. MARKETorders usingquoteOrderQtywill not breakLOT_SIZEfilter rules; the order will execute aquantitythat will have the notional value as close as possible toquoteOrderQty. Trigger order price rules against market price for both MARKET and LIMIT versions:- Price above market price:
STOP_LOSSBUY,TAKE_PROFITSELL - Price below market price:
STOP_LOSSSELL,TAKE_PROFITBUY
§Arguments
params:NewOrderParamsThe parameters for this operation.
§Returns
RestApiResponse<models::NewOrderResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_amend_keep_priority(
&self,
params: OrderAmendKeepPriorityParams,
) -> Result<RestApiResponse<OrderAmendKeepPriorityResponse>>
pub async fn order_amend_keep_priority( &self, params: OrderAmendKeepPriorityParams, ) -> Result<RestApiResponse<OrderAmendKeepPriorityResponse>>
Order Amend Keep Priority (TRADE)
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
§Arguments
params:OrderAmendKeepPriorityParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderAmendKeepPriorityResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_cancel_replace(
&self,
params: OrderCancelReplaceParams,
) -> Result<RestApiResponse<OrderCancelReplaceResponse>>
pub async fn order_cancel_replace( &self, params: OrderCancelReplaceParams, ) -> Result<RestApiResponse<OrderCancelReplaceResponse>>
Cancel an Existing Order and Send a New Order (TRADE)
- 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
orderIdis sent. SendingorigClientOrderIdor bothorderId+origClientOrderIdwill be slower.
§Arguments
params:OrderCancelReplaceParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderCancelReplaceResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_list_oco(
&self,
params: OrderListOcoParams,
) -> Result<RestApiResponse<OrderListOcoResponse>>
pub async fn order_list_oco( &self, params: OrderListOcoParams, ) -> Result<RestApiResponse<OrderListOcoResponse>>
New Order list - OCO (TRADE)
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_LIMITorder and the other must beSTOP_LOSSorSTOP_LOSS_LIMITorder. - Price restrictions
- If the OCO is on the
SELLside: LIMIT_MAKER/TAKE_PROFIT_LIMITprice> Last Traded Price >STOP_LOSS/STOP_LOSS_LIMITstopPriceTAKE_PROFIT stopPrice> Last Traded Price >STOP_LOSS/STOP_LOSS_LIMIT stopPrice- If the OCO is on the
BUYside: LIMIT_MAKER/TAKE_PROFIT_LIMIT price< Last Traded Price <stopPriceTAKE_PROFIT stopPrice< Last Traded Price <STOP_LOSS/STOP_LOSS_LIMIT stopPrice* OCOs add 2 orders to theEXCHANGE_MAX_ORDERSfilter and theMAX_NUM_ORDERSfilter.- OCOs add 2 orders to the
EXCHANGE_MAX_ORDERSfilter and theMAX_NUM_ORDERSfilter.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
§Arguments
params:OrderListOcoParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderListOcoResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_list_opo(
&self,
params: OrderListOpoParams,
) -> Result<RestApiResponse<OrderListOpoResponse>>
pub async fn order_list_opo( &self, params: OrderListOpoParams, ) -> Result<RestApiResponse<OrderListOpoResponse>>
New Order List - OPO (TRADE)
Place an OPO.
- OPOs add 2 orders to the
EXCHANGE_MAX_NUM_ORDERS`` filter andMAX_NUM_ORDERS`` filter.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
§Arguments
params:OrderListOpoParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderListOpoResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_list_opoco(
&self,
params: OrderListOpocoParams,
) -> Result<RestApiResponse<OrderListOpocoResponse>>
pub async fn order_list_opoco( &self, params: OrderListOpocoParams, ) -> Result<RestApiResponse<OrderListOpocoResponse>>
New Order List - OPOCO (TRADE)
Place an OPOCO.
Weight(IP): 1
Unfilled Order Count: 3
Security Type: TRADE
Notes: Data Source: Matching Engine
§Arguments
params:OrderListOpocoParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderListOpocoResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_list_oto(
&self,
params: OrderListOtoParams,
) -> Result<RestApiResponse<OrderListOtoResponse>>
pub async fn order_list_oto( &self, params: OrderListOtoParams, ) -> Result<RestApiResponse<OrderListOtoResponse>>
New Order list - OTO (TRADE)
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
LIMITorLIMIT_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
MARKETorders using parameterquoteOrderQty. 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
FILLEDbut the pending order will still appear asPENDING_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_ORDERSfilter andMAX_NUM_ORDERSfilter.
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 |
§Arguments
params:OrderListOtoParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderListOtoResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_list_otoco(
&self,
params: OrderListOtocoParams,
) -> Result<RestApiResponse<OrderListOtocoResponse>>
pub async fn order_list_otoco( &self, params: OrderListOtocoParams, ) -> Result<RestApiResponse<OrderListOtocoResponse>>
New Order list - OTOCO (TRADE)
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
LIMITorLIMIT_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_ORDERSfilter andMAX_NUM_ORDERSfilter.
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 |
§Arguments
params:OrderListOtocoParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderListOtocoResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn order_oco(
&self,
params: OrderOcoParams,
) -> Result<RestApiResponse<OrderOcoResponse>>
👎Deprecated
pub async fn order_oco( &self, params: OrderOcoParams, ) -> Result<RestApiResponse<OrderOcoResponse>>
New OCO - Deprecated (TRADE)
Send in a new OCO.
- Price Restrictions:
SELL: Limit Price > Last Price > Stop PriceBUY: Limit Price < Last Price < Stop Price- Quantity Restrictions:
- Both legs must have the same quantity.
ICEBERGquantities however do not have to be the sameOCOadds 2 orders to theEXCHANGE_MAX_ORDERSfilter and theMAX_NUM_ORDERSfilter.
Weight(IP): 1
Unfilled Order Count: 2
Security Type: TRADE
Notes: Data Source: Matching Engine
§Arguments
params:OrderOcoParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderOcoResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
§Deprecation
Deprecated: This method may be removed in a future version.
Sourcepub async fn order_test(
&self,
params: OrderTestParams,
) -> Result<RestApiResponse<OrderTestResponse>>
pub async fn order_test( &self, params: OrderTestParams, ) -> Result<RestApiResponse<OrderTestResponse>>
Test new order (TRADE)
Test new order creation and signature/recvWindow long.
Creates and validates a new order but does not send it into the matching engine.
Weight: |Condition|Weight|
|—|—|
|Without computeCommissionRates|1|
|With computeCommissionRates|20|
Security Type: TRADE
Notes: Data Source: Memory
§Arguments
params:OrderTestParamsThe parameters for this operation.
§Returns
RestApiResponse<models::OrderTestResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn sor_order(
&self,
params: SorOrderParams,
) -> Result<RestApiResponse<SorOrderResponse>>
pub async fn sor_order( &self, params: SorOrderParams, ) -> Result<RestApiResponse<SorOrderResponse>>
New order using SOR (TRADE)
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: POST /api/v3/sor/order only supports LIMIT and MARKET orders. quoteOrderQty is not supported.
§Arguments
params:SorOrderParamsThe parameters for this operation.
§Returns
RestApiResponse<models::SorOrderResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.
Sourcepub async fn sor_order_test(
&self,
params: SorOrderTestParams,
) -> Result<RestApiResponse<SorOrderTestResponse>>
pub async fn sor_order_test( &self, params: SorOrderTestParams, ) -> Result<RestApiResponse<SorOrderTestResponse>>
Test new order using SOR (TRADE)
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|Weight|
|—|—|
|Without computeCommissionRates|1|
|With computeCommissionRates|20|
Security Type: TRADE
Notes: Data Source: Memory
§Arguments
params:SorOrderTestParamsThe parameters for this operation.
§Returns
RestApiResponse<models::SorOrderTestResponse> on success.
§Errors
This function will return an anyhow::Error if:
- the HTTP request fails
- any parameter is invalid
- the response cannot be parsed
- or one of the following occurs:
RequiredErrorConnectorClientErrorUnauthorizedErrorForbiddenErrorTooManyRequestsErrorRateLimitBanErrorServerErrorNotFoundErrorNetworkErrorBadRequestError
For full API details, see the Binance API Documentation.