pub struct PolymarketDataApiHttpClient { /* private fields */ }Expand description
Provides an unauthenticated HTTP client for the Polymarket Data API.
Used for fetching historical trade data from GET /v2/trades.
Implementations§
Source§impl PolymarketDataApiHttpClient
impl PolymarketDataApiHttpClient
Sourcepub fn new(
base_url: Option<String>,
timeout_secs: u64,
) -> StdResult<Self, HttpClientError>
pub fn new( base_url: Option<String>, timeout_secs: u64, ) -> StdResult<Self, HttpClientError>
Creates a new PolymarketDataApiHttpClient.
§Errors
Returns an error if the HTTP client cannot be created.
Sourcepub fn new_with_proxy(
base_url: Option<String>,
timeout_secs: u64,
proxy_url: Option<ProxyUrl>,
) -> StdResult<Self, HttpClientError>
pub fn new_with_proxy( base_url: Option<String>, timeout_secs: u64, proxy_url: Option<ProxyUrl>, ) -> StdResult<Self, HttpClientError>
Creates a new client with an optional validated proxy URL.
§Errors
Returns an error if the HTTP client cannot be created.
Sourcepub async fn get_positions(
&self,
user_address: &str,
) -> Result<Vec<DataApiPosition>>
pub async fn get_positions( &self, user_address: &str, ) -> Result<Vec<DataApiPosition>>
Fetches all positions for a user from the Data API v2.
Walks GET /v2/positions?user={address} by cursor until the venue
reports no further pages. A short page never ends the walk; only a
null next_cursor does.
Sourcepub async fn get_trades(
&self,
condition_id: &str,
limit: Option<u32>,
) -> Result<Vec<DataApiTrade>>
pub async fn get_trades( &self, condition_id: &str, limit: Option<u32>, ) -> Result<Vec<DataApiTrade>>
Fetches a single page of trades from the Data API v2 for the given condition ID.
Sourcepub async fn request_trade_ticks(
&self,
instrument_id: InstrumentId,
condition_id: &str,
token_id: &str,
price_precision: u8,
size_precision: u8,
start: Option<UnixNanos>,
end: Option<UnixNanos>,
limit: Option<u32>,
) -> Result<Vec<TradeTick>>
pub async fn request_trade_ticks( &self, instrument_id: InstrumentId, condition_id: &str, token_id: &str, price_precision: u8, size_precision: u8, start: Option<UnixNanos>, end: Option<UnixNanos>, limit: Option<u32>, ) -> Result<Vec<TradeTick>>
Fetches trades and converts them to [TradeTick] for the given instrument.
Automatically walks all pages by cursor (up to limit if specified).
Filters by token_id (since the API returns trades for all outcomes of
the condition) and returns results in chronological order.
The v2 condition feed serves a fixed three-year window and ignores
start/end bounds, so window filtering happens locally and the walk
stops as soon as an entire page precedes start (the feed is served
newest-first).
Trait Implementations§
Source§impl Clone for PolymarketDataApiHttpClient
impl Clone for PolymarketDataApiHttpClient
Auto Trait Implementations§
impl !RefUnwindSafe for PolymarketDataApiHttpClient
impl !UnwindSafe for PolymarketDataApiHttpClient
impl Freeze for PolymarketDataApiHttpClient
impl Send for PolymarketDataApiHttpClient
impl Sync for PolymarketDataApiHttpClient
impl Unpin for PolymarketDataApiHttpClient
impl UnsafeUnpin for PolymarketDataApiHttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more