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 /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 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.
Paginates through GET /positions?user={address}&sizeThreshold=0
until a partial page is returned.
Sourcepub async fn get_trades(
&self,
condition_id: &str,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Vec<DataApiTrade>>
pub async fn get_trades( &self, condition_id: &str, limit: Option<u32>, offset: Option<u32>, ) -> Result<Vec<DataApiTrade>>
Fetches trades from the Data API 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,
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, limit: Option<u32>, ) -> Result<Vec<TradeTick>>
Fetches trades and converts them to [TradeTick] for the given instrument.
Automatically paginates through all available results (up to limit
if specified, with a safety cap of 100 pages). Filters by token_id
(since the API returns trades for all outcomes of the condition) and
returns results in chronological order.
Trait Implementations§
Source§impl Clone for PolymarketDataApiHttpClient
impl Clone for PolymarketDataApiHttpClient
Source§fn clone(&self) -> PolymarketDataApiHttpClient
fn clone(&self) -> PolymarketDataApiHttpClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PolymarketDataApiHttpClient
impl !RefUnwindSafe for PolymarketDataApiHttpClient
impl Send for PolymarketDataApiHttpClient
impl Sync for PolymarketDataApiHttpClient
impl Unpin for PolymarketDataApiHttpClient
impl UnsafeUnpin for PolymarketDataApiHttpClient
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more
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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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