hybrid_server example ships inside the polymarket-client crate as a minimal Axum REST API. It wraps the SDK’s public and secure clients behind four HTTP endpoints, giving any front-end — a Solana app, a browser, a mobile client, or another service — a simple JSON interface to Polymarket’s order book and order placement without that client needing to know anything about Polygon or the CLOB protocol. You can start it in two modes: read-only (no credentials needed) or with live order placement enabled via environment variables.
Running the server
Read-only mode
Use this to browse markets and order books without any private key. No environment variables are required.http://127.0.0.1:8080. All endpoints except POST /v1/orders are fully functional in this mode.
With live order placement
Set your Polygon private key and opt-in flag to unlock thePOST /v1/orders endpoint.
POLYMARKET_PLACE_ORDER=1 is an explicit opt-in so you cannot accidentally place live orders without knowing it.
Endpoints
Example requests
Health check
List markets
Fetch an order book
TOKEN_ID with the outcome token ID from a market returned by /v1/markets.
Place a limit order
The X-Solana-Address header
When your Solana front-end places an order through the hybrid server, include the user’s Solana public key in the X-Solana-Address request header. This lets your backend correlate the Solana identity with the resulting Polygon fill — for example, to update a user’s portfolio view or attribute fees correctly.
Source code
The full annotated implementation is available at:crates/polymarket-client/examples/hybrid_server.rs
