Update Polymarket documentation - March 30, 2026
Updated 229 documentation pages reflecting latest official docs changes: - API Reference: authentication, rate-limits, clients-sdks, market-data endpoints - Developers: CLOB, Gamma Markets, RTDS, Sports Websocket, Builders, CTF - Trading: fees, bridge, orders, orderbook, clients - Polymarket Learn: get-started guides, deposits, trading - Builders: tiers, api-keys, profile, examples, order-attribution - Quickstart: overview, first-order, websocket guides - Concepts: markets-events, prices-orderbook, resolution - Market Makers: getting-started, trading, liquidity-rewards - Resources: error-codes, contract-addresses, blockchain-data
This commit is contained in:
@@ -26,7 +26,7 @@ The CLOB API uses two levels of authentication: **L1 (Private Key)** and **L2 (A
|
||||
|
||||
The CLOB uses two levels of authentication: L1 (Private Key) and L2 (API Key). Either can be accomplished using the CLOB client or REST API
|
||||
|
||||
### L1 Authentication (Private Key)
|
||||
### L1 Authentication
|
||||
|
||||
L1 authentication uses the wallet's private key to sign an EIP-712 message used in the request header. It proves ownership and control over the private key. The private key stays in control of the user and all trading activity remains non-custodial.
|
||||
|
||||
@@ -36,7 +36,7 @@ L1 authentication uses the wallet's private key to sign an EIP-712 message used
|
||||
* Deriving existing API credentials
|
||||
* Signing and creating user's orders locally
|
||||
|
||||
### L2 Authentication (API Credentials)
|
||||
### L2 Authentication
|
||||
|
||||
L2 uses API credentials (apiKey, secret, passphrase) generated from L1 authentication. These are used solely to authenticate requests made to the CLOB API. Requests are signed using HMAC-SHA256.
|
||||
|
||||
@@ -57,7 +57,7 @@ L2 uses API credentials (apiKey, secret, passphrase) generated from L1 authentic
|
||||
|
||||
Before making authenticated requests, you need to obtain API credentials using L1 authentication.
|
||||
|
||||
### Using the SDK (Recommended)
|
||||
### Using the SDK
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
@@ -105,6 +105,29 @@ Before making authenticated requests, you need to obtain API credentials using L
|
||||
# }
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Rust">
|
||||
```rust theme={null}
|
||||
use std::str::FromStr;
|
||||
use polymarket_client_sdk::POLYGON;
|
||||
use polymarket_client_sdk::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
.with_chain_id(Some(POLYGON));
|
||||
|
||||
// Creates new credentials or derives existing ones,
|
||||
// then initializes the authenticated client — all in one step
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.authenticate()
|
||||
.await?;
|
||||
|
||||
let credentials = client.credentials();
|
||||
println!("API Key: {}", credentials.key());
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Warning>
|
||||
@@ -228,7 +251,7 @@ All trading endpoints require these 5 headers:
|
||||
|
||||
The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's API credentials `secret` value. Reference implementations can be found in the [TypeScript](https://github.com/Polymarket/clob-client/blob/main/src/signing/hmac.ts) and [Python](https://github.com/Polymarket/py-clob-client/blob/main/py_clob_client/signing/hmac.py) clients.
|
||||
|
||||
### CLOB Client (L2)
|
||||
### CLOB Client
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
@@ -274,6 +297,30 @@ The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's
|
||||
)
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Rust">
|
||||
```rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::{Side, SignatureType};
|
||||
use polymarket_client_sdk::types::dec;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.signature_type(SignatureType::Proxy) // signatureType explained below
|
||||
// Funder auto-derived via CREATE2 for Proxy/GnosisSafe
|
||||
.authenticate()
|
||||
.await?;
|
||||
|
||||
// Now you can trade!
|
||||
let order = client.limit_order()
|
||||
.token_id("123456".parse()?)
|
||||
.price(dec!(0.65))
|
||||
.size(dec!(100))
|
||||
.side(Side::Buy)
|
||||
.build().await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Info>
|
||||
@@ -324,7 +371,7 @@ When initializing the L2 client, you must specify your wallet **signatureType**
|
||||
## Troubleshooting
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Error: INVALID_SIGNATURE">
|
||||
<Accordion title="Error - INVALID_SIGNATURE">
|
||||
Your wallet's private key is incorrect or improperly formatted.
|
||||
|
||||
**Solutions:**
|
||||
@@ -334,7 +381,7 @@ When initializing the L2 client, you must specify your wallet **signatureType**
|
||||
* Check that the key has proper permissions
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Error: NONCE_ALREADY_USED">
|
||||
<Accordion title="Error - NONCE_ALREADY_USED">
|
||||
The nonce you provided has already been used to create an API key.
|
||||
|
||||
**Solutions:**
|
||||
@@ -343,7 +390,7 @@ When initializing the L2 client, you must specify your wallet **signatureType**
|
||||
* Or use a different nonce with `createApiKey()`
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Error: Invalid Funder Address">
|
||||
<Accordion title="Error - Invalid Funder Address">
|
||||
Your funder address is incorrect or doesn't match your wallet.
|
||||
|
||||
**Solution:** Check your Polymarket profile address at [polymarket.com/settings](https://polymarket.com/settings).
|
||||
@@ -375,3 +422,6 @@ When initializing the L2 client, you must specify your wallet **signatureType**
|
||||
Check trading availability by region.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
# Builder Methods
|
||||
|
||||
> These methods require builder API credentials and are only relevant for Builders Program order attribution.
|
||||
> Methods for querying orders and trades using builder API credentials.
|
||||
|
||||
## Client Initialization
|
||||
|
||||
@@ -122,7 +122,70 @@ Builder methods require the client to initialize with a separate builder config
|
||||
|
||||
***
|
||||
|
||||
### getBuilderTrades()
|
||||
### getOrder
|
||||
|
||||
Get details for a specific order by ID using builder authentication. When called from a builder-configured client, the request authenticates with builder headers and returns orders attributed to the builder.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOrder(orderID: string): Promise<OpenOrder>
|
||||
```
|
||||
|
||||
<Info>
|
||||
When a `BuilderConfig` is present, the client automatically sends builder headers. If builder auth is unavailable, it falls back to standard L2 headers.
|
||||
</Info>
|
||||
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
const order = await clobClient.getOrder("0xb816482a...");
|
||||
console.log(order);
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
order = clob_client.get_order("0xb816482a...")
|
||||
print(order)
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
|
||||
### getOpenOrders
|
||||
|
||||
Get all open orders attributed to the builder. When called from a builder-configured client, returns orders placed through the builder rather than orders owned by the authenticated user.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOpenOrders(
|
||||
params?: OpenOrderParams,
|
||||
only_first_page?: boolean,
|
||||
): Promise<OpenOrder[]>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
Optional. Filter by order ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
Optional. Filter by market condition ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
Optional. Filter by token ID.
|
||||
</ResponseField>
|
||||
|
||||
```typescript TypeScript theme={null}
|
||||
// All open orders for this builder
|
||||
const orders = await clobClient.getOpenOrders();
|
||||
|
||||
// Filtered by market
|
||||
const marketOrders = await clobClient.getOpenOrders({
|
||||
market: "0xbd31dc8a...",
|
||||
});
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### getBuilderTrades
|
||||
|
||||
Retrieves all trades attributed to your builder account. Use this to track which trades were routed through your platform.
|
||||
|
||||
@@ -272,7 +335,7 @@ async getBuilderTrades(
|
||||
|
||||
***
|
||||
|
||||
### revokeBuilderApiKey()
|
||||
### revokeBuilderApiKey
|
||||
|
||||
Revokes the builder API key used to authenticate the current request. After revocation, the key can no longer be used for builder-authenticated requests.
|
||||
|
||||
@@ -305,3 +368,6 @@ async revokeBuilderApiKey(): Promise<any>
|
||||
Execute onchain operations without paying gas.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -58,7 +58,7 @@ L1 methods require the client to initialize with a signer.
|
||||
|
||||
***
|
||||
|
||||
### createApiKey()
|
||||
### createApiKey
|
||||
|
||||
Creates a new API key (L2 credentials) for the wallet signer. Each wallet can only have one active API key at a time — creating a new key invalidates the previous one.
|
||||
|
||||
@@ -84,7 +84,7 @@ async createApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
|
||||
***
|
||||
|
||||
### deriveApiKey()
|
||||
### deriveApiKey
|
||||
|
||||
Derives an existing API key using a specific nonce. If you've already created credentials with a particular nonce, this returns the same credentials.
|
||||
|
||||
@@ -110,7 +110,7 @@ async deriveApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
|
||||
***
|
||||
|
||||
### createOrDeriveApiKey()
|
||||
### createOrDeriveApiKey
|
||||
|
||||
Convenience method that attempts to derive an API key with the default nonce, or creates a new one if it doesn't exist. **Recommended for initial setup.**
|
||||
|
||||
@@ -134,7 +134,7 @@ async createOrDeriveApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
|
||||
## Order Signing
|
||||
|
||||
### createOrder()
|
||||
### createOrder
|
||||
|
||||
Create and sign a limit order locally without posting it to the CLOB. Use this when you want to sign orders in advance or implement custom submission logic. Submit via [`postOrder()`](/trading/clients/l2#postorder) or [`postOrders()`](/trading/clients/l2#postorders).
|
||||
|
||||
@@ -239,7 +239,7 @@ async createOrder(
|
||||
|
||||
***
|
||||
|
||||
### createMarketOrder()
|
||||
### createMarketOrder
|
||||
|
||||
Create and sign a market order locally without posting it to the CLOB. Submit via [`postOrder()`](/trading/clients/l2#postorder) or [`postOrders()`](/trading/clients/l2#postorders).
|
||||
|
||||
@@ -339,7 +339,7 @@ async createMarketOrder(
|
||||
## Troubleshooting
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Error: INVALID_SIGNATURE">
|
||||
<Accordion title="Error - INVALID_SIGNATURE">
|
||||
Your wallet's private key is incorrect or improperly formatted.
|
||||
|
||||
**Solution:**
|
||||
@@ -349,7 +349,7 @@ async createMarketOrder(
|
||||
* Check that the key has proper permissions
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Error: NONCE_ALREADY_USED">
|
||||
<Accordion title="Error - NONCE_ALREADY_USED">
|
||||
The nonce you provided has already been used to create an API key.
|
||||
|
||||
**Solution:**
|
||||
@@ -358,7 +358,7 @@ async createMarketOrder(
|
||||
* Or use a different nonce with `createApiKey()`
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Error: Invalid Funder Address">
|
||||
<Accordion title="Error - Invalid Funder Address">
|
||||
Your funder address is incorrect or doesn't match your wallet.
|
||||
|
||||
**Solution:** Check your proxy wallet address at [polymarket.com/settings](https://polymarket.com/settings). If it doesn't exist, the user has never logged in to Polymarket.com — deploy the proxy wallet first before creating L2 credentials.
|
||||
@@ -403,3 +403,6 @@ async createMarketOrder(
|
||||
Place and manage orders with API credentials.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -71,7 +71,7 @@ L2 methods require the client to initialize with a signer, signature type, API c
|
||||
|
||||
***
|
||||
|
||||
### createAndPostOrder()
|
||||
### createAndPostOrder
|
||||
|
||||
Convenience method that creates, signs, and posts a limit order in a single call. Use when you want to buy or sell at a specific price.
|
||||
|
||||
@@ -157,7 +157,7 @@ async createAndPostOrder(
|
||||
|
||||
***
|
||||
|
||||
### createAndPostMarketOrder()
|
||||
### createAndPostMarketOrder
|
||||
|
||||
Convenience method that creates, signs, and posts a market order in a single call. Use when you want to buy or sell at the current market price.
|
||||
|
||||
@@ -235,7 +235,7 @@ async createAndPostMarketOrder(
|
||||
|
||||
***
|
||||
|
||||
### postOrder()
|
||||
### postOrder
|
||||
|
||||
Posts a pre-signed order to the CLOB. Use with [`createOrder()`](/trading/clients/l1#createorder) or [`createMarketOrder()`](/trading/clients/l1#createmarketorder) from L1 methods.
|
||||
|
||||
@@ -249,7 +249,7 @@ async postOrder(
|
||||
|
||||
***
|
||||
|
||||
### postOrders()
|
||||
### postOrders
|
||||
|
||||
Posts up to 15 pre-signed orders in a single batch.
|
||||
|
||||
@@ -275,7 +275,7 @@ async postOrders(
|
||||
|
||||
***
|
||||
|
||||
### cancelOrder()
|
||||
### cancelOrder
|
||||
|
||||
Cancels a single open order.
|
||||
|
||||
@@ -295,7 +295,7 @@ async cancelOrder(orderID: string): Promise<CancelOrdersResponse>
|
||||
|
||||
***
|
||||
|
||||
### cancelOrders()
|
||||
### cancelOrders
|
||||
|
||||
Cancels multiple orders in a single batch.
|
||||
|
||||
@@ -305,7 +305,7 @@ async cancelOrders(orderIDs: string[]): Promise<CancelOrdersResponse>
|
||||
|
||||
***
|
||||
|
||||
### cancelAll()
|
||||
### cancelAll
|
||||
|
||||
Cancels all open orders.
|
||||
|
||||
@@ -315,7 +315,7 @@ async cancelAll(): Promise<CancelOrdersResponse>
|
||||
|
||||
***
|
||||
|
||||
### cancelMarketOrders()
|
||||
### cancelMarketOrders
|
||||
|
||||
Cancels all open orders for a specific market.
|
||||
|
||||
@@ -341,7 +341,7 @@ async cancelMarketOrders(
|
||||
|
||||
***
|
||||
|
||||
### getOrder()
|
||||
### getOrder
|
||||
|
||||
Get details for a specific order by ID.
|
||||
|
||||
@@ -413,7 +413,7 @@ async getOrder(orderID: string): Promise<OpenOrder>
|
||||
|
||||
***
|
||||
|
||||
### getOpenOrders()
|
||||
### getOpenOrders
|
||||
|
||||
Get all your open orders.
|
||||
|
||||
@@ -440,7 +440,7 @@ async getOpenOrders(
|
||||
|
||||
***
|
||||
|
||||
### getTrades()
|
||||
### getTrades
|
||||
|
||||
Get your trade history (filled orders).
|
||||
|
||||
@@ -589,7 +589,7 @@ async getTrades(
|
||||
|
||||
***
|
||||
|
||||
### getTradesPaginated()
|
||||
### getTradesPaginated
|
||||
|
||||
Get trade history with pagination for large result sets.
|
||||
|
||||
@@ -619,7 +619,7 @@ async getTradesPaginated(
|
||||
|
||||
***
|
||||
|
||||
### getBalanceAllowance()
|
||||
### getBalanceAllowance
|
||||
|
||||
Get your balance and allowance for specific tokens.
|
||||
|
||||
@@ -651,7 +651,7 @@ async getBalanceAllowance(
|
||||
|
||||
***
|
||||
|
||||
### updateBalanceAllowance()
|
||||
### updateBalanceAllowance
|
||||
|
||||
Updates the cached balance and allowance for specific tokens.
|
||||
|
||||
@@ -667,7 +667,7 @@ async updateBalanceAllowance(
|
||||
|
||||
***
|
||||
|
||||
### getApiKeys()
|
||||
### getApiKeys
|
||||
|
||||
Get all API keys associated with your account.
|
||||
|
||||
@@ -683,7 +683,7 @@ async getApiKeys(): Promise<ApiKeysResponse>
|
||||
|
||||
***
|
||||
|
||||
### deleteApiKey()
|
||||
### deleteApiKey
|
||||
|
||||
Deletes (revokes) the currently authenticated API key.
|
||||
|
||||
@@ -697,7 +697,7 @@ async deleteApiKey(): Promise<any>
|
||||
|
||||
***
|
||||
|
||||
### getNotifications()
|
||||
### getNotifications
|
||||
|
||||
Retrieves all event notifications for the authenticated user. Records are automatically removed after 48 hours.
|
||||
|
||||
@@ -735,7 +735,7 @@ async getNotifications(): Promise<Notification[]>
|
||||
|
||||
***
|
||||
|
||||
### dropNotifications()
|
||||
### dropNotifications
|
||||
|
||||
Mark notifications as read/dismissed.
|
||||
|
||||
@@ -770,3 +770,6 @@ async dropNotifications(params?: DropNotificationParams): Promise<void>
|
||||
Real-time market data streaming.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -52,6 +52,17 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
||||
|
||||
markets = client.get_markets()
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::{Client, Config};
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.authenticate()
|
||||
.await?;
|
||||
|
||||
let markets = client.markets(None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Source Code
|
||||
@@ -95,3 +106,6 @@ For [gasless transactions](/trading/gasless) using proxy wallets, the relayer cl
|
||||
Understand L1/L2 auth and API credentials.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -46,7 +46,7 @@ Public methods require the client to initialize with the host URL and Polygon ch
|
||||
|
||||
***
|
||||
|
||||
### getOk()
|
||||
### getOk
|
||||
|
||||
Health check endpoint to verify the CLOB service is operational.
|
||||
|
||||
@@ -60,7 +60,7 @@ async getOk(): Promise<any>
|
||||
|
||||
***
|
||||
|
||||
### getMarket()
|
||||
### getMarket
|
||||
|
||||
Get details for a single market by condition ID.
|
||||
|
||||
@@ -186,7 +186,7 @@ async getMarket(conditionId: string): Promise<Market>
|
||||
|
||||
***
|
||||
|
||||
### getMarkets()
|
||||
### getMarkets
|
||||
|
||||
Get details for multiple markets paginated.
|
||||
|
||||
@@ -208,7 +208,7 @@ async getMarkets(): Promise<PaginationPayload>
|
||||
|
||||
***
|
||||
|
||||
### getSimplifiedMarkets()
|
||||
### getSimplifiedMarkets
|
||||
|
||||
Get simplified market data paginated for faster loading.
|
||||
|
||||
@@ -230,7 +230,7 @@ async getSimplifiedMarkets(): Promise<PaginationPayload>
|
||||
|
||||
***
|
||||
|
||||
### getSamplingMarkets()
|
||||
### getSamplingMarkets
|
||||
|
||||
Get markets eligible for sampling/liquidity rewards.
|
||||
|
||||
@@ -240,7 +240,7 @@ async getSamplingMarkets(): Promise<PaginationPayload>
|
||||
|
||||
***
|
||||
|
||||
### getSamplingSimplifiedMarkets()
|
||||
### getSamplingSimplifiedMarkets
|
||||
|
||||
Get simplified market data for markets eligible for sampling/liquidity rewards.
|
||||
|
||||
@@ -254,7 +254,7 @@ async getSamplingSimplifiedMarkets(): Promise<PaginationPayload>
|
||||
|
||||
***
|
||||
|
||||
### calculateMarketPrice()
|
||||
### calculateMarketPrice
|
||||
|
||||
Calculate the estimated price for a market order of a given size.
|
||||
|
||||
@@ -289,7 +289,7 @@ async calculateMarketPrice(
|
||||
|
||||
***
|
||||
|
||||
### getOrderBook()
|
||||
### getOrderBook
|
||||
|
||||
Get the order book for a specific token ID.
|
||||
|
||||
@@ -335,7 +335,7 @@ async getOrderBook(tokenID: string): Promise<OrderBookSummary>
|
||||
|
||||
***
|
||||
|
||||
### getOrderBooks()
|
||||
### getOrderBooks
|
||||
|
||||
Get order books for multiple token IDs.
|
||||
|
||||
@@ -357,7 +357,7 @@ async getOrderBooks(params: BookParams[]): Promise<OrderBookSummary[]>
|
||||
|
||||
***
|
||||
|
||||
### getPrice()
|
||||
### getPrice
|
||||
|
||||
Get the current best price for buying or selling a token ID.
|
||||
|
||||
@@ -374,7 +374,7 @@ async getPrice(
|
||||
|
||||
***
|
||||
|
||||
### getPrices()
|
||||
### getPrices
|
||||
|
||||
Get the current best prices for multiple token IDs.
|
||||
|
||||
@@ -388,7 +388,7 @@ async getPrices(params: BookParams[]): Promise<PricesResponse>
|
||||
|
||||
***
|
||||
|
||||
### getMidpoint()
|
||||
### getMidpoint
|
||||
|
||||
Get the midpoint price (average of best bid and best ask) for a token ID.
|
||||
|
||||
@@ -402,7 +402,7 @@ async getMidpoint(tokenID: string): Promise<any>
|
||||
|
||||
***
|
||||
|
||||
### getMidpoints()
|
||||
### getMidpoints
|
||||
|
||||
Get the midpoint prices for multiple token IDs.
|
||||
|
||||
@@ -416,7 +416,7 @@ async getMidpoints(params: BookParams[]): Promise<any>
|
||||
|
||||
***
|
||||
|
||||
### getSpread()
|
||||
### getSpread
|
||||
|
||||
Get the spread (difference between best ask and best bid) for a token ID.
|
||||
|
||||
@@ -430,7 +430,7 @@ async getSpread(tokenID: string): Promise<SpreadResponse>
|
||||
|
||||
***
|
||||
|
||||
### getSpreads()
|
||||
### getSpreads
|
||||
|
||||
Get the spreads for multiple token IDs.
|
||||
|
||||
@@ -444,7 +444,7 @@ async getSpreads(params: BookParams[]): Promise<SpreadsResponse>
|
||||
|
||||
***
|
||||
|
||||
### getPricesHistory()
|
||||
### getPricesHistory
|
||||
|
||||
Get historical price data for a token.
|
||||
|
||||
@@ -486,7 +486,7 @@ async getPricesHistory(params: PriceHistoryFilterParams): Promise<MarketPrice[]>
|
||||
|
||||
***
|
||||
|
||||
### getLastTradePrice()
|
||||
### getLastTradePrice
|
||||
|
||||
Get the price of the most recent trade for a token.
|
||||
|
||||
@@ -504,7 +504,7 @@ async getLastTradePrice(tokenID: string): Promise<LastTradePrice>
|
||||
|
||||
***
|
||||
|
||||
### getLastTradesPrices()
|
||||
### getLastTradesPrices
|
||||
|
||||
Get the most recent trade prices for multiple tokens.
|
||||
|
||||
@@ -526,7 +526,7 @@ async getLastTradesPrices(params: BookParams[]): Promise<LastTradePriceWithToken
|
||||
|
||||
***
|
||||
|
||||
### getMarketTradesEvents()
|
||||
### getMarketTradesEvents
|
||||
|
||||
Get recent trade events for a market.
|
||||
|
||||
@@ -584,7 +584,7 @@ async getMarketTradesEvents(conditionID: string): Promise<MarketTradeEvent[]>
|
||||
|
||||
***
|
||||
|
||||
### getFeeRateBps()
|
||||
### getFeeRateBps
|
||||
|
||||
Get the fee rate in basis points for a token.
|
||||
|
||||
@@ -598,7 +598,7 @@ async getFeeRateBps(tokenID: string): Promise<number>
|
||||
|
||||
***
|
||||
|
||||
### getTickSize()
|
||||
### getTickSize
|
||||
|
||||
Get the tick size (minimum price increment) for a market.
|
||||
|
||||
@@ -612,7 +612,7 @@ async getTickSize(tokenID: string): Promise<TickSize>
|
||||
|
||||
***
|
||||
|
||||
### getNegRisk()
|
||||
### getNegRisk
|
||||
|
||||
Check if a market uses negative risk (binary complementary tokens).
|
||||
|
||||
@@ -626,9 +626,9 @@ async getNegRisk(tokenID: string): Promise<boolean>
|
||||
|
||||
***
|
||||
|
||||
## Time & Server Info
|
||||
## Time and Server Info
|
||||
|
||||
### getServerTime()
|
||||
### getServerTime
|
||||
|
||||
Get the current server timestamp.
|
||||
|
||||
@@ -661,3 +661,6 @@ async getServerTime(): Promise<number>
|
||||
Real-time market data streaming.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -71,6 +71,7 @@ The following countries are restricted from placing orders on Polymarket. Countr
|
||||
| LY | Libya | Blocked |
|
||||
| MM | Myanmar | Blocked |
|
||||
| NI | Nicaragua | Blocked |
|
||||
| NL | Netherlands | Blocked |
|
||||
| PL | Poland | Close-only |
|
||||
| RU | Russia | Blocked |
|
||||
| SG | Singapore | Close-only |
|
||||
@@ -162,11 +163,26 @@ The geoblocking system includes:
|
||||
print("Trading available")
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Rust">
|
||||
```rust theme={null}
|
||||
use polymarket_client_sdk::clob::Client;
|
||||
|
||||
let client = Client::default();
|
||||
let geo = client.check_geoblock().await?;
|
||||
|
||||
if geo.blocked {
|
||||
println!("Trading not available in {}", geo.country);
|
||||
} else {
|
||||
println!("Trading available");
|
||||
}
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
***
|
||||
|
||||
## Why These Restrictions?
|
||||
## Why These Restrictions
|
||||
|
||||
Geographic restrictions are implemented to ensure compliance with:
|
||||
|
||||
@@ -191,3 +207,6 @@ If you believe you are incorrectly restricted or have questions about geographic
|
||||
Start placing orders (from eligible regions).
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -10,7 +10,7 @@ Polymarket's CLOB (Central Limit Order Book) is a hybrid-decentralized trading s
|
||||
|
||||
We recommend using the open-source SDK clients, which handle order signing, authentication, and submission:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<CardGroup cols={3}>
|
||||
<Card title="TypeScript Client" icon="github" href="https://github.com/Polymarket/clob-client">
|
||||
<p className="font-mono text-[0.8rem]">
|
||||
npm install @polymarket/clob-client
|
||||
@@ -20,6 +20,10 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
<Card title="Python Client" icon="github" href="https://github.com/Polymarket/py-clob-client">
|
||||
<p className="font-mono text-[0.8rem]">pip install py-clob-client</p>
|
||||
</Card>
|
||||
|
||||
<Card title="Rust Client" icon="github" href="https://github.com/Polymarket/rs-clob-client">
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket-client-sdk</p>
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
<Info>
|
||||
@@ -66,6 +70,23 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use std::str::FromStr;
|
||||
use polymarket_client_sdk::POLYGON;
|
||||
use polymarket_client_sdk::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
.with_chain_id(Some(POLYGON));
|
||||
|
||||
// Derive L2 API credentials and initialize client in one step
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.authenticate()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -110,6 +131,16 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
funder="0x..." # Your proxy wallet address
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::SignatureType;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.signature_type(SignatureType::GnosisSafe) // Funder auto-derived via CREATE2
|
||||
.authenticate()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -167,7 +198,7 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
|
||||
***
|
||||
|
||||
## What's in This Section
|
||||
## What Is in This Section
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Quickstart" icon="bolt" href="/trading/quickstart">
|
||||
@@ -198,3 +229,6 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
Deposit and withdraw funds across chains
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -25,6 +25,12 @@ All cancel endpoints require [L2 authentication](/trading/overview#authenticatio
|
||||
# {"canceled": ["0xb816482a..."], "not_canceled": {}}
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.cancel_order("0xb816482a...").await?;
|
||||
println!("{:?}", resp);
|
||||
// CancelOrdersResponse { canceled: ["0xb816482a..."], not_canceled: {} }
|
||||
```
|
||||
|
||||
```bash REST theme={null}
|
||||
curl -X DELETE "https://clob.polymarket.com/order" \
|
||||
-H "Content-Type: application/json" \
|
||||
@@ -53,6 +59,10 @@ All cancel endpoints require [L2 authentication](/trading/overview#authenticatio
|
||||
])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.cancel_orders(&["0xb816482a...", "0xc927593b..."]).await?;
|
||||
```
|
||||
|
||||
```bash REST theme={null}
|
||||
curl -X DELETE "https://clob.polymarket.com/orders" \
|
||||
-H "Content-Type: application/json" \
|
||||
@@ -80,6 +90,10 @@ Cancel every open order across all markets:
|
||||
resp = client.cancel_all()
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.cancel_all_orders().await?;
|
||||
```
|
||||
|
||||
```bash REST theme={null}
|
||||
curl -X DELETE "https://clob.polymarket.com/cancel-all" \
|
||||
-H "POLY_ADDRESS: ..." \
|
||||
@@ -111,6 +125,16 @@ Cancel all orders for a specific market, optionally filtered to a single token.
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::CancelMarketOrderRequest;
|
||||
|
||||
let request = CancelMarketOrderRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.asset_id("52114319501245...".parse()?)
|
||||
.build();
|
||||
let resp = client.cancel_market_orders(&request).await?;
|
||||
```
|
||||
|
||||
```bash REST theme={null}
|
||||
curl -X DELETE "https://clob.polymarket.com/cancel-market-orders" \
|
||||
-H "Content-Type: application/json" \
|
||||
@@ -149,6 +173,11 @@ This is a fallback mechanism — API cancellation is instant while onchain cance
|
||||
order = client.get_order("0xb816482a...")
|
||||
print(order["status"], order["size_matched"])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client.order("0xb816482a...").await?;
|
||||
println!("{:?} {}", order.status, order.size_matched);
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Get Open Orders
|
||||
@@ -182,6 +211,19 @@ Retrieve all open orders, optionally filtered by market or token:
|
||||
OpenOrderParams(market="0xbd31dc8a...")
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = OrdersRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_orders = client.orders(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### OpenOrder Object
|
||||
@@ -238,11 +280,24 @@ When an order is matched, it creates a trade. Trades progress through these stat
|
||||
TradeParams(market="0xbd31dc8a...")
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = TradesRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_trades = client.trades(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Additional filter parameters: `id`, `maker_address`, `asset_id`, `before`, `after`.
|
||||
|
||||
For large result sets, use the paginated variant:
|
||||
The Rust SDK uses cursor-based pagination via the `next_cursor` parameter:
|
||||
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
@@ -253,6 +308,15 @@ For large result sets, use the paginated variant:
|
||||
```python Python theme={null}
|
||||
page = client.get_trades_paginated(TradeParams(market="0xbd31dc8a..."))
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// First page
|
||||
let page = client.trades(&request, None).await?;
|
||||
println!("{} trades, cursor: {}", page.data.len(), page.next_cursor);
|
||||
|
||||
// Next page
|
||||
let page2 = client.trades(&request, Some(page.next_cursor)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Trade Object
|
||||
@@ -312,6 +376,14 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
OrdersScoringParams(orderIds=["0x...", "0x..."])
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Single order
|
||||
let scoring = client.is_order_scoring("0x...").await?;
|
||||
|
||||
// Multiple orders
|
||||
let batch = client.are_orders_scoring(&["0x...", "0x..."]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -327,3 +399,6 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
Understand fee structures and maker rebates
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -71,6 +71,11 @@ Retrieve the tick size for a market using the SDK:
|
||||
tick_size = client.get_tick_size(token_id)
|
||||
# Returns: "0.1" | "0.01" | "0.001" | "0.0001"
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.tick_size(token_id).await?;
|
||||
// resp.minimum_tick_size: TickSize::Tenth | Hundredth | Thousandth | TenThousandth
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
@@ -114,6 +119,21 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// The Rust SDK auto-detects neg risk from the token ID — no flag needed.
|
||||
// The order builder fetches neg_risk and uses the correct exchange contract.
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
You can check whether a market uses negative risk via the SDK or the market object's `neg_risk` field:
|
||||
@@ -126,6 +146,10 @@ You can check whether a market uses negative risk via the SDK or the market obje
|
||||
```python Python theme={null}
|
||||
is_neg_risk = client.get_neg_risk(token_id)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let is_neg_risk = client.neg_risk(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -165,7 +189,7 @@ $$
|
||||
|
||||
## Querying Orders
|
||||
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication).
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication). [Builder-authenticated](/trading/clients/builder) clients can also query orders attributed to their builder account using the same methods.
|
||||
|
||||
### Get a Single Order
|
||||
|
||||
@@ -181,6 +205,11 @@ Retrieve details for a specific order by its ID:
|
||||
order = client.get_order("0xb816482a...")
|
||||
print(order)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client.order("0xb816482a...").await?;
|
||||
println!("{order:?}");
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Get Open Orders
|
||||
@@ -216,6 +245,25 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = OrdersRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_orders = client.orders(&request, None).await?;
|
||||
|
||||
// Filtered by asset
|
||||
let request = OrdersRequest::builder()
|
||||
.asset_id("52114319501245...".parse()?)
|
||||
.build();
|
||||
let asset_orders = client.orders(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### OpenOrder Object
|
||||
@@ -325,6 +373,19 @@ Retrieve your trades with the SDK:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = TradesRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_trades = client.trades(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -352,6 +413,15 @@ The heartbeat endpoint maintains session liveness for order safety. If a valid h
|
||||
heartbeat_id = resp["heartbeat_id"]
|
||||
time.sleep(5)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// With the `heartbeats` feature, auto-send in background:
|
||||
Client::start_heartbeats(&mut client)?;
|
||||
|
||||
// Or manually:
|
||||
let resp = client.post_heartbeat(None).await?; // None for first call
|
||||
let resp = client.post_heartbeat(Some(resp.heartbeat_id)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* On each request, include the most recent `heartbeat_id` you received. For your first request, use an empty string.
|
||||
@@ -388,6 +458,15 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
OrdersScoringParams(orderIds=["0x...", "0x..."])
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Single order
|
||||
let scoring = client.is_order_scoring("0x...").await?;
|
||||
println!("Scoring: {}", scoring.scoring);
|
||||
|
||||
// Multiple orders
|
||||
let batch = client.are_orders_scoring(&["0x...", "0x..."]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -461,3 +540,6 @@ The operator's privileges are limited to order matching and ensuring correct ord
|
||||
Cancel single, multiple, or all orders
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -80,9 +80,29 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
print("Order ID:", response["orderID"])
|
||||
print("Status:", response["status"])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::Side;
|
||||
use polymarket_client_sdk::types::dec;
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id(token_id)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
|
||||
println!("Order ID: {}", response.order_id);
|
||||
println!("Status: {:?}", response.status);
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Two-Step: Sign Then Submit
|
||||
### Two-Step Sign Then Submit
|
||||
|
||||
For more control, you can separate signing from submission. This is useful for batch orders or custom submission logic:
|
||||
|
||||
@@ -121,11 +141,27 @@ For more control, you can separate signing from submission. This is useful for b
|
||||
# Step 2: Submit to the CLOB
|
||||
response = client.post_order(signed_order, OrderType.GTC)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Step 1: Create order (auto-fetches tick size, neg risk, fee rate)
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
|
||||
// Step 2: Sign and submit separately
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
|
||||
## GTD Orders (Expiring)
|
||||
## GTD Orders
|
||||
|
||||
GTD orders auto-expire at a specified time. Useful for quoting around known events.
|
||||
|
||||
@@ -168,6 +204,24 @@ GTD orders auto-expire at a specified time. Useful for quoting around known even
|
||||
order_type=OrderType.GTD
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use chrono::{TimeDelta, Utc};
|
||||
use polymarket_client_sdk::clob::types::OrderType;
|
||||
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.order_type(OrderType::GTD)
|
||||
.expiration(Utc::now() + TimeDelta::hours(1))
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Note>
|
||||
@@ -235,6 +289,38 @@ Market orders execute immediately against resting liquidity using FOK or FAK typ
|
||||
)
|
||||
client.post_order(sell_order, OrderType.FOK)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::{Amount, OrderType, Side};
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
|
||||
// FOK BUY: spend exactly $100 or cancel entirely
|
||||
let buy = client
|
||||
.market_order()
|
||||
.token_id(token_id)
|
||||
.amount(Amount::usdc(dec!(100))?)
|
||||
.price(dec!(0.50)) // worst-price limit (slippage protection)
|
||||
.side(Side::Buy)
|
||||
.order_type(OrderType::FOK)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, buy).await?;
|
||||
client.post_order(signed).await?;
|
||||
|
||||
// FOK SELL: sell exactly 200 shares or cancel entirely
|
||||
let sell = client
|
||||
.market_order()
|
||||
.token_id(token_id)
|
||||
.amount(Amount::shares(dec!(200))?)
|
||||
.price(dec!(0.45)) // worst-price limit (slippage protection)
|
||||
.side(Side::Sell)
|
||||
.order_type(OrderType::FOK)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, sell).await?;
|
||||
client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* **FOK** — fill entirely or cancel the whole order
|
||||
@@ -270,6 +356,20 @@ For convenience, `createAndPostMarketOrder` handles creation, signing, and submi
|
||||
order_type=OrderType.FOK,
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client
|
||||
.market_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.amount(Amount::usdc(dec!(100))?)
|
||||
.price(dec!(0.50))
|
||||
.side(Side::Buy)
|
||||
.order_type(OrderType::FOK)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -286,6 +386,20 @@ Post-only orders guarantee you're always the maker. If the order would match imm
|
||||
```python Python theme={null}
|
||||
response = client.post_order(signed_order, OrderType.GTC, post_only=True)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.post_only(true)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* Only works with **GTC** and **GTD** order types
|
||||
@@ -356,6 +470,31 @@ Place up to **15 orders** in a single request:
|
||||
),
|
||||
])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
|
||||
let bid = client
|
||||
.limit_order()
|
||||
.token_id(token_id)
|
||||
.price(dec!(0.48))
|
||||
.size(dec!(500))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let ask = client
|
||||
.limit_order()
|
||||
.token_id(token_id)
|
||||
.price(dec!(0.52))
|
||||
.size(dec!(500))
|
||||
.side(Side::Sell)
|
||||
.build()
|
||||
.await?;
|
||||
|
||||
let signed_bid = client.sign(&signer, bid).await?;
|
||||
let signed_ask = client.sign(&signer, ask).await?;
|
||||
let response = client.post_orders(vec![signed_bid, signed_ask]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -383,6 +522,11 @@ Your order price must conform to the market's tick size, or the order is rejecte
|
||||
```python Python theme={null}
|
||||
tick_size = client.get_tick_size("TOKEN_ID")
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let tick_size = client.tick_size(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Negative Risk
|
||||
@@ -397,11 +541,16 @@ Multi-outcome events (3+ outcomes) use the Neg Risk CTF Exchange. Pass `negRisk:
|
||||
```python Python theme={null}
|
||||
is_neg_risk = client.get_neg_risk("TOKEN_ID")
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let is_neg_risk = client.neg_risk(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
Both values are also available on the market object: `minimum_tick_size` and
|
||||
`neg_risk`.
|
||||
`neg_risk`. In Rust, the order builder auto-fetches both — you don't need to look them up manually.
|
||||
</Tip>
|
||||
|
||||
***
|
||||
@@ -513,6 +662,18 @@ The heartbeat endpoint maintains session liveness. If a valid heartbeat is not r
|
||||
heartbeat_id = resp["heartbeat_id"]
|
||||
time.sleep(5)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// With the `heartbeats` feature, the Rust SDK can auto-send heartbeats
|
||||
// in a background task — no manual loop needed:
|
||||
Client::start_heartbeats(&mut client)?;
|
||||
// ... your trading logic ...
|
||||
client.stop_heartbeats().await?;
|
||||
|
||||
// Or send manually:
|
||||
let resp = client.post_heartbeat(None).await?; // None for first call
|
||||
let resp = client.post_heartbeat(Some(resp.heartbeat_id)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* Include the most recent `heartbeat_id` in each request. Use an empty string for the first request.
|
||||
@@ -531,3 +692,6 @@ The heartbeat endpoint maintains session liveness. If a valid heartbeat is not r
|
||||
Attribute orders to your builder account for volume credit
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -80,9 +80,29 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
print("Order ID:", response["orderID"])
|
||||
print("Status:", response["status"])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::Side;
|
||||
use polymarket_client_sdk::types::dec;
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id(token_id)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
|
||||
println!("Order ID: {}", response.order_id);
|
||||
println!("Status: {:?}", response.status);
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Two-Step: Sign Then Submit
|
||||
### Two-Step Sign Then Submit
|
||||
|
||||
For more control, you can separate signing from submission. This is useful for batch orders or custom submission logic:
|
||||
|
||||
@@ -121,11 +141,27 @@ For more control, you can separate signing from submission. This is useful for b
|
||||
# Step 2: Submit to the CLOB
|
||||
response = client.post_order(signed_order, OrderType.GTC)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Step 1: Create order (auto-fetches tick size, neg risk, fee rate)
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
|
||||
// Step 2: Sign and submit separately
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
|
||||
## GTD Orders (Expiring)
|
||||
## GTD Orders
|
||||
|
||||
GTD orders auto-expire at a specified time. Useful for quoting around known events.
|
||||
|
||||
@@ -168,6 +204,24 @@ GTD orders auto-expire at a specified time. Useful for quoting around known even
|
||||
order_type=OrderType.GTD
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use chrono::{TimeDelta, Utc};
|
||||
use polymarket_client_sdk::clob::types::OrderType;
|
||||
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.order_type(OrderType::GTD)
|
||||
.expiration(Utc::now() + TimeDelta::hours(1))
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Note>
|
||||
@@ -235,6 +289,38 @@ Market orders execute immediately against resting liquidity using FOK or FAK typ
|
||||
)
|
||||
client.post_order(sell_order, OrderType.FOK)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::{Amount, OrderType, Side};
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
|
||||
// FOK BUY: spend exactly $100 or cancel entirely
|
||||
let buy = client
|
||||
.market_order()
|
||||
.token_id(token_id)
|
||||
.amount(Amount::usdc(dec!(100))?)
|
||||
.price(dec!(0.50)) // worst-price limit (slippage protection)
|
||||
.side(Side::Buy)
|
||||
.order_type(OrderType::FOK)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, buy).await?;
|
||||
client.post_order(signed).await?;
|
||||
|
||||
// FOK SELL: sell exactly 200 shares or cancel entirely
|
||||
let sell = client
|
||||
.market_order()
|
||||
.token_id(token_id)
|
||||
.amount(Amount::shares(dec!(200))?)
|
||||
.price(dec!(0.45)) // worst-price limit (slippage protection)
|
||||
.side(Side::Sell)
|
||||
.order_type(OrderType::FOK)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, sell).await?;
|
||||
client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* **FOK** — fill entirely or cancel the whole order
|
||||
@@ -270,6 +356,20 @@ For convenience, `createAndPostMarketOrder` handles creation, signing, and submi
|
||||
order_type=OrderType.FOK,
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client
|
||||
.market_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.amount(Amount::usdc(dec!(100))?)
|
||||
.price(dec!(0.50))
|
||||
.side(Side::Buy)
|
||||
.order_type(OrderType::FOK)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -286,6 +386,20 @@ Post-only orders guarantee you're always the maker. If the order would match imm
|
||||
```python Python theme={null}
|
||||
response = client.post_order(signed_order, OrderType.GTC, post_only=True)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.post_only(true)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* Only works with **GTC** and **GTD** order types
|
||||
@@ -356,6 +470,31 @@ Place up to **15 orders** in a single request:
|
||||
),
|
||||
])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
|
||||
let bid = client
|
||||
.limit_order()
|
||||
.token_id(token_id)
|
||||
.price(dec!(0.48))
|
||||
.size(dec!(500))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let ask = client
|
||||
.limit_order()
|
||||
.token_id(token_id)
|
||||
.price(dec!(0.52))
|
||||
.size(dec!(500))
|
||||
.side(Side::Sell)
|
||||
.build()
|
||||
.await?;
|
||||
|
||||
let signed_bid = client.sign(&signer, bid).await?;
|
||||
let signed_ask = client.sign(&signer, ask).await?;
|
||||
let response = client.post_orders(vec![signed_bid, signed_ask]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -383,6 +522,11 @@ Your order price must conform to the market's tick size, or the order is rejecte
|
||||
```python Python theme={null}
|
||||
tick_size = client.get_tick_size("TOKEN_ID")
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let tick_size = client.tick_size(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Negative Risk
|
||||
@@ -397,11 +541,16 @@ Multi-outcome events (3+ outcomes) use the Neg Risk CTF Exchange. Pass `negRisk:
|
||||
```python Python theme={null}
|
||||
is_neg_risk = client.get_neg_risk("TOKEN_ID")
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let is_neg_risk = client.neg_risk(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
Both values are also available on the market object: `minimum_tick_size` and
|
||||
`neg_risk`.
|
||||
`neg_risk`. In Rust, the order builder auto-fetches both — you don't need to look them up manually.
|
||||
</Tip>
|
||||
|
||||
***
|
||||
@@ -513,6 +662,18 @@ The heartbeat endpoint maintains session liveness. If a valid heartbeat is not r
|
||||
heartbeat_id = resp["heartbeat_id"]
|
||||
time.sleep(5)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// With the `heartbeats` feature, the Rust SDK can auto-send heartbeats
|
||||
// in a background task — no manual loop needed:
|
||||
Client::start_heartbeats(&mut client)?;
|
||||
// ... your trading logic ...
|
||||
client.stop_heartbeats().await?;
|
||||
|
||||
// Or send manually:
|
||||
let resp = client.post_heartbeat(None).await?; // None for first call
|
||||
let resp = client.post_heartbeat(Some(resp.heartbeat_id)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* Include the most recent `heartbeat_id` in each request. Use an empty string for the first request.
|
||||
@@ -531,3 +692,6 @@ The heartbeat endpoint maintains session liveness. If a valid heartbeat is not r
|
||||
Attribute orders to your builder account for volume credit
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -71,6 +71,11 @@ Retrieve the tick size for a market using the SDK:
|
||||
tick_size = client.get_tick_size(token_id)
|
||||
# Returns: "0.1" | "0.01" | "0.001" | "0.0001"
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.tick_size(token_id).await?;
|
||||
// resp.minimum_tick_size: TickSize::Tenth | Hundredth | Thousandth | TenThousandth
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
@@ -114,6 +119,21 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// The Rust SDK auto-detects neg risk from the token ID — no flag needed.
|
||||
// The order builder fetches neg_risk and uses the correct exchange contract.
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
You can check whether a market uses negative risk via the SDK or the market object's `neg_risk` field:
|
||||
@@ -126,6 +146,10 @@ You can check whether a market uses negative risk via the SDK or the market obje
|
||||
```python Python theme={null}
|
||||
is_neg_risk = client.get_neg_risk(token_id)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let is_neg_risk = client.neg_risk(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -165,7 +189,7 @@ $$
|
||||
|
||||
## Querying Orders
|
||||
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication).
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication). [Builder-authenticated](/trading/clients/builder) clients can also query orders attributed to their builder account using the same methods.
|
||||
|
||||
### Get a Single Order
|
||||
|
||||
@@ -181,6 +205,11 @@ Retrieve details for a specific order by its ID:
|
||||
order = client.get_order("0xb816482a...")
|
||||
print(order)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client.order("0xb816482a...").await?;
|
||||
println!("{order:?}");
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Get Open Orders
|
||||
@@ -216,6 +245,25 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = OrdersRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_orders = client.orders(&request, None).await?;
|
||||
|
||||
// Filtered by asset
|
||||
let request = OrdersRequest::builder()
|
||||
.asset_id("52114319501245...".parse()?)
|
||||
.build();
|
||||
let asset_orders = client.orders(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### OpenOrder Object
|
||||
@@ -325,6 +373,19 @@ Retrieve your trades with the SDK:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = TradesRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_trades = client.trades(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -352,6 +413,15 @@ The heartbeat endpoint maintains session liveness for order safety. If a valid h
|
||||
heartbeat_id = resp["heartbeat_id"]
|
||||
time.sleep(5)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// With the `heartbeats` feature, auto-send in background:
|
||||
Client::start_heartbeats(&mut client)?;
|
||||
|
||||
// Or manually:
|
||||
let resp = client.post_heartbeat(None).await?; // None for first call
|
||||
let resp = client.post_heartbeat(Some(resp.heartbeat_id)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* On each request, include the most recent `heartbeat_id` you received. For your first request, use an empty string.
|
||||
@@ -388,6 +458,15 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
OrdersScoringParams(orderIds=["0x...", "0x..."])
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Single order
|
||||
let scoring = client.is_order_scoring("0x...").await?;
|
||||
println!("Scoring: {}", scoring.scoring);
|
||||
|
||||
// Multiple orders
|
||||
let batch = client.are_orders_scoring(&["0x...", "0x..."]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -461,3 +540,6 @@ The operator's privileges are limited to order matching and ensuring correct ord
|
||||
Cancel single, multiple, or all orders
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -71,6 +71,11 @@ Retrieve the tick size for a market using the SDK:
|
||||
tick_size = client.get_tick_size(token_id)
|
||||
# Returns: "0.1" | "0.01" | "0.001" | "0.0001"
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.tick_size(token_id).await?;
|
||||
// resp.minimum_tick_size: TickSize::Tenth | Hundredth | Thousandth | TenThousandth
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
@@ -114,6 +119,21 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// The Rust SDK auto-detects neg risk from the token ID — no flag needed.
|
||||
// The order builder fetches neg_risk and uses the correct exchange contract.
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
You can check whether a market uses negative risk via the SDK or the market object's `neg_risk` field:
|
||||
@@ -126,6 +146,10 @@ You can check whether a market uses negative risk via the SDK or the market obje
|
||||
```python Python theme={null}
|
||||
is_neg_risk = client.get_neg_risk(token_id)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let is_neg_risk = client.neg_risk(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -165,7 +189,7 @@ $$
|
||||
|
||||
## Querying Orders
|
||||
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication).
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication). [Builder-authenticated](/trading/clients/builder) clients can also query orders attributed to their builder account using the same methods.
|
||||
|
||||
### Get a Single Order
|
||||
|
||||
@@ -181,6 +205,11 @@ Retrieve details for a specific order by its ID:
|
||||
order = client.get_order("0xb816482a...")
|
||||
print(order)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client.order("0xb816482a...").await?;
|
||||
println!("{order:?}");
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Get Open Orders
|
||||
@@ -216,6 +245,25 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = OrdersRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_orders = client.orders(&request, None).await?;
|
||||
|
||||
// Filtered by asset
|
||||
let request = OrdersRequest::builder()
|
||||
.asset_id("52114319501245...".parse()?)
|
||||
.build();
|
||||
let asset_orders = client.orders(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### OpenOrder Object
|
||||
@@ -325,6 +373,19 @@ Retrieve your trades with the SDK:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = TradesRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_trades = client.trades(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -352,6 +413,15 @@ The heartbeat endpoint maintains session liveness for order safety. If a valid h
|
||||
heartbeat_id = resp["heartbeat_id"]
|
||||
time.sleep(5)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// With the `heartbeats` feature, auto-send in background:
|
||||
Client::start_heartbeats(&mut client)?;
|
||||
|
||||
// Or manually:
|
||||
let resp = client.post_heartbeat(None).await?; // None for first call
|
||||
let resp = client.post_heartbeat(Some(resp.heartbeat_id)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* On each request, include the most recent `heartbeat_id` you received. For your first request, use an empty string.
|
||||
@@ -388,6 +458,15 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
OrdersScoringParams(orderIds=["0x...", "0x..."])
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Single order
|
||||
let scoring = client.is_order_scoring("0x...").await?;
|
||||
println!("Scoring: {}", scoring.scoring);
|
||||
|
||||
// Multiple orders
|
||||
let batch = client.are_orders_scoring(&["0x...", "0x..."]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -461,3 +540,6 @@ The operator's privileges are limited to order matching and ensuring correct ord
|
||||
Cancel single, multiple, or all orders
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -71,6 +71,11 @@ Retrieve the tick size for a market using the SDK:
|
||||
tick_size = client.get_tick_size(token_id)
|
||||
# Returns: "0.1" | "0.01" | "0.001" | "0.0001"
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.tick_size(token_id).await?;
|
||||
// resp.minimum_tick_size: TickSize::Tenth | Hundredth | Thousandth | TenThousandth
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
@@ -114,6 +119,21 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// The Rust SDK auto-detects neg risk from the token ID — no flag needed.
|
||||
// The order builder fetches neg_risk and uses the correct exchange contract.
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
You can check whether a market uses negative risk via the SDK or the market object's `neg_risk` field:
|
||||
@@ -126,6 +146,10 @@ You can check whether a market uses negative risk via the SDK or the market obje
|
||||
```python Python theme={null}
|
||||
is_neg_risk = client.get_neg_risk(token_id)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let is_neg_risk = client.neg_risk(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -165,7 +189,7 @@ $$
|
||||
|
||||
## Querying Orders
|
||||
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication).
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication). [Builder-authenticated](/trading/clients/builder) clients can also query orders attributed to their builder account using the same methods.
|
||||
|
||||
### Get a Single Order
|
||||
|
||||
@@ -181,6 +205,11 @@ Retrieve details for a specific order by its ID:
|
||||
order = client.get_order("0xb816482a...")
|
||||
print(order)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client.order("0xb816482a...").await?;
|
||||
println!("{order:?}");
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Get Open Orders
|
||||
@@ -216,6 +245,25 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = OrdersRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_orders = client.orders(&request, None).await?;
|
||||
|
||||
// Filtered by asset
|
||||
let request = OrdersRequest::builder()
|
||||
.asset_id("52114319501245...".parse()?)
|
||||
.build();
|
||||
let asset_orders = client.orders(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### OpenOrder Object
|
||||
@@ -325,6 +373,19 @@ Retrieve your trades with the SDK:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = TradesRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_trades = client.trades(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -352,6 +413,15 @@ The heartbeat endpoint maintains session liveness for order safety. If a valid h
|
||||
heartbeat_id = resp["heartbeat_id"]
|
||||
time.sleep(5)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// With the `heartbeats` feature, auto-send in background:
|
||||
Client::start_heartbeats(&mut client)?;
|
||||
|
||||
// Or manually:
|
||||
let resp = client.post_heartbeat(None).await?; // None for first call
|
||||
let resp = client.post_heartbeat(Some(resp.heartbeat_id)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* On each request, include the most recent `heartbeat_id` you received. For your first request, use an empty string.
|
||||
@@ -388,6 +458,15 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
OrdersScoringParams(orderIds=["0x...", "0x..."])
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Single order
|
||||
let scoring = client.is_order_scoring("0x...").await?;
|
||||
println!("Scoring: {}", scoring.scoring);
|
||||
|
||||
// Multiple orders
|
||||
let batch = client.are_orders_scoring(&["0x...", "0x..."]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -461,3 +540,6 @@ The operator's privileges are limited to order matching and ensuring correct ord
|
||||
Cancel single, multiple, or all orders
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -71,6 +71,11 @@ Retrieve the tick size for a market using the SDK:
|
||||
tick_size = client.get_tick_size(token_id)
|
||||
# Returns: "0.1" | "0.01" | "0.001" | "0.0001"
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let resp = client.tick_size(token_id).await?;
|
||||
// resp.minimum_tick_size: TickSize::Tenth | Hundredth | Thousandth | TenThousandth
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
@@ -114,6 +119,21 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// The Rust SDK auto-detects neg risk from the token ID — no flag needed.
|
||||
// The order builder fetches neg_risk and uses the correct exchange contract.
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id("TOKEN_ID".parse()?)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
You can check whether a market uses negative risk via the SDK or the market object's `neg_risk` field:
|
||||
@@ -126,6 +146,10 @@ You can check whether a market uses negative risk via the SDK or the market obje
|
||||
```python Python theme={null}
|
||||
is_neg_risk = client.get_neg_risk(token_id)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let is_neg_risk = client.neg_risk(token_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -165,7 +189,7 @@ $$
|
||||
|
||||
## Querying Orders
|
||||
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication).
|
||||
All query endpoints require [L2 authentication](/api-reference/authentication). [Builder-authenticated](/trading/clients/builder) clients can also query orders attributed to their builder account using the same methods.
|
||||
|
||||
### Get a Single Order
|
||||
|
||||
@@ -181,6 +205,11 @@ Retrieve details for a specific order by its ID:
|
||||
order = client.get_order("0xb816482a...")
|
||||
print(order)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
let order = client.order("0xb816482a...").await?;
|
||||
println!("{order:?}");
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Get Open Orders
|
||||
@@ -216,6 +245,25 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = OrdersRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_orders = client.orders(&request, None).await?;
|
||||
|
||||
// Filtered by asset
|
||||
let request = OrdersRequest::builder()
|
||||
.asset_id("52114319501245...".parse()?)
|
||||
.build();
|
||||
let asset_orders = client.orders(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### OpenOrder Object
|
||||
@@ -325,6 +373,19 @@ Retrieve your trades with the SDK:
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
|
||||
// Filtered by market
|
||||
let request = TradesRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
.build();
|
||||
let market_trades = client.trades(&request, None).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -352,6 +413,15 @@ The heartbeat endpoint maintains session liveness for order safety. If a valid h
|
||||
heartbeat_id = resp["heartbeat_id"]
|
||||
time.sleep(5)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// With the `heartbeats` feature, auto-send in background:
|
||||
Client::start_heartbeats(&mut client)?;
|
||||
|
||||
// Or manually:
|
||||
let resp = client.post_heartbeat(None).await?; // None for first call
|
||||
let resp = client.post_heartbeat(Some(resp.heartbeat_id)).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
* On each request, include the most recent `heartbeat_id` you received. For your first request, use an empty string.
|
||||
@@ -388,6 +458,15 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
OrdersScoringParams(orderIds=["0x...", "0x..."])
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
// Single order
|
||||
let scoring = client.is_order_scoring("0x...").await?;
|
||||
println!("Scoring: {}", scoring.scoring);
|
||||
|
||||
// Multiple orders
|
||||
let batch = client.are_orders_scoring(&["0x...", "0x..."]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -461,3 +540,6 @@ The operator's privileges are limited to order matching and ensuring correct ord
|
||||
Cancel single, multiple, or all orders
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -18,6 +18,10 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
```bash Python theme={null}
|
||||
pip install py-clob-client
|
||||
```
|
||||
|
||||
```bash Rust theme={null}
|
||||
cargo add polymarket-client-sdk --features clob
|
||||
```
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
|
||||
@@ -70,6 +74,23 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
funder="YOUR_WALLET_ADDRESS"
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use std::str::FromStr;
|
||||
use polymarket_client_sdk::POLYGON;
|
||||
use polymarket_client_sdk::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
.with_chain_id(Some(POLYGON));
|
||||
|
||||
// Derive API credentials and initialize client (EOA by default)
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.authenticate()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Note>
|
||||
@@ -131,6 +152,28 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
print("Order ID:", response["orderID"])
|
||||
print("Status:", response["status"])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::Side;
|
||||
use polymarket_client_sdk::types::dec;
|
||||
|
||||
let token_id = "YOUR_TOKEN_ID".parse()?;
|
||||
|
||||
// Tick size and neg risk are auto-fetched by the order builder
|
||||
let order = client
|
||||
.limit_order()
|
||||
.token_id(token_id)
|
||||
.price(dec!(0.50))
|
||||
.size(dec!(10))
|
||||
.side(Side::Buy)
|
||||
.build()
|
||||
.await?;
|
||||
let signed_order = client.sign(&signer, order).await?;
|
||||
let response = client.post_order(signed_order).await?;
|
||||
|
||||
println!("Order ID: {}", response.order_id);
|
||||
println!("Status: {:?}", response.status);
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
@@ -167,6 +210,21 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
# Cancel an order
|
||||
client.cancel(order_id=response["orderID"])
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::{OrdersRequest, TradesRequest};
|
||||
|
||||
// View all open orders
|
||||
let open_orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
println!("You have {} open orders", open_orders.data.len());
|
||||
|
||||
// View your trade history
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
println!("You've made {} trades", trades.data.len());
|
||||
|
||||
// Cancel an order
|
||||
client.cancel_order(&response.order_id).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
</Steps>
|
||||
@@ -176,7 +234,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
## Troubleshooting
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="L2_AUTH_NOT_AVAILABLE / Invalid Signature">
|
||||
<Accordion title="L2 AUTH NOT AVAILABLE - Invalid Signature">
|
||||
Wrong private key, signature type, or funder address for the derived API credentials.
|
||||
|
||||
* Check that `signatureType` matches your account type (`0`, `1`, or `2`)
|
||||
@@ -184,7 +242,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
* Re-derive credentials with `createOrDeriveApiKey()` if unsure
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Order rejected: insufficient balance">
|
||||
<Accordion title="Order rejected - insufficient balance">
|
||||
Your funder address doesn't have enough tokens:
|
||||
|
||||
* **BUY orders**: need USDC.e in your funder address
|
||||
@@ -192,13 +250,13 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
* Ensure you have more USDC.e than what's committed in open orders
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Order rejected: insufficient allowance">
|
||||
<Accordion title="Order rejected - insufficient allowance">
|
||||
You need to approve the Exchange contract to spend your tokens. This is
|
||||
typically done through the Polymarket UI on your first trade, or using the CTF
|
||||
contract's `setApprovalForAll()` method.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="What's my funder address?">
|
||||
<Accordion title="What is my funder address">
|
||||
Your funder address is the wallet where your funds are held:
|
||||
|
||||
* **EOA (type 0)**: Your wallet address directly
|
||||
@@ -207,7 +265,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
If the proxy wallet doesn't exist, log into Polymarket.com first (it's deployed on first login).
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Blocked by Cloudflare / Geoblock">
|
||||
<Accordion title="Blocked by Cloudflare or Geoblock">
|
||||
You're trying to place a trade from a restricted region. See [Geographic Restrictions](/api-reference/geoblock) for details.
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
@@ -225,3 +283,6 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
Attribute orders to your builder account for volume credit
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
File diff suppressed because one or more lines are too long
@@ -10,7 +10,7 @@
|
||||
|
||||
## OpenAPI
|
||||
|
||||
````yaml api-spec/clob-openapi.yaml get /prices-history
|
||||
````yaml /api-spec/clob-openapi.yaml get /prices-history
|
||||
openapi: 3.1.0
|
||||
info:
|
||||
title: Polymarket CLOB API
|
||||
@@ -36,6 +36,8 @@ tags:
|
||||
description: User notification endpoints
|
||||
- name: Rewards
|
||||
description: Rewards and earnings endpoints
|
||||
- name: Rebates
|
||||
description: Maker rebate endpoints
|
||||
paths:
|
||||
/prices-history:
|
||||
get:
|
||||
@@ -133,3 +135,5 @@ components:
|
||||
format: float
|
||||
|
||||
````
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -10,7 +10,7 @@ Polymarket's CLOB (Central Limit Order Book) is a hybrid-decentralized trading s
|
||||
|
||||
We recommend using the open-source SDK clients, which handle order signing, authentication, and submission:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<CardGroup cols={3}>
|
||||
<Card title="TypeScript Client" icon="github" href="https://github.com/Polymarket/clob-client">
|
||||
<p className="font-mono text-[0.8rem]">
|
||||
npm install @polymarket/clob-client
|
||||
@@ -20,6 +20,10 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
<Card title="Python Client" icon="github" href="https://github.com/Polymarket/py-clob-client">
|
||||
<p className="font-mono text-[0.8rem]">pip install py-clob-client</p>
|
||||
</Card>
|
||||
|
||||
<Card title="Rust Client" icon="github" href="https://github.com/Polymarket/rs-clob-client">
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket-client-sdk</p>
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
<Info>
|
||||
@@ -66,6 +70,23 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use std::str::FromStr;
|
||||
use polymarket_client_sdk::POLYGON;
|
||||
use polymarket_client_sdk::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
.with_chain_id(Some(POLYGON));
|
||||
|
||||
// Derive L2 API credentials and initialize client in one step
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.authenticate()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -110,6 +131,16 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
funder="0x..." # Your proxy wallet address
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::SignatureType;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.signature_type(SignatureType::GnosisSafe) // Funder auto-derived via CREATE2
|
||||
.authenticate()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -167,7 +198,7 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
|
||||
***
|
||||
|
||||
## What's in This Section
|
||||
## What Is in This Section
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Quickstart" icon="bolt" href="/trading/quickstart">
|
||||
@@ -198,3 +229,6 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
Deposit and withdraw funds across chains
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -10,7 +10,7 @@ Polymarket's CLOB (Central Limit Order Book) is a hybrid-decentralized trading s
|
||||
|
||||
We recommend using the open-source SDK clients, which handle order signing, authentication, and submission:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<CardGroup cols={3}>
|
||||
<Card title="TypeScript Client" icon="github" href="https://github.com/Polymarket/clob-client">
|
||||
<p className="font-mono text-[0.8rem]">
|
||||
npm install @polymarket/clob-client
|
||||
@@ -20,6 +20,10 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
<Card title="Python Client" icon="github" href="https://github.com/Polymarket/py-clob-client">
|
||||
<p className="font-mono text-[0.8rem]">pip install py-clob-client</p>
|
||||
</Card>
|
||||
|
||||
<Card title="Rust Client" icon="github" href="https://github.com/Polymarket/rs-clob-client">
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket-client-sdk</p>
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
<Info>
|
||||
@@ -66,6 +70,23 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use std::str::FromStr;
|
||||
use polymarket_client_sdk::POLYGON;
|
||||
use polymarket_client_sdk::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
.with_chain_id(Some(POLYGON));
|
||||
|
||||
// Derive L2 API credentials and initialize client in one step
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.authenticate()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -110,6 +131,16 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
funder="0x..." # Your proxy wallet address
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::SignatureType;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
.signature_type(SignatureType::GnosisSafe) // Funder auto-derived via CREATE2
|
||||
.authenticate()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
@@ -167,7 +198,7 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
|
||||
***
|
||||
|
||||
## What's in This Section
|
||||
## What Is in This Section
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Quickstart" icon="bolt" href="/trading/quickstart">
|
||||
@@ -198,3 +229,6 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
Deposit and withdraw funds across chains
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -144,6 +144,10 @@ Emitted when the best bid or ask prices for a market change.
|
||||
|
||||
Emitted when a new market is created.
|
||||
|
||||
The payload also includes market metadata fields such as `tags`,
|
||||
`condition_id`, `active`, `clob_token_ids`, `sports_market_type`, `line`,
|
||||
`game_start_time`, `order_price_min_tick_size`, and `group_item_title`.
|
||||
|
||||
```json theme={null}
|
||||
{
|
||||
"id": "1031769",
|
||||
@@ -164,7 +168,19 @@ Emitted when a new market is created.
|
||||
"description": "This market will resolve to \"Yes\" if the official closing price..."
|
||||
},
|
||||
"timestamp": "1766790415550",
|
||||
"event_type": "new_market"
|
||||
"event_type": "new_market",
|
||||
"tags": ["stocks"],
|
||||
"condition_id": "0x311d0c4b6671ab54af4970c06fcf58662516f5168997bdda209ec3db5aa6b0c1",
|
||||
"active": true,
|
||||
"clob_token_ids": [
|
||||
"76043073756653678226373981964075571318267289248134717369284518995922789326425",
|
||||
"31690934263385727664202099278545688007799199447969475608906331829650099442770"
|
||||
],
|
||||
"sports_market_type": "",
|
||||
"line": "",
|
||||
"game_start_time": "",
|
||||
"order_price_min_tick_size": "0.01",
|
||||
"group_item_title": "NVDA above $240"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -199,3 +215,6 @@ Emitted when a market is resolved.
|
||||
"event_type": "market_resolved"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -122,3 +122,6 @@ Emitted when:
|
||||
"type": "PLACEMENT"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -137,7 +137,7 @@ For the user channel, use `markets` instead of `assets_ids`:
|
||||
|
||||
## Heartbeats
|
||||
|
||||
### Market & User Channels
|
||||
### Market and User Channels
|
||||
|
||||
Send `PING` every 10 seconds. The server responds with `PONG`.
|
||||
|
||||
@@ -165,7 +165,7 @@ pong
|
||||
close connections that don't subscribe within a timeout period.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Connection drops after ~10 seconds">
|
||||
<Accordion title="Connection drops after about 10 seconds">
|
||||
You're not sending heartbeats. Send `PING` every 10 seconds for market/user
|
||||
channels, or respond to server `ping` with `pong` for the sports channel.
|
||||
</Accordion>
|
||||
@@ -176,6 +176,9 @@ pong
|
||||
expecting `best_bid_ask`, `new_market`, or `market_resolved` events
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Authentication failed (user channel)">
|
||||
<Accordion title="Authentication failed - user channel">
|
||||
Verify your API credentials are correct and haven't expired.
|
||||
</Accordion>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
@@ -137,7 +137,7 @@ For the user channel, use `markets` instead of `assets_ids`:
|
||||
|
||||
## Heartbeats
|
||||
|
||||
### Market & User Channels
|
||||
### Market and User Channels
|
||||
|
||||
Send `PING` every 10 seconds. The server responds with `PONG`.
|
||||
|
||||
@@ -165,7 +165,7 @@ pong
|
||||
close connections that don't subscribe within a timeout period.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Connection drops after ~10 seconds">
|
||||
<Accordion title="Connection drops after about 10 seconds">
|
||||
You're not sending heartbeats. Send `PING` every 10 seconds for market/user
|
||||
channels, or respond to server `ping` with `pong` for the sports channel.
|
||||
</Accordion>
|
||||
@@ -176,6 +176,9 @@ pong
|
||||
expecting `best_bid_ask`, `new_market`, or `market_resolved` events
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Authentication failed (user channel)">
|
||||
<Accordion title="Authentication failed - user channel">
|
||||
Verify your API credentials are correct and haven't expired.
|
||||
</Accordion>
|
||||
|
||||
|
||||
Built with [Mintlify](https://mintlify.com).
|
||||
Reference in New Issue
Block a user