bpx_api_client

Struct BpxClient

Source
pub struct BpxClient { /* private fields */ }
Expand description

A client for interacting with the Backpack Exchange API.

Implementations§

Source§

impl BpxClient

Source

pub async fn get_balances(&self) -> Result<HashMap<String, Balance>>

Fetches the account’s current balances.

Source

pub async fn get_deposits( &self, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<Deposit>>

Retrieves a list of deposits with optional pagination.

Source

pub async fn get_deposit_address( &self, blockchain: Blockchain, ) -> Result<DepositAddress>

Fetches the deposit address for a specified blockchain.

Source

pub async fn get_withdrawals( &self, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<Withdrawal>>

Retrieves a list of withdrawals with optional pagination.

Source

pub async fn request_withdrawal( &self, payload: RequestWithdrawalPayload, ) -> Result<Withdrawal>

Submits a withdrawal request for the specified payload.

Source§

impl BpxClient

Source

pub async fn get_assets(&self) -> Result<HashMap<String, Vec<Token>>>

Fetches available assets and their associated tokens.

Source

pub async fn get_markets(&self) -> Result<Vec<Market>>

Retrieves a list of available markets.

Source

pub async fn get_ticker(&self, symbol: &str) -> Result<Ticker>

Fetches the ticker information for a given symbol.

Source

pub async fn get_tickers(&self) -> Result<Vec<Ticker>>

Fetches the ticker information for all symbols.

Source

pub async fn get_order_book_depth(&self, symbol: &str) -> Result<OrderBookDepth>

Retrieves the order book depth for a given symbol.

Source

pub async fn get_k_lines( &self, symbol: &str, kline_interval: &str, start_time: Option<i64>, end_time: Option<i64>, ) -> Result<Vec<Kline>>

Fetches historical K-line (candlestick) data for a given symbol and interval.

Source§

impl BpxClient

Source

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.

Source

pub async fn execute_order(&self, payload: ExecuteOrderPayload) -> Result<Order>

Executes a new order with the given payload.

Source

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.

Source

pub async fn get_open_orders(&self, symbol: Option<&str>) -> Result<Vec<Order>>

Retrieves all open orders, optionally filtered by symbol.

Source

pub async fn cancel_open_orders( &self, payload: CancelOpenOrdersPayload, ) -> Result<Vec<Order>>

Cancels all open orders matching the specified payload.

Source§

impl BpxClient

Source

pub async fn submit_rfq( &self, payload: RequestForQuotePayload, ) -> Result<RequestForQuote>

Source

pub async fn submit_quote(&self, payload: QuotePayload) -> Result<Quote>

Source§

impl BpxClient

Source

pub async fn get_recent_trades( &self, symbol: &str, limit: Option<i16>, ) -> Result<Vec<Trade>>

Fetches the most recent trades for a given symbol, with an optional limit.

Source

pub async fn get_historical_trades( &self, symbol: &str, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<Trade>>

Fetches historical trades for a given symbol, with optional limit and offset.

Source§

impl BpxClient

Source

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

Source

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.

Source

pub fn create_headers() -> BpxHeaders

Creates a new, empty BpxHeaders instance.

Source

pub async fn get<U: IntoUrl>(&self, url: U) -> Result<Response>

Sends a GET request to the specified URL and signs it before execution.

Source

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.

Source

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.

Source

pub fn verifier(&self) -> &VerifyingKey

Returns a reference to the VerifyingKey used for request verification.

Source

pub fn client(&self) -> &Client

Returns a reference to the underlying HTTP client.

Methods from Deref<Target = Client>§

Source

pub fn get<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a GET request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn post<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a POST request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn put<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a PUT request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn patch<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a PATCH request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn delete<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a DELETE request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn head<U>(&self, url: U) -> RequestBuilder
where U: IntoUrl,

Convenience method to make a HEAD request to a URL.

§Errors

This method fails whenever the supplied Url cannot be parsed.

Source

pub fn request<U>(&self, method: Method, url: U) -> RequestBuilder
where 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.

Source

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.

Trait Implementations§

Source§

impl AsRef<Client> for BpxClient

Source§

fn as_ref(&self) -> &Client

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for BpxClient

Source§

fn clone(&self) -> BpxClient

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BpxClient

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for BpxClient

Source§

type Target = Client

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for BpxClient

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

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<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T