pub struct PolyNodeClient { /* private fields */ }Expand description
Main PolyNode client.
Implementations§
Source§impl PolyNodeClient
impl PolyNodeClient
Sourcepub fn builder(api_key: impl Into<String>) -> ClientBuilder
pub fn builder(api_key: impl Into<String>) -> ClientBuilder
Create a builder for full configuration.
Sourcepub async fn status(&self) -> Result<StatusResponse>
pub async fn status(&self) -> Result<StatusResponse>
System status with metrics.
Sourcepub async fn create_key(&self, name: Option<&str>) -> Result<ApiKeyResponse>
pub async fn create_key(&self, name: Option<&str>) -> Result<ApiKeyResponse>
Generate a new API key. No auth required.
Sourcepub async fn markets(&self, count: Option<u64>) -> Result<MarketsResponse>
pub async fn markets(&self, count: Option<u64>) -> Result<MarketsResponse>
Top markets sorted by 24h volume.
Sourcepub async fn market_by_slug(&self, slug: &str) -> Result<Value>
pub async fn market_by_slug(&self, slug: &str) -> Result<Value>
Market detail by URL slug.
Sourcepub async fn market_by_condition(&self, condition_id: &str) -> Result<Value>
pub async fn market_by_condition(&self, condition_id: &str) -> Result<Value>
Market detail by condition ID.
Sourcepub async fn list_markets(
&self,
params: &ListMarketsParams,
) -> Result<MarketsListResponse>
pub async fn list_markets( &self, params: &ListMarketsParams, ) -> Result<MarketsListResponse>
Filtered, paginated market listing.
Sourcepub async fn search(
&self,
query: &str,
limit: Option<u64>,
include_inactive: Option<bool>,
) -> Result<SearchResponse>
pub async fn search( &self, query: &str, limit: Option<u64>, include_inactive: Option<bool>, ) -> Result<SearchResponse>
Full-text search across market questions.
Sourcepub async fn candles(
&self,
token_id: &str,
resolution: Option<CandleResolution>,
limit: Option<u64>,
) -> Result<CandlesResponse>
pub async fn candles( &self, token_id: &str, resolution: Option<CandleResolution>, limit: Option<u64>, ) -> Result<CandlesResponse>
OHLCV candles for a token.
Sourcepub async fn recent_settlements(
&self,
count: Option<u64>,
) -> Result<SettlementsResponse>
pub async fn recent_settlements( &self, count: Option<u64>, ) -> Result<SettlementsResponse>
Most recent decoded settlements.
Sourcepub async fn token_settlements(
&self,
token_id: &str,
count: Option<u64>,
) -> Result<SettlementsResponse>
pub async fn token_settlements( &self, token_id: &str, count: Option<u64>, ) -> Result<SettlementsResponse>
Settlements for a specific token ID.
Sourcepub async fn wallet_settlements(
&self,
address: &str,
count: Option<u64>,
) -> Result<SettlementsResponse>
pub async fn wallet_settlements( &self, address: &str, count: Option<u64>, ) -> Result<SettlementsResponse>
Settlements for a specific wallet address.
Sourcepub async fn wallet_positions_data(
&self,
address: &str,
limit: Option<u64>,
offset: Option<u64>,
) -> Result<WalletPositionsResponse>
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.
Sourcepub async fn wallet_onchain_positions(
&self,
address: &str,
) -> Result<WalletOnchainPositionsResponse>
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.
Sourcepub async fn wallet_trades(
&self,
address: &str,
limit: Option<u64>,
offset: Option<u64>,
) -> Result<WalletTradesResponse>
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.
Sourcepub async fn market_trades(
&self,
id: &str,
limit: Option<u64>,
offset: Option<u64>,
side: Option<&str>,
user: Option<&str>,
) -> Result<MarketTradesResponse>
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).
Sourcepub async fn orderbook_rest(
&self,
token_id: &str,
) -> Result<OrderbookRestResponse>
pub async fn orderbook_rest( &self, token_id: &str, ) -> Result<OrderbookRestResponse>
Full orderbook snapshot from the CLOB.
Sourcepub async fn midpoint(&self, token_id: &str) -> Result<MidpointResponse>
pub async fn midpoint(&self, token_id: &str) -> Result<MidpointResponse>
Midpoint price for a token.
Sourcepub async fn spread(&self, token_id: &str) -> Result<SpreadResponse>
pub async fn spread(&self, token_id: &str) -> Result<SpreadResponse>
Bid-ask spread for a token.
Sourcepub async fn leaderboard(
&self,
period: Option<&str>,
sort: Option<&str>,
) -> Result<LeaderboardResponse>
pub async fn leaderboard( &self, period: Option<&str>, sort: Option<&str>, ) -> Result<LeaderboardResponse>
Top traders leaderboard.
Sourcepub async fn trending(&self) -> Result<TrendingResponse>
pub async fn trending(&self) -> Result<TrendingResponse>
Trending markets (carousel, breaking, hot topics, featured, movers).
Sourcepub async fn activity(&self) -> Result<ActivityResponse>
pub async fn activity(&self) -> Result<ActivityResponse>
Recent global trading activity.
Sourcepub async fn movers(&self) -> Result<MoversResponse>
pub async fn movers(&self) -> Result<MoversResponse>
Markets with largest 24h price moves.
Sourcepub async fn trader_profile(&self, wallet: &str) -> Result<TraderProfile>
pub async fn trader_profile(&self, wallet: &str) -> Result<TraderProfile>
Trader profile with stats.
Sourcepub async fn trader_pnl(
&self,
wallet: &str,
period: Option<&str>,
) -> Result<TraderPnlResponse>
pub async fn trader_pnl( &self, wallet: &str, period: Option<&str>, ) -> Result<TraderPnlResponse>
Trader P&L time series.
Sourcepub async fn event(&self, slug: &str) -> Result<EventDetailResponse>
pub async fn event(&self, slug: &str) -> Result<EventDetailResponse>
Event detail by slug (includes all markets within the event).
Sourcepub async fn search_events(
&self,
query: &str,
limit: Option<u64>,
) -> Result<EventSearchResponse>
pub async fn search_events( &self, query: &str, limit: Option<u64>, ) -> Result<EventSearchResponse>
Search events by query string.
Sourcepub async fn markets_by_category(
&self,
category: &str,
) -> Result<MarketsListResponse>
pub async fn markets_by_category( &self, category: &str, ) -> Result<MarketsListResponse>
Markets filtered by category. Delegates to /v1/markets/list with a category filter.
Sourcepub async fn rpc_call(&self, method: &str, params: Value) -> Result<Value>
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).
Sourcepub async fn stream(&self, options: StreamOptions) -> Result<WsStream>
pub async fn stream(&self, options: StreamOptions) -> Result<WsStream>
Open a WebSocket connection, returning a stream of messages.
Sourcepub fn short_form(&self, interval: ShortFormInterval) -> ShortFormBuilder<'_>
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?;Sourcepub async fn orderbook_stream(
&self,
options: ObStreamOptions,
) -> Result<ObStream>
pub async fn orderbook_stream( &self, options: ObStreamOptions, ) -> Result<ObStream>
Open an orderbook WebSocket stream from ob.polynode.dev.