Skip to main content

PrecolatorClient

Struct PrecolatorClient 

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

Async client for interacting with the Precolator API.

§Example

use precolator_sdk::PrecolatorClient;

#[tokio::main]
async fn main() -> precolator_sdk::Result<()> {
    let client = PrecolatorClient::new("https://precolator.xyz");
    let markets = client.get_markets().await?;
    Ok(())
}

Implementations§

Source§

impl PrecolatorClient

Source

pub fn new(base_url: &str) -> Self

Create a new client pointing at the given base URL.

let client = precolator_sdk::PrecolatorClient::new("https://precolator.xyz");
Source

pub fn with_client(base_url: &str, http: Client) -> Result<Self>

Create a client with a custom reqwest::Client (e.g. custom timeouts).

Source

pub async fn health(&self) -> Result<HealthStatus>

GET /api/v1/health

Source

pub async fn health_detailed(&self) -> Result<DetailedHealth>

GET /api/v1/health/detailed

Source

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

GET /api/v1/markets – list all markets.

Source

pub async fn get_market(&self, id: &str) -> Result<Market>

GET /api/v1/markets/:id – single market details.

Source

pub async fn get_market_stats(&self, id: &str) -> Result<MarketStats>

GET /api/v1/markets/:id/stats – market statistics.

Source

pub async fn get_trades(&self) -> Result<Vec<Trade>>

GET /api/v1/trades – recent trades across all markets.

Source

pub async fn get_trade(&self, trade_id: &str) -> Result<Trade>

GET /api/v1/trades/:tradeId

Source

pub async fn get_user_trades(&self, wallet: &str) -> Result<Vec<Trade>>

GET /api/v1/trades/user/:wallet

Source

pub async fn get_portfolio(&self, wallet: &str) -> Result<Portfolio>

GET /api/v1/portfolio/:wallet

Source

pub async fn get_portfolio_history( &self, wallet: &str, ) -> Result<PortfolioHistory>

GET /api/v1/portfolio/:wallet/history

Source

pub async fn get_portfolio_stats(&self, wallet: &str) -> Result<PortfolioStats>

GET /api/v1/portfolio/:wallet/stats

Source

pub async fn get_leaderboard(&self) -> Result<Vec<LeaderboardEntry>>

GET /api/v1/leaderboard

Source

pub async fn get_leaderboard_by_timeframe( &self, timeframe: &str, ) -> Result<Vec<LeaderboardEntry>>

GET /api/v1/leaderboard/:timeframe (e.g. 7d, 30d, all)

Source

pub async fn get_tokens(&self) -> Result<Vec<Token>>

GET /api/v1/tokens

Source

pub async fn get_token(&self, symbol: &str) -> Result<Token>

GET /api/v1/tokens/:symbol

Source

pub async fn get_platform_stats(&self) -> Result<PlatformStats>

GET /api/v1/stats – platform-wide statistics.

Source

pub async fn get_market_overview(&self) -> Result<MarketOverview>

GET /api/v1/stats/markets/overview

Source

pub async fn get_exchange_metrics(&self) -> Result<ExchangeMetrics>

GET /api/v1/stats/exchange/metrics

Trait Implementations§

Source§

impl Clone for PrecolatorClient

Source§

fn clone(&self) -> PrecolatorClient

Returns a duplicate 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 PrecolatorClient

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