Skip to main content

fetch_trades

Public market trade tape.
async fn fetch_trades(
    req: TradesRequest,
) -> Result<(Vec<MarketTrade>, Option<String>), OpenPxError>
TradesRequest
FieldTypeDescription
market_idstringNative market ID
market_refstring?Alternate ID (e.g. Polymarket conditionId) — preferred when present
outcomestring?Filter by outcome label
token_idstring?Filter by CLOB token (Polymarket)
start_tsi64?Inclusive lower bound (Unix seconds)
end_tsi64?Inclusive upper bound (Unix seconds)
limitusize?Max trades, exchange-capped
cursorstring?From a prior response

fetch_price_history

OHLCV candles.
async fn fetch_price_history(
    req: PriceHistoryRequest,
) -> Result<Vec<Candlestick>, OpenPxError>
PriceHistoryRequest
FieldTypeDescription
market_idstringNative market ID
outcomestring?Outcome label (Kalshi infers Yes/No from market)
token_idstring?Polymarket CLOB token
condition_idstring?Polymarket condition ID for OI enrichment
intervalPriceHistoryInterval1m, 1h, 6h, 1d, 1w, max
start_tsi64?Unix seconds
end_tsi64?Unix seconds
Candlestick: { timestamp, open, high, low, close, volume, open_interest? }. Open interest is currently provided only by Kalshi.
candles = ex.fetch_price_history(
    "KXBTC-25MAR14-T20000",
    "1h",
    start_ts=1735689600,
)

fetch_fills

Your own executed fills.
async fn fetch_fills(
    market_id: Option<&str>,
    limit: Option<usize>,
) -> Result<Vec<Fill>, OpenPxError>
Fill: { fill_id, order_id, market_id, outcome, side, price, size, is_taker, fee, created_at }.

fetch_user_activity

Polymarket-only activity feed (positions, trades, portfolio data).
async fn fetch_user_activity(
    params: FetchUserActivityParams,
) -> Result<serde_json::Value, OpenPxError>
FetchUserActivityParams { address: String, limit: Option<usize> }. Returns unparsed JSON from Polymarket’s activity API.

fetch_orderbook_history

Historical L2 orderbook snapshots — Polymarket only.
async fn fetch_orderbook_history(
    req: OrderbookHistoryRequest,
) -> Result<(Vec<OrderbookSnapshot>, Option<String>), OpenPxError>
OrderbookHistoryRequest
FieldType
market_idstring
token_idstring?
start_tsi64?
end_tsi64?
limitusize?
cursorstring?
OrderbookSnapshot: { timestamp, recorded_at?, hash?, bids, asks }.