Expand description
Unified Polymarket Rust SDK.
Modeled after the official TypeScript SDK (@polymarket/client).
§Clients
PublicClient— read-only discovery, market data, and (withaccount) portfolio reads- [
SecureClient] — authenticated trading, notifications, rewards, CTF wallet ops, and user websockets
§Feature flags
| Feature | Enables |
|---|---|
| (default) | HTTP discovery + CLOB market data |
account | Data API reads on PublicClient |
websockets | Realtime subscribe() on PublicClient |
secure | account + websockets + [SecureClient] trading and wallet ops |
§Quickstart
use polymarket_client::{Environment, PublicClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = PublicClient::new(Environment::production());
let mut paginator = client.list_markets(polymarket_client::ListMarketsRequest {
closed: Some(false),
page_size: Some(5),
..Default::default()
})?;
let page = paginator.first_page().await?;
for market in &page.items {
println!("{}: {}", market.id, market.question.as_deref().unwrap_or(""));
}
Ok(())
}§Realtime (websockets)
use futures::StreamExt as _;
use polymarket_client::{Environment, MarketSubscription, PublicClient, SubscriptionSpec};
let client = PublicClient::new(Environment::production());
let mut handle = client.subscribe(vec![SubscriptionSpec::Market(MarketSubscription {
token_ids: vec!["123".into()],
custom_feature_enabled: false,
})])?;
if let Some(Ok(event)) = handle.next().await {
println!("{event:?}");
}
handle.close();Structs§
- CtfCondition
Id - CTF condition identifier (bytes32 hex).
- Decimal
String - Environment
- Production and preproduction environment configuration.
- Event
- Normalized Polymarket event.
- EventId
- EvmAddress
- An EVM account or contract address.
- Fetch
Midpoint Request - Fetch
Order Book Request - List
Events Request - List
Markets Request - Market
- Market
Id - Order
Book - Order
Book Level - Page
- Pagination
Cursor - Paginator
- Public
Client - Read-only Polymarket client for discovery and market data.
- Public
Client Builder - Builder for
PublicClient. - Rate
Limit Error - Request
Rejected Error - TokenId
- Transport
Error - Unexpected
Response Error - User
Input Error
Enums§
- Error
- Top-level SDK error.
- Fetch
Market Error - Fetch
Market Request - Fetch
Midpoint Error - Fetch
Order Book Error - List
Events Error - List
Markets Error - Order
Side - Order
Type