Skip to main content

PolyNodeClient

Struct PolyNodeClient 

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

Main PolyNode client.

Implementations§

Source§

impl PolyNodeClient

Source

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

Create a client with defaults.

Source

pub fn builder(api_key: impl Into<String>) -> ClientBuilder

Create a builder for full configuration.

Source

pub async fn healthz(&self) -> Result<String>

Liveness probe. No auth required.

Source

pub async fn readyz(&self) -> Result<Value>

Readiness check. No auth required.

Source

pub async fn status(&self) -> Result<StatusResponse>

System status with metrics.

Source

pub async fn create_key(&self, name: Option<&str>) -> Result<ApiKeyResponse>

Generate a new API key. No auth required.

Source

pub async fn markets(&self, count: Option<u64>) -> Result<MarketsResponse>

Top markets sorted by 24h volume.

Source

pub async fn market(&self, token_id: &str) -> Result<Value>

Market detail by token ID.

Source

pub async fn market_by_slug(&self, slug: &str) -> Result<Value>

Market detail by URL slug.

Source

pub async fn market_by_condition(&self, condition_id: &str) -> Result<Value>

Market detail by condition ID.

Source

pub async fn list_markets( &self, params: &ListMarketsParams, ) -> Result<MarketsListResponse>

Filtered, paginated market listing.

Source

pub async fn search( &self, query: &str, limit: Option<u64>, include_inactive: Option<bool>, ) -> Result<SearchResponse>

Full-text search across market questions.

Source

pub async fn candles( &self, token_id: &str, resolution: Option<CandleResolution>, limit: Option<u64>, ) -> Result<CandlesResponse>

OHLCV candles for a token.

Source

pub async fn stats(&self, token_id: &str) -> Result<Value>

Market statistics.

Source

pub async fn recent_settlements( &self, count: Option<u64>, ) -> Result<SettlementsResponse>

Most recent decoded settlements.

Source

pub async fn token_settlements( &self, token_id: &str, count: Option<u64>, ) -> Result<SettlementsResponse>

Settlements for a specific token ID.

Source

pub async fn wallet_settlements( &self, address: &str, count: Option<u64>, ) -> Result<SettlementsResponse>

Settlements for a specific wallet address.

Source

pub async fn wallet(&self, address: &str) -> Result<Value>

Wallet activity summary.

Source

pub async fn wallet_positions_data( &self, address: &str, limit: Option<u64>, offset: Option<u64>, ) -> Result<WalletPositionsResponse>

Positions for a wallet (proxied from Polymarket data-api). Returns full P&L, current values.

Source

pub async fn wallet_onchain_positions( &self, address: &str, ) -> Result<WalletOnchainPositionsResponse>

Onchain positions from the PNL subgraph. Returns ALL positions (open + closed) with accurate realized P&L.

Source

pub async fn wallet_trades( &self, address: &str, limit: Option<u64>, offset: Option<u64>, ) -> Result<WalletTradesResponse>

Trades for a wallet. Used by the cache for backfill.

Source

pub async fn market_trades( &self, id: &str, limit: Option<u64>, offset: Option<u64>, side: Option<&str>, user: Option<&str>, ) -> Result<MarketTradesResponse>

Trades for a market (by condition ID or slug).

Source

pub async fn orderbook_rest( &self, token_id: &str, ) -> Result<OrderbookRestResponse>

Full orderbook snapshot from the CLOB.

Source

pub async fn midpoint(&self, token_id: &str) -> Result<MidpointResponse>

Midpoint price for a token.

Source

pub async fn spread(&self, token_id: &str) -> Result<SpreadResponse>

Bid-ask spread for a token.

Source

pub async fn leaderboard( &self, period: Option<&str>, sort: Option<&str>, ) -> Result<LeaderboardResponse>

Top traders leaderboard.

Source

pub async fn trending(&self) -> Result<TrendingResponse>

Trending markets (carousel, breaking, hot topics, featured, movers).

Source

pub async fn activity(&self) -> Result<ActivityResponse>

Recent global trading activity.

Source

pub async fn movers(&self) -> Result<MoversResponse>

Markets with largest 24h price moves.

Source

pub async fn trader_profile(&self, wallet: &str) -> Result<TraderProfile>

Trader profile with stats.

Source

pub async fn trader_pnl( &self, wallet: &str, period: Option<&str>, ) -> Result<TraderPnlResponse>

Trader P&L time series.

Source

pub async fn event(&self, slug: &str) -> Result<EventDetailResponse>

Event detail by slug (includes all markets within the event).

Source

pub async fn search_events( &self, query: &str, limit: Option<u64>, ) -> Result<EventSearchResponse>

Search events by query string.

Source

pub async fn markets_by_category( &self, category: &str, ) -> Result<MarketsListResponse>

Markets filtered by category. Delegates to /v1/markets/list with a category filter.

Source

pub async fn rpc_call(&self, method: &str, params: Value) -> Result<Value>

Send a JSON-RPC request through the PolyNode RPC endpoint (rpc.polynode.dev).

Source

pub async fn stream(&self, options: StreamOptions) -> Result<WsStream>

Open a WebSocket connection, returning a stream of messages.

Source

pub fn short_form(&self, interval: ShortFormInterval) -> ShortFormBuilder<'_>

Subscribe to short-form crypto markets (5m, 15m, 1h) with auto-rotation.

Returns a builder to configure coins and options before starting.

§Example
let mut stream = client
    .short_form(polynode::ShortFormInterval::FifteenMin)
    .coins(&[polynode::Coin::Btc, polynode::Coin::Eth])
    .start()
    .await?;
Source

pub async fn orderbook_stream( &self, options: ObStreamOptions, ) -> Result<ObStream>

Open an orderbook WebSocket stream from ob.polynode.dev.

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> 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> Same for T

Source§

type Output = T

Should always be Self
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