pub struct BpxClient { /* private fields */ }
Expand description
A client for interacting with the Backpack Exchange API.
Implementations§
Source§impl BpxClient
impl BpxClient
Sourcepub async fn get_balances(&self) -> Result<HashMap<String, Balance>>
pub async fn get_balances(&self) -> Result<HashMap<String, Balance>>
Fetches the account’s current balances.
Sourcepub async fn get_deposits(
&self,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Vec<Deposit>>
pub async fn get_deposits( &self, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<Deposit>>
Retrieves a list of deposits with optional pagination.
Sourcepub async fn get_deposit_address(
&self,
blockchain: Blockchain,
) -> Result<DepositAddress>
pub async fn get_deposit_address( &self, blockchain: Blockchain, ) -> Result<DepositAddress>
Fetches the deposit address for a specified blockchain.
Sourcepub async fn get_withdrawals(
&self,
limit: Option<i64>,
offset: Option<i64>,
) -> Result<Vec<Withdrawal>>
pub async fn get_withdrawals( &self, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<Withdrawal>>
Retrieves a list of withdrawals with optional pagination.
Sourcepub async fn request_withdrawal(
&self,
payload: RequestWithdrawalPayload,
) -> Result<Withdrawal>
pub async fn request_withdrawal( &self, payload: RequestWithdrawalPayload, ) -> Result<Withdrawal>
Submits a withdrawal request for the specified payload.
Source§impl BpxClient
impl BpxClient
Sourcepub async fn get_assets(&self) -> Result<HashMap<String, Vec<Token>>>
pub async fn get_assets(&self) -> Result<HashMap<String, Vec<Token>>>
Fetches available assets and their associated tokens.
Sourcepub async fn get_markets(&self) -> Result<Vec<Market>>
pub async fn get_markets(&self) -> Result<Vec<Market>>
Retrieves a list of available markets.
Sourcepub async fn get_ticker(&self, symbol: &str) -> Result<Ticker>
pub async fn get_ticker(&self, symbol: &str) -> Result<Ticker>
Fetches the ticker information for a given symbol.
Sourcepub async fn get_tickers(&self) -> Result<Vec<Ticker>>
pub async fn get_tickers(&self) -> Result<Vec<Ticker>>
Fetches the ticker information for all symbols.
Sourcepub async fn get_order_book_depth(&self, symbol: &str) -> Result<OrderBookDepth>
pub async fn get_order_book_depth(&self, symbol: &str) -> Result<OrderBookDepth>
Retrieves the order book depth for a given symbol.
Source§impl BpxClient
impl BpxClient
Sourcepub async fn get_open_order(
&self,
symbol: &str,
order_id: Option<&str>,
client_id: Option<u32>,
) -> Result<Order>
pub async fn get_open_order( &self, symbol: &str, order_id: Option<&str>, client_id: Option<u32>, ) -> Result<Order>
Fetches a specific open order by symbol and either order ID or client ID.
Sourcepub async fn execute_order(&self, payload: ExecuteOrderPayload) -> Result<Order>
pub async fn execute_order(&self, payload: ExecuteOrderPayload) -> Result<Order>
Executes a new order with the given payload.
Sourcepub async fn cancel_order(
&self,
symbol: &str,
order_id: Option<&str>,
client_id: Option<u32>,
) -> Result<Order>
pub async fn cancel_order( &self, symbol: &str, order_id: Option<&str>, client_id: Option<u32>, ) -> Result<Order>
Cancels a specific order by symbol and either order ID or client ID.
Sourcepub async fn get_open_orders(&self, symbol: Option<&str>) -> Result<Vec<Order>>
pub async fn get_open_orders(&self, symbol: Option<&str>) -> Result<Vec<Order>>
Retrieves all open orders, optionally filtered by symbol.
Sourcepub async fn cancel_open_orders(
&self,
payload: CancelOpenOrdersPayload,
) -> Result<Vec<Order>>
pub async fn cancel_open_orders( &self, payload: CancelOpenOrdersPayload, ) -> Result<Vec<Order>>
Cancels all open orders matching the specified payload.
Source§impl BpxClient
impl BpxClient
pub async fn submit_rfq( &self, payload: RequestForQuotePayload, ) -> Result<RequestForQuote>
pub async fn submit_quote(&self, payload: QuotePayload) -> Result<Quote>
Source§impl BpxClient
impl BpxClient
Source§impl BpxClient
impl BpxClient
Sourcepub async fn request_two_factor(
&self,
payload: RequestTwoFactorPayload,
) -> Result<RequestTwoFactorResponse>
pub async fn request_two_factor( &self, payload: RequestTwoFactorPayload, ) -> Result<RequestTwoFactorResponse>
Requests a two-factor authentication token.
Sends a request to initiate the two-factor authentication process with the provided payload and returns the response.
Source§impl BpxClient
impl BpxClient
Sourcepub fn init(
base_url: String,
secret: &str,
headers: Option<BpxHeaders>,
) -> Result<Self>
pub fn init( base_url: String, secret: &str, headers: Option<BpxHeaders>, ) -> Result<Self>
Initializes a new client with the given base URL, API secret, and optional headers.
This sets up the signing and verification keys, and creates a reqwest
client
with default headers including the API key and content type.
Sourcepub fn create_headers() -> BpxHeaders
pub fn create_headers() -> BpxHeaders
Creates a new, empty BpxHeaders
instance.
Sourcepub async fn get<U: IntoUrl>(&self, url: U) -> Result<Response>
pub async fn get<U: IntoUrl>(&self, url: U) -> Result<Response>
Sends a GET request to the specified URL and signs it before execution.
Sourcepub async fn post<P: Serialize, U: IntoUrl>(
&self,
url: U,
payload: P,
) -> Result<Response>
pub async fn post<P: Serialize, U: IntoUrl>( &self, url: U, payload: P, ) -> Result<Response>
Sends a POST request with a JSON payload to the specified URL and signs it.
Sourcepub async fn delete<P: Serialize, U: IntoUrl>(
&self,
url: U,
payload: P,
) -> Result<Response>
pub async fn delete<P: Serialize, U: IntoUrl>( &self, url: U, payload: P, ) -> Result<Response>
Sends a DELETE request with a JSON payload to the specified URL and signs it.
Sourcepub fn verifier(&self) -> &VerifyingKey
pub fn verifier(&self) -> &VerifyingKey
Returns a reference to the VerifyingKey
used for request verification.
Methods from Deref<Target = Client>§
Sourcepub fn get<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
pub fn get<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
Convenience method to make a GET
request to a URL.
§Errors
This method fails whenever the supplied Url
cannot be parsed.
Sourcepub fn post<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
pub fn post<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
Convenience method to make a POST
request to a URL.
§Errors
This method fails whenever the supplied Url
cannot be parsed.
Sourcepub fn put<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
pub fn put<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
Convenience method to make a PUT
request to a URL.
§Errors
This method fails whenever the supplied Url
cannot be parsed.
Sourcepub fn patch<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
pub fn patch<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
Convenience method to make a PATCH
request to a URL.
§Errors
This method fails whenever the supplied Url
cannot be parsed.
Sourcepub fn delete<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
pub fn delete<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
Convenience method to make a DELETE
request to a URL.
§Errors
This method fails whenever the supplied Url
cannot be parsed.
Sourcepub fn head<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
pub fn head<U>(&self, url: U) -> RequestBuilderwhere
U: IntoUrl,
Convenience method to make a HEAD
request to a URL.
§Errors
This method fails whenever the supplied Url
cannot be parsed.
Sourcepub fn request<U>(&self, method: Method, url: U) -> RequestBuilderwhere
U: IntoUrl,
pub fn request<U>(&self, method: Method, url: U) -> RequestBuilderwhere
U: IntoUrl,
Start building a Request
with the Method
and Url
.
Returns a RequestBuilder
, which will allow setting headers and
the request body before sending.
§Errors
This method fails whenever the supplied Url
cannot be parsed.
Sourcepub fn execute(
&self,
request: Request,
) -> impl Future<Output = Result<Response, Error>>
pub fn execute( &self, request: Request, ) -> impl Future<Output = Result<Response, Error>>
Executes a Request
.
A Request
can be built manually with Request::new()
or obtained
from a RequestBuilder with RequestBuilder::build()
.
You should prefer to use the RequestBuilder
and
RequestBuilder::send()
.
§Errors
This method fails if there was an error while sending request, redirect loop was detected or redirect limit was exhausted.