Skip to main content

RestApi

Struct RestApi 

Source
pub struct RestApi { /* private fields */ }

Implementations§

Source§

impl RestApi

Source

pub fn new(configuration: ConfigurationRestApi) -> Self

Source

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 to
  • method - The HTTP method to use for the request
  • query_params - A map of query parameters to send with the request
  • body_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

Source

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 to
  • method - The HTTP method to use for the request
  • query_params - A map of query parameters to send with the request
  • body_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

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
  • For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.
  • If startTime and/or endTime provided, orderId is not required.
  • The time between startTime and endTime can’t be longer than 24 hours.
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 orderId or origClientOrderId must be sent.
  • If both orderId and origClientOrderId are provided, the orderId is searched first, then the origClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected.
  • For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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:

ParametersResponse
symbolallocations from oldest to newest
symbol + startTimeoldest allocations since startTime
symbol + endTimenewest allocations until endTime
symbol + startTime + endTimeallocations within the time range
symbol + fromAllocationIdallocations by allocation ID
symbol + orderIdallocations related to an order starting with oldest
symbol + orderId + fromAllocationIdallocations related to an order by allocation ID

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

§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 + preventedMatchId
  • symbol + orderId
  • symbol + orderId + fromPreventedMatchId (limit will default to 500)
  • symbol + orderId + fromPreventedMatchId + limit
Weight: CaseWeight
If symbol is invalid2
Querying by preventedMatchId2
Querying by orderId20

Security Type: USER_DATA

Notes: Data Source: Database

§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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: ConditionWeight
Without orderId20
With orderId5

Security Type: USER_DATA

Notes: Data Source: Memory => Database

Notes::

  • If fromId is set, it will get trades >= that fromId. Otherwise most recent trades are returned.
  • The time between startTime and endTime can’t be longer than 24 hours.
  • These are the supported combinations of all parameters:
  • symbol
  • symbol + orderId
  • symbol + startTime
  • symbol + endTime
  • symbol + fromId
  • symbol + startTime + endTime
  • symbol+ orderId + fromId
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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

Examples of Symbol Permissions Interpretation from the Response:

  • [["A","B"]] means you may place an order if your account has either permission “A” or permission “B”.
  • [["A"],["B"]] means you can place an order if your account has permission “A” and permission “B”.
  • [["A"],["B","C"]] means you can place an order if your account has permission “A” and permission “B” or permission “C”. (Inclusive or is applied here, not exclusive or, so your account may have both permission “B” and permission “C”.)
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

pub async fn execution_rules( &self, params: ExecutionRulesParams, ) -> Result<RestApiResponse<ExecutionRulesResponse>>

Query Execution Rules

Query execution rules for symbols.

Weight: ParameterWeight
symbol2
symbols2 for each symbol, capped at a max of 40
symbolStatus40
None40

Security Type: NONE

Notes: Data Source: Memory

Note:: No combination of multiple parameters is allowed.

§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

pub async fn depth( &self, params: DepthParams, ) -> Result<RestApiResponse<DepthResponse>>

Order book

Order book

Weight: Adjusted based on the limit:

LimitRequest Weight
1-1005
101-50025
501-100050
1001-5000250

Security Type: NONE

Notes: Data Source: Memory

§Arguments
  • params: DepthParams The 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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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):

Intervalinterval value
seconds1s
minutes1m, 3m, 5m, 15m, 30m
hours1h, 2h, 4h, 6h, 8h, 12h
days1d, 3d
weeks1w
months1M

Notes:

  • If startTime and endTime are not sent, the most recent klines are returned.
  • Supported values for timeZone:
  • Hours and minutes (e.g. -1:00, 05:45)
  • Only hours (e.g. 0, 8, 4)
  • Accepted range is strictly [-12:00 to +14:00] inclusive
  • If timeZone provided, kline intervals are interpreted in that timezone instead of UTC.
  • Note that startTime and endTime are always interpreted in UTC, regardless of timeZone.
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 startTime and endTime are not sent, the most recent klines are returned.
  • Supported values for timeZone:
  • Hours and minutes (e.g. -1:00, 05:45)
  • Only hours (e.g. 0, 8, 4)
  • Accepted range is strictly [-12:00 to +14:00] inclusive
  • If timeZone provided, kline intervals are interpreted in that timezone instead of UTC.
  • Note that startTime and endTime are always interpreted in UTC, regardless of timeZone.
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 orderId or origClientOrderId must be sent.
  • If both orderId and origClientOrderId are provided, the orderId is searched first, then the origClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected.
  • The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only orderId is sent. Sending origClientOrderId or both orderId + origClientOrderId will be slower.
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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:

TypeAdditional mandatory parametersAdditional Information
LIMITtimeInForce, quantity, price
MARKETquantity or quoteOrderQtyMARKET 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_LOSSquantity, stopPrice or trailingDeltaThis will execute a MARKET order when the conditions are met. (e.g. stopPrice is met or trailingDelta is activated)
STOP_LOSS_LIMITtimeInForce, quantity, price, stopPrice or trailingDelta
TAKE_PROFITquantity, stopPrice or trailingDeltaThis will execute a MARKET order when the conditions are met. (e.g. stopPrice is met or trailingDelta is activated)
TAKE_PROFIT_LIMITtimeInForce, quantity, price, stopPrice or trailingDelta
LIMIT_MAKERquantity, priceThis is a LIMIT order that will be rejected if the order immediately matches and trades as a taker.
This is also known as a POST-ONLY order.

Notes on using parameters for Pegged Orders:

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

Other info:

  • Any LIMIT or LIMIT_MAKER type order can be made an iceberg order by sending an icebergQty.
  • Any order with an icebergQty MUST have timeInForce set to GTC.
  • For STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT_LIMIT and TAKE_PROFIT orders, trailingDelta can be combined with stopPrice.
  • MARKET orders using quoteOrderQty will not break LOT_SIZE filter rules; the order will execute a quantity that will have the notional value as close as possible to quoteOrderQty. Trigger order price rules against market price for both MARKET and LIMIT versions:
  • Price above market price: STOP_LOSS BUY, TAKE_PROFIT SELL
  • Price below market price: STOP_LOSS SELL, TAKE_PROFIT BUY
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 orderId is sent. Sending origClientOrderId or both orderId + origClientOrderId will be slower.
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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_LIMIT order and the other must be STOP_LOSS or STOP_LOSS_LIMIT order.
  • Price restrictions
  • If the OCO is on the SELL side:
  • LIMIT_MAKER/TAKE_PROFIT_LIMIT price > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice
  • TAKE_PROFIT stopPrice > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice
  • If the OCO is on the BUY side:
  • LIMIT_MAKER/TAKE_PROFIT_LIMIT price < Last Traded Price < stopPrice
  • TAKE_PROFIT stopPrice < Last Traded Price < STOP_LOSS/STOP_LOSS_LIMIT stopPrice * OCOs add 2 orders to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
  • OCOs add 2 orders to the EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.

Weight(IP): 1

Unfilled Order Count: 2

Security Type: TRADE

Notes: Data Source: Matching Engine

§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 and MAX_NUM_ORDERS`` filter.

Weight(IP): 1

Unfilled Order Count: 2

Security Type: TRADE

Notes: Data Source: Matching Engine

§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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

Weight(IP): 1

Unfilled Order Count: 2

Security Type: TRADE

Notes: Data Source: Matching Engine

Mandatory parameters based on pendingType or workingType

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

TypeAdditional mandatory parametersAdditional information
workingType = LIMITworkingTimeInForce
pendingType = LIMITpendingPrice, pendingTimeInForce
pendingType = STOP_LOSS or TAKE_PROFITpendingStopPrice and/or pendingTrailingDelta
pendingType = STOP_LOSS_LIMIT or TAKE_PROFIT_LIMITpendingPrice, pendingStopPrice and/or pendingTrailingDelta, pendingTimeInForce
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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 LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book.
  • The behavior of the working order is the same as the OTO.
  • OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets fully filled.
  • The rules of the pending above and pending below follow the same rules as the Order list OCO.
  • OTOCOs add 3 orders to the EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter.

Weight(IP): 1

Unfilled Order Count: 3

Security Type: TRADE

Notes: Data Source: Matching Engine

Mandatory parameters based on pendingAboveType, pendingBelowType or workingType

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

TypeAdditional mandatory parametersAdditional information
workingType = LIMITworkingTimeInForce
pendingAboveType= LIMIT_MAKERpendingAbovePrice
pendingAboveType = STOP_LOSS/TAKE_PROFITpendingAboveStopPrice and/or pendingAboveTrailingDelta
pendingAboveType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMITpendingAbovePrice, pendingAboveStopPrice and/or pendingAboveTrailingDelta, pendingAboveTimeInForce
pendingBelowType= LIMIT_MAKERpendingBelowPrice
pendingBelowType= STOP_LOSS/TAKE_PROFITpendingBelowStopPrice and/or pendingBelowTrailingDelta
pendingBelowType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMITpendingBelowPrice, pendingBelowStopPrice and/or pendingBelowTrailingDelta, pendingBelowTimeInForce
§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

pub async fn order_oco( &self, params: OrderOcoParams, ) -> Result<RestApiResponse<OrderOcoResponse>>

👎Deprecated

New OCO - Deprecated (TRADE)

Send in a new OCO.

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

Weight(IP): 1

Unfilled Order Count: 2

Security Type: TRADE

Notes: Data Source: Matching Engine

§Arguments
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

§Deprecation

Deprecated: This method may be removed in a future version.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Source

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
§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:
    • RequiredError
    • ConnectorClientError
    • UnauthorizedError
    • ForbiddenError
    • TooManyRequestsError
    • RateLimitBanError
    • ServerError
    • NotFoundError
    • NetworkError
    • BadRequestError

For full API details, see the Binance API Documentation.

Trait Implementations§

Source§

impl Clone for RestApi

Source§

fn clone(&self) -> RestApi

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RestApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more