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

Get current account commission rates. Weight: 20

§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

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

§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

Get all account orders; active, canceled, or filled. Weight: 20

§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

Get current account information. Weight: 20

§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<AllOrdersResponseInner>>>

Current open orders

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

§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_order( &self, params: GetOrderParams, ) -> Result<RestApiResponse<GetOrderResponse>>

Query order

Check an order’s status. Weight: 4

§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

Retrieves a specific order list based on provided optional parameters. Weight: 4

§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

Retrieves allocations resulting from SOR order placement. Weight: 20

§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

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

§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

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: Case | Weight –– | —– If symbol is invalid | 2 Querying by preventedMatchId | 2 Querying by orderId | 20
§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

Get trades for a specific account and symbol. Weight: Condition| Weight| —| — |Without orderId|20| |With orderId|5|

§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

Weight: 6

§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

Queries all amendments of a single order. Weight: 4

§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

Displays the user’s unfilled order count for all intervals. Weight: 40

§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: 20

§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

Weight: ParameterWeight
symbol2
symbols2 for each symbol, capped at a max of 40
symbolStatus40
None40
§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: 1

§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: 1

§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: 4

§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: 2

§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

Weight: Adjusted based on the limit:

LimitRequest Weight
1-1005
101-50025
501-100050
1001-5000250
§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<HistoricalTradesResponseInner>>>

Recent trades list

Get recent trades. Weight: 25

§Arguments
§Returns

RestApiResponse<Vec<models::HistoricalTradesResponseInner>> 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

Get block trades. Weight: 25

§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<HistoricalTradesResponseInner>>>

Old trade lookup

Get older trades. Weight: 25

§Arguments
§Returns

RestApiResponse<Vec<models::HistoricalTradesResponseInner>> 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: 2

§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

Weight: 2

§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: 2

§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

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.

§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
§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
symbol parameter is omitted 4
symbols Any 4
§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
symbol parameter is omitted 4
symbols Any 4
§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.

§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: 2

§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

Cancels all active orders on a symbol. This includes orders that are part of an order list. Weight: 1

§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

Cancel an active order. Weight: 1

§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

Cancel an entire Order list Weight: 1

§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

Send in a new order.

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

§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

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

§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

  • 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: 1
§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

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. Weight: 1

Unfilled Order Count: 2

§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

Place an OPO.

  • OPOs add 2 orders to the EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter. Weight: 1

Unfilled Order Count: 2

§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

Place an OPOCO. Weight: 1

Unfilled Order Count: 3

§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

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

Unfilled Order Count: 2

§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

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

Unfilled Order Count: 3

§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

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

Unfilled Order Count: 2

§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

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| Request Weight| |———— | ———— | |Without computeCommissionRates| 1| |With computeCommissionRates|20|

§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

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

Unfilled Order Count: 1

§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

Test new order creation and signature/recvWindow using smart order routing (SOR). Creates and validates a new order but does not send it into the matching engine. Weight: | Condition | Request Weight | | ——— | ––––––– | | Without computeCommissionRates | 1 | | With computeCommissionRates | 20 |

§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