pub struct PolymarketClobHttpClient { /* private fields */ }Expand description
Provides an authenticated HTTP client for the Polymarket CLOB REST API.
Handles HTTP transport, L2 HMAC-SHA256 auth signing, pagination, and raw API calls that closely match Polymarket endpoint specifications. Credential is always present: the CLOB API requires authentication.
Implementations§
Source§impl PolymarketClobHttpClient
impl PolymarketClobHttpClient
Sourcepub fn new(
credential: Credential,
address: String,
base_url: Option<String>,
timeout_secs: u64,
) -> StdResult<Self, HttpClientError>
pub fn new( credential: Credential, address: String, base_url: Option<String>, timeout_secs: u64, ) -> StdResult<Self, HttpClientError>
Creates a new authenticated PolymarketClobHttpClient.
§Errors
Returns an error if the HTTP client cannot be created.
Sourcepub async fn get_orders(
&self,
params: GetOrdersParams,
) -> Result<Vec<PolymarketOpenOrder>>
pub async fn get_orders( &self, params: GetOrdersParams, ) -> Result<Vec<PolymarketOpenOrder>>
Fetches all open orders matching the given parameters (auto-paginated).
Sourcepub async fn get_order_optional(
&self,
order_id: &str,
) -> Result<Option<PolymarketOpenOrder>>
pub async fn get_order_optional( &self, order_id: &str, ) -> Result<Option<PolymarketOpenOrder>>
Fetches a single open order by ID, returning None for empty/null responses.
Sourcepub async fn get_order(&self, order_id: &str) -> Result<PolymarketOpenOrder>
pub async fn get_order(&self, order_id: &str) -> Result<PolymarketOpenOrder>
Fetches a single open order by ID.
Returns an error if the order is not found (empty/null response).
Sourcepub async fn get_trades(
&self,
params: GetTradesParams,
) -> Result<Vec<PolymarketTradeReport>>
pub async fn get_trades( &self, params: GetTradesParams, ) -> Result<Vec<PolymarketTradeReport>>
Fetches all trades matching the given parameters (auto-paginated).
Sourcepub async fn get_balance_allowance(
&self,
params: GetBalanceAllowanceParams,
) -> Result<BalanceAllowance>
pub async fn get_balance_allowance( &self, params: GetBalanceAllowanceParams, ) -> Result<BalanceAllowance>
Fetches balance and allowance for the given parameters.
Sourcepub async fn post_order(
&self,
order: &PolymarketOrder,
order_type: PolymarketOrderType,
post_only: bool,
) -> Result<OrderResponse>
pub async fn post_order( &self, order: &PolymarketOrder, order_type: PolymarketOrderType, post_only: bool, ) -> Result<OrderResponse>
Submits a single signed order to the exchange.
Sourcepub async fn post_orders(
&self,
orders: &[(&PolymarketOrder, PolymarketOrderType, bool)],
) -> Result<Vec<OrderResponse>>
pub async fn post_orders( &self, orders: &[(&PolymarketOrder, PolymarketOrderType, bool)], ) -> Result<Vec<OrderResponse>>
Submits a batch of signed orders to the exchange.
Each entry is (order, order_type, post_only).
Sourcepub async fn cancel_order(&self, order_id: &str) -> Result<CancelResponse>
pub async fn cancel_order(&self, order_id: &str) -> Result<CancelResponse>
Cancels a single order by ID.
Sourcepub async fn cancel_orders(
&self,
order_ids: &[&str],
) -> Result<BatchCancelResponse>
pub async fn cancel_orders( &self, order_ids: &[&str], ) -> Result<BatchCancelResponse>
Cancels multiple orders by ID.
Sourcepub async fn cancel_all(&self) -> Result<BatchCancelResponse>
pub async fn cancel_all(&self) -> Result<BatchCancelResponse>
Cancels all open orders.
Sourcepub async fn cancel_market_orders(
&self,
params: CancelMarketOrdersParams,
) -> Result<BatchCancelResponse>
pub async fn cancel_market_orders( &self, params: CancelMarketOrdersParams, ) -> Result<BatchCancelResponse>
Cancels all orders for a specific market.
Sourcepub async fn get_tick_size(&self, token_id: &str) -> Result<TickSizeResponse>
pub async fn get_tick_size(&self, token_id: &str) -> Result<TickSizeResponse>
Fetches the tick size for a token from the CLOB API.
Sourcepub async fn get_fee_rate(&self, token_id: &str) -> Result<FeeRateResponse>
pub async fn get_fee_rate(&self, token_id: &str) -> Result<FeeRateResponse>
Fetches the fee rate (in basis points) for a token from the CLOB API.
Sourcepub async fn get_book(&self, token_id: &str) -> Result<ClobBookResponse>
pub async fn get_book(&self, token_id: &str) -> Result<ClobBookResponse>
Fetches the order book for a token from the CLOB API (public endpoint).
Trait Implementations§
Source§impl Clone for PolymarketClobHttpClient
impl Clone for PolymarketClobHttpClient
Source§fn clone(&self) -> PolymarketClobHttpClient
fn clone(&self) -> PolymarketClobHttpClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PolymarketClobHttpClient
impl !RefUnwindSafe for PolymarketClobHttpClient
impl Send for PolymarketClobHttpClient
impl Sync for PolymarketClobHttpClient
impl Unpin for PolymarketClobHttpClient
impl UnsafeUnpin for PolymarketClobHttpClient
impl !UnwindSafe for PolymarketClobHttpClient
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
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>
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