Polysqueeze
Polysqueeze is a Rust SDK for interacting with Polymarket's REST APIs; the markets,
orders, and authentication helpers are implemented today, while the ws::
WebSocket helpers are still a TODO. If you hit a 401 or other auth pain point, raise
an issue and the implementation is guaranteed to keep evolving.
Highlights
- Fully working REST helpers for the Gamma and CLOB APIs (markets, fills, single orders, authentication, helper types).
- Order creation flows have live regression coverage for the single-order path; batch/multi-order flows still need more testing and contributions are welcome.
- Gamma data types for markets, tokens, order books, rewards, etc.
- Configuration helpers for Polygon mainnet + testnet (testing has only been done on mainnet), plus shared utils for signing, math, and fills.
Quickstart
-
Add
polysqueezeto yourCargo.tomland enabletokioin your runtime. -
Create a client, derive API keys, and post a sample order. This is the one path that currently runs against the live API (single-order placement); batch order flows and broader WebSocket handling still need more testing and are open for contributions.
use ;
use Decimal;
async
- Explore
ws::WebSocketStream(WIP TODO) for real-time updates, or usebook::OrderBookCachefor a cached view of the order book.
Example
The smoke-testing logic from tests/place_order.rs is also available as
examples/order.rs. To run it locally:
It expects the same environment variables as the test (private key, API creds,
network, etc.) and drops a microscopic order when RUN_PLACE_ORDER_TEST=1 is set.
Copy .env.example to .env and fill in your wallet key plus any overrides
(POLY_CHAIN_ID, POLY_API_URL, POLY_FUNDER, POLY_TEST_TOKEN). Only the
private key is strictly required; the rest are optional fallbacks.
Gamma and Data APIs
Use the client module to call Gamma endpoints such as /markets, /events,
/tags, and NegRisk data. Only the Gamma markets and single-order creation
paths have live regression coverage today; feel free to extend coverage to more
endpoints or submit fixes. The types module contains strongly typed responses
such as Market, MarketOrderArgs, and OrderBookSummary.
Testing
Test order placement with this command (make sure env variables are set). This exercise is what we currently rely on as basic coverage for the order APIs:
# WARNING: this test placese a tiny order on Polymarket ~0.006 USDC
RUN_PLACE_ORDER_TEST=1
Formatting and Lints
cargo fmt
cargo clippy
Contributing
Contributions are welcome! Look for any open issue in the Issues page, or open a pull request after forking the project.