polyoxide
Unified Rust client for Polymarket APIs, re-exporting the CLOB (trading), Gamma (market data), and Data (user positions/trades) crates behind feature flags.
More information about this crate can be found in the crate documentation.
Installation
By default, all three REST API modules are enabled:
Select only what you need:
# Market data only
# Trading only
# User data only
# Everything including WebSocket
Feature flags
| Feature | Default | Description |
|---|---|---|
clob |
yes | CLOB order-book trading via polyoxide-clob |
gamma |
yes | Read-only market data via polyoxide-gamma |
data |
yes | Read-only user positions/trades via polyoxide-data |
ws |
no | WebSocket streaming (implies clob) |
full |
no | Enables clob + gamma + data + ws |
keychain |
no | OS keychain credential storage; off by default |
Usage
Unified client (all three features enabled)
When clob, gamma, and data are all enabled, the Polymarket struct provides a single entry point. It requires an Account for authenticated CLOB operations.
use *;
# async
Using individual crates directly
Each sub-client can be used standalone without the unified Polymarket wrapper.
// Read-only Gamma client (no auth required)
use Gamma;
# async
// Read-only Data API client (no auth required)
use DataApi;
# async
// Public (unauthenticated) CLOB client for read-only market data
use Clob;
# async
WebSocket (requires ws feature)
use *;
use StreamExt;
# async
For long-running connections, WebSocketBuilder provides automatic keep-alive pings:
use *;
use Duration;
# async
Environment variables
Authenticated operations (CLOB trading) require:
| Variable | Description |
|---|---|
POLYMARKET_PRIVATE_KEY |
Hex-encoded private key |
POLYMARKET_API_KEY |
L2 API key |
POLYMARKET_API_SECRET |
L2 API secret (base64) |
POLYMARKET_API_PASSPHRASE |
L2 API passphrase |
Account::from_env() reads all four. Alternatively, use Account::new(private_key, credentials) or Account::from_file(path) for file-based config. With the keychain feature enabled, Account::from_keychain() loads the same credentials from the OS keychain instead of environment variables.
License
Licensed under either of MIT or Apache-2.0 at your option.