Skip to main content

Client

Struct Client 

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

The async client for interacting with the Datamaxi+ API.

This is the default surface. For a synchronous client, enable the sync feature and use [sync::Client].

Cloning a Client is cheap: the shared state lives behind an Arc, so a clone is a single refcount bump.

Implementations§

Source§

impl Client

Source

pub fn new(api_key: impl Into<String>) -> Self

Creates a new client authenticating with the given API key.

Uses the production base URL and the default timeout ([DEFAULT_TIMEOUT]). For control over the base URL, timeout, or reading the API key from the environment, use ClientBuilder. Endpoint groups are reached via accessors, e.g. Client::cex_candle.

Source

pub async fn get<T: DeserializeOwned>( &self, endpoint: &str, parameters: Option<BTreeMap<String, String>>, ) -> Result<T>

Sends a GET request to the specified endpoint with optional parameters.

Transient failures (timeouts, connection errors, 429, and 5xx) are retried per the client’s [RetryConfig] with exponential backoff; a 429 honors its Retry-After header. Fatal statuses (400/401/403/404) are returned without retry.

With the tracing feature enabled, each call is wrapped in a span carrying method, endpoint, attempt, and the resolved status; retries additionally emit a debug event with the backoff delay. The API key is never recorded.

Source

pub fn paginate<T>( &self, endpoint: impl Into<String>, params: BTreeMap<String, String>, ) -> Paginator<T>

Returns an auto-paginator over a paged endpoint (see Paginated).

params seeds the query string for every page (e.g. limit, sort, filters); a page key in params sets the starting page (defaults to 1) and is overwritten on each subsequent request as the paginator advances. Call Paginator::next_page in a loop to walk forward.

Source§

impl Client

Source

pub fn announcements(&self) -> Announcements

Returns a handle to the Announcements endpoint group.

Source

pub fn cex_candle(&self) -> CexCandle

Returns a handle to the CexCandle endpoint group.

Source

pub fn cex_symbol(&self) -> CexSymbol

Returns a handle to the CexSymbol endpoint group.

Source

pub fn forex(&self) -> Forex

Returns a handle to the Forex endpoint group.

Source

pub fn funding_rate(&self) -> FundingRate

Returns a handle to the FundingRate endpoint group.

Source

pub fn index_price(&self) -> IndexPrice

Returns a handle to the IndexPrice endpoint group.

Source

pub fn liquidation(&self) -> Liquidation

Returns a handle to the Liquidation endpoint group.

Source

pub fn listing(&self) -> Listing

Returns a handle to the Listing endpoint group.

Source

pub fn margin_borrow(&self) -> MarginBorrow

Returns a handle to the MarginBorrow endpoint group.

Source

pub fn naver_trend(&self) -> NaverTrend

Returns a handle to the NaverTrend endpoint group.

Source

pub fn open_interest(&self) -> OpenInterest

Returns a handle to the OpenInterest endpoint group.

Source

pub fn premium(&self) -> Premium

Returns a handle to the Premium endpoint group.

Source

pub fn telegram(&self) -> Telegram

Returns a handle to the Telegram endpoint group.

Source

pub fn ticker(&self) -> Ticker

Returns a handle to the Ticker endpoint group.

Source

pub fn token(&self) -> Token

Returns a handle to the Token endpoint group.

Source

pub fn trading_fees(&self) -> TradingFees

Returns a handle to the TradingFees endpoint group.

Source

pub fn wallet_status(&self) -> WalletStatus

Returns a handle to the WalletStatus endpoint group.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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 Client

Source§

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

Redacts the API key so it never leaks into logs or error output.

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, 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.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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