docs: sync Polymarket documentation (2026-05-03)
Updated 55 files with latest documentation changes
This commit is contained in:
@@ -63,12 +63,16 @@ Before making authenticated requests, you need to obtain API credentials using L
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers"; // v5.8.0
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
const client = new ClobClient({
|
||||
host: "https://clob.polymarket.com",
|
||||
chain: 137, // Polygon mainnet
|
||||
signer: new Wallet(process.env.PRIVATE_KEY),
|
||||
signer,
|
||||
});
|
||||
|
||||
// Creates new credentials or derives existing ones
|
||||
@@ -76,7 +80,7 @@ Before making authenticated requests, you need to obtain API credentials using L
|
||||
|
||||
console.log(credentials);
|
||||
// {
|
||||
// apiKey: "550e8400-e29b-41d4-a716-446655440000",
|
||||
// key: "550e8400-e29b-41d4-a716-446655440000",
|
||||
// secret: "base64EncodedSecretString",
|
||||
// passphrase: "randomPassphraseString"
|
||||
// }
|
||||
@@ -85,17 +89,17 @@ Before making authenticated requests, you need to obtain API credentials using L
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
import os
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain=137, # Polygon mainnet
|
||||
chain_id=137, # Polygon mainnet
|
||||
key=os.getenv("PRIVATE_KEY")
|
||||
)
|
||||
|
||||
# Creates new credentials or derives existing ones
|
||||
credentials = client.create_or_derive_api_creds()
|
||||
credentials = client.create_or_derive_api_key()
|
||||
|
||||
print(credentials)
|
||||
# {
|
||||
@@ -109,9 +113,9 @@ Before making authenticated requests, you need to obtain API credentials using L
|
||||
<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};
|
||||
use polymarket_client_sdk_v2::POLYGON;
|
||||
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
@@ -221,7 +225,7 @@ The `POLY_SIGNATURE` is generated by signing the following EIP-712 struct:
|
||||
Reference implementations:
|
||||
|
||||
* [TypeScript](https://github.com/Polymarket/clob-client-v2/blob/main/src/signing/eip712.ts)
|
||||
* [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client/signing/eip712.py)
|
||||
* [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client_v2/signing/eip712.py)
|
||||
|
||||
Response:
|
||||
|
||||
@@ -249,20 +253,24 @@ All trading endpoints require these 5 headers:
|
||||
| `POLY_API_KEY` | User's API `apiKey` value |
|
||||
| `POLY_PASSPHRASE` | User's API `passphrase` value |
|
||||
|
||||
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-v2/blob/main/src/signing/hmac.ts) and [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client/signing/hmac.py) clients.
|
||||
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-v2/blob/main/src/signing/hmac.ts) and [Python](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client_v2/signing/hmac.py) clients.
|
||||
|
||||
### CLOB Client
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers"; // v5.8.0
|
||||
import { ClobClient, Side } from "@polymarket/clob-client-v2";
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
const client = new ClobClient({
|
||||
host: "https://clob.polymarket.com",
|
||||
chain: 137,
|
||||
signer: new Wallet(process.env.PRIVATE_KEY),
|
||||
signer,
|
||||
creds: apiCreds, // Generated from L1 auth, API credentials enable L2 methods
|
||||
signatureType: 1, // signatureType explained below
|
||||
funderAddress, // funder explained below
|
||||
@@ -270,7 +278,7 @@ The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's
|
||||
|
||||
// Now you can trade!
|
||||
const order = await client.createAndPostOrder(
|
||||
{ tokenID: "123456", price: 0.65, size: 100, side: "BUY" },
|
||||
{ tokenID: "123456", price: 0.65, size: 100, side: Side.BUY },
|
||||
{ tickSize: "0.01", negRisk: false }
|
||||
);
|
||||
```
|
||||
@@ -278,12 +286,13 @@ The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient, OrderArgs, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
import os
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
key=os.getenv("PRIVATE_KEY"),
|
||||
creds=api_creds, # Generated from L1 auth, API credentials enable L2 methods
|
||||
signature_type=1, # signatureType explained below
|
||||
@@ -292,16 +301,16 @@ The `POLY_SIGNATURE` for L2 is an HMAC-SHA256 signature created using the user's
|
||||
|
||||
# Now you can trade!
|
||||
order = client.create_and_post_order(
|
||||
{"token_id": "123456", "price": 0.65, "size": 100, "side": "BUY"},
|
||||
{"tick_size": "0.01", "neg_risk": False}
|
||||
OrderArgs(token_id="123456", price=0.65, size=100, side=BUY),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
)
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Rust">
|
||||
```rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::{Side, SignatureType};
|
||||
use polymarket_client_sdk::types::dec;
|
||||
use polymarket_client_sdk_v2::clob::types::{Side, SignatureType};
|
||||
use polymarket_client_sdk_v2::types::dec;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
|
||||
@@ -37,14 +37,14 @@ Builder attribution in V2 is handled natively through the order struct — you a
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client.clob_types import OrderArgs
|
||||
from py_clob_client.order_builder.constants import BUY
|
||||
from py_clob_client_v2 import ClobClient
|
||||
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
import os
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
key=os.getenv("PRIVATE_KEY"),
|
||||
creds=creds,
|
||||
signature_type=signature_type,
|
||||
@@ -60,7 +60,7 @@ Builder attribution in V2 is handled natively through the order struct — you a
|
||||
side=BUY,
|
||||
builder_code=os.environ["POLY_BUILDER_CODE"],
|
||||
),
|
||||
options={"tick_size": "0.01", "neg_risk": False},
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
)
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -14,9 +14,11 @@ L1 methods require the client to initialize with a signer.
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers";
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY);
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
const client = new ClobClient({
|
||||
host: "https://clob.polymarket.com",
|
||||
@@ -31,14 +33,14 @@ L1 methods require the client to initialize with a signer.
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
import os
|
||||
|
||||
private_key = os.getenv("PRIVATE_KEY")
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
key=private_key # Signer required for L1 methods
|
||||
)
|
||||
|
||||
@@ -134,6 +136,13 @@ async createOrDeriveApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
|
||||
## Order Signing
|
||||
|
||||
<Note>
|
||||
In CLOB V2, `expiration` is still accepted in order payloads for GTD/order
|
||||
expiry handling, but it is not part of the EIP-712 signed order struct. The
|
||||
signed struct uses `timestamp`, `metadata`, and `builder` instead of the V1
|
||||
`expiration`, `nonce`, `feeRateBps`, and `taker` fields.
|
||||
</Note>
|
||||
|
||||
### 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).
|
||||
@@ -162,7 +171,8 @@ async createOrder(
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="number">
|
||||
Optional expiration timestamp for the order. Optional.
|
||||
Optional expiration timestamp included in the order payload for GTD/order
|
||||
expiry handling. This is not part of the CLOB V2 EIP-712 signed order struct.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tickSize" type="TickSize">
|
||||
@@ -202,7 +212,22 @@ async createOrder(
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="string">
|
||||
The expiration timestamp as a string.
|
||||
The expiration timestamp included in the order payload. This is not part of
|
||||
the CLOB V2 EIP-712 signed order struct.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="timestamp" type="string">
|
||||
Order creation timestamp in milliseconds, used for order uniqueness in CLOB
|
||||
V2.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="metadata" type="string">
|
||||
Reserved `bytes32` metadata field.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="builder" type="string">
|
||||
Builder code (`bytes32`) for attribution, or zero if no builder code is
|
||||
attached.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signatureType" type="number">
|
||||
@@ -275,7 +300,22 @@ async createMarketOrder(
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="string">
|
||||
The expiration timestamp as a string.
|
||||
The expiration timestamp included in the order payload. This is not part of
|
||||
the CLOB V2 EIP-712 signed order struct.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="timestamp" type="string">
|
||||
Order creation timestamp in milliseconds, used for order uniqueness in CLOB
|
||||
V2.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="metadata" type="string">
|
||||
Reserved `bytes32` metadata field.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="builder" type="string">
|
||||
Builder code (`bytes32`) for attribution, or zero if no builder code is
|
||||
attached.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signatureType" type="number">
|
||||
|
||||
@@ -14,12 +14,14 @@ L2 methods require the client to initialize with a signer, signature type, API c
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers";
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY);
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
const apiCreds = {
|
||||
apiKey: process.env.API_KEY,
|
||||
key: process.env.API_KEY,
|
||||
secret: process.env.SECRET,
|
||||
passphrase: process.env.PASSPHRASE,
|
||||
};
|
||||
@@ -40,8 +42,8 @@ L2 methods require the client to initialize with a signer, signature type, API c
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client.clob_types import ApiCreds
|
||||
from py_clob_client_v2 import ClobClient
|
||||
from py_clob_client_v2 import ApiCreds
|
||||
import os
|
||||
|
||||
api_creds = ApiCreds(
|
||||
@@ -52,7 +54,7 @@ L2 methods require the client to initialize with a signer, signature type, API c
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
key=os.getenv("PRIVATE_KEY"),
|
||||
creds=api_creds,
|
||||
signature_type=2, # GNOSIS_SAFE
|
||||
|
||||
@@ -12,7 +12,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
||||
|
||||
<CodeGroup>
|
||||
```bash TypeScript theme={null}
|
||||
npm install @polymarket/clob-client-v2 ethers@5
|
||||
npm install @polymarket/clob-client-v2 viem
|
||||
```
|
||||
|
||||
```bash Python theme={null}
|
||||
@@ -20,7 +20,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
||||
```
|
||||
|
||||
```bash Rust theme={null}
|
||||
cargo add polymarket-client-sdk
|
||||
cargo add polymarket_client_sdk_v2 --features clob
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -41,12 +41,12 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
|
||||
client = ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
key=private_key,
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
creds=api_creds,
|
||||
)
|
||||
|
||||
@@ -54,7 +54,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::{Client, Config};
|
||||
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
@@ -71,7 +71,7 @@ Polymarket provides official open-source clients in TypeScript, Python, and Rust
|
||||
| ---------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
||||
| TypeScript | `@polymarket/clob-client-v2` | [github.com/Polymarket/clob-client-v2](https://github.com/Polymarket/clob-client-v2) |
|
||||
| Python | `py-clob-client-v2` | [github.com/Polymarket/py-clob-client-v2](https://github.com/Polymarket/py-clob-client-v2) |
|
||||
| Rust | `polymarket-client-sdk` | [github.com/Polymarket/rs-clob-client-v2](https://github.com/Polymarket/rs-clob-client-v2) |
|
||||
| Rust | `polymarket_client_sdk_v2` | [github.com/Polymarket/rs-clob-client-v2](https://github.com/Polymarket/rs-clob-client-v2) |
|
||||
|
||||
Each repository includes working examples in the `/examples` directory.
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ Public methods require the client to initialize with the host URL and Polygon ch
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain=137
|
||||
chain_id=137
|
||||
)
|
||||
|
||||
# Ready to call public methods
|
||||
|
||||
@@ -167,9 +167,9 @@ The geoblocking system includes:
|
||||
|
||||
<Tab title="Rust">
|
||||
```rust theme={null}
|
||||
use polymarket_client_sdk::clob::Client;
|
||||
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||
|
||||
let client = Client::default();
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?;
|
||||
let geo = client.check_geoblock().await?;
|
||||
|
||||
if geo.blocked {
|
||||
|
||||
@@ -13,7 +13,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
<CardGroup cols={3}>
|
||||
<Card title="TypeScript Client" icon="github" href="https://github.com/Polymarket/clob-client-v2">
|
||||
<p className="font-mono text-[0.8rem]">
|
||||
npm install @polymarket/clob-client-v2
|
||||
npm install @polymarket/clob-client-v2 viem
|
||||
</p>
|
||||
</Card>
|
||||
|
||||
@@ -22,7 +22,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
</Card>
|
||||
|
||||
<Card title="Rust Client" icon="github" href="https://github.com/Polymarket/rs-clob-client-v2">
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket-client-sdk</p>
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket\_client\_sdk\_v2 --features clob</p>
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -51,9 +51,11 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers"; // v5.8.0
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY);
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
// Derive L2 API credentials
|
||||
const tempClient = new ClobClient({ host: "https://clob.polymarket.com", chain: 137, signer });
|
||||
@@ -61,21 +63,21 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
import os
|
||||
|
||||
private_key = os.getenv("PRIVATE_KEY")
|
||||
|
||||
# Derive L2 API credentials
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain=137)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
|
||||
api_creds = temp_client.create_or_derive_api_key()
|
||||
```
|
||||
|
||||
```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};
|
||||
use polymarket_client_sdk_v2::POLYGON;
|
||||
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
@@ -125,7 +127,7 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
client = ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
key=private_key,
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
creds=api_creds,
|
||||
signature_type=2, # GNOSIS_SAFE
|
||||
funder="0x..." # Your proxy wallet address
|
||||
@@ -133,7 +135,7 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::SignatureType;
|
||||
use polymarket_client_sdk_v2::clob::types::SignatureType;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
@@ -192,7 +194,7 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
</Card>
|
||||
|
||||
<Card title="Builder Methods" icon="hammer" href="/trading/clients/builder">
|
||||
Track attributed trades and manage builder credentials.
|
||||
Track orders and trades attributed to your builder code.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ 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;
|
||||
use polymarket_client_sdk_v2::clob::types::request::CancelMarketOrderRequest;
|
||||
|
||||
let request = CancelMarketOrderRequest::builder()
|
||||
.market("0xbd31dc8a...".parse()?)
|
||||
@@ -191,7 +191,7 @@ Retrieve all open orders, optionally filtered by market or token:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OpenOrderParams
|
||||
from py_clob_client_v2 import OpenOrderParams
|
||||
|
||||
# All open orders
|
||||
orders = client.get_orders()
|
||||
@@ -203,7 +203,7 @@ Retrieve all open orders, optionally filtered by market or token:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
@@ -262,7 +262,7 @@ When an order is matched, it creates a trade. Trades progress through these stat
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import TradeParams
|
||||
from py_clob_client_v2 import TradeParams
|
||||
|
||||
trades = client.get_trades()
|
||||
|
||||
@@ -272,7 +272,7 @@ When an order is matched, it creates a trade. Trades progress through these stat
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
@@ -356,7 +356,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
|
||||
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
|
||||
|
||||
scoring = client.is_order_scoring(
|
||||
OrderScoringParams(orderId="0x...")
|
||||
|
||||
@@ -106,6 +106,9 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
@@ -113,10 +116,10 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": True, # Required for multi-outcome markets
|
||||
}
|
||||
options=PartialCreateOrderOptions(
|
||||
tick_size="0.01",
|
||||
neg_risk=True, # Required for multi-outcome markets
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
@@ -232,7 +235,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OpenOrderParams
|
||||
from py_clob_client_v2 import OpenOrderParams
|
||||
|
||||
# All open orders
|
||||
orders = client.get_orders()
|
||||
@@ -246,7 +249,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
@@ -360,7 +363,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import TradeParams
|
||||
from py_clob_client_v2 import TradeParams
|
||||
|
||||
# All trades
|
||||
trades = client.get_trades()
|
||||
@@ -374,7 +377,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
@@ -445,7 +448,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
|
||||
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
|
||||
|
||||
# Single order
|
||||
scoring = client.is_order_scoring(
|
||||
|
||||
@@ -60,8 +60,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderArgs, OrderType
|
||||
from py_clob_client.order_builder.constants import BUY
|
||||
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
@@ -70,10 +70,7 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": False,
|
||||
},
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
order_type=OrderType.GTC
|
||||
)
|
||||
|
||||
@@ -82,8 +79,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::Side;
|
||||
use polymarket_client_sdk::types::dec;
|
||||
use polymarket_client_sdk_v2::clob::types::Side;
|
||||
use polymarket_client_sdk_v2::types::dec;
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let order = client
|
||||
@@ -132,10 +129,7 @@ For more control, you can separate signing from submission. This is useful for b
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": False,
|
||||
}
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)
|
||||
)
|
||||
|
||||
# Step 2: Submit to the CLOB
|
||||
@@ -197,17 +191,14 @@ GTD orders auto-expire at a specified time. Useful for quoting around known even
|
||||
side=BUY,
|
||||
expiration=expiration,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": False,
|
||||
},
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
order_type=OrderType.GTD
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use chrono::{TimeDelta, Utc};
|
||||
use polymarket_client_sdk::clob::types::OrderType;
|
||||
use polymarket_client_sdk_v2::clob::types::OrderType;
|
||||
|
||||
let order = client
|
||||
.limit_order()
|
||||
@@ -266,32 +257,36 @@ Market orders execute immediately against resting liquidity using FOK or FAK typ
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.order_builder.constants import BUY, SELL
|
||||
from py_clob_client.clob_types import OrderType
|
||||
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||
|
||||
# FOK BUY: spend exactly $100 or cancel entirely
|
||||
buy_order = client.create_market_order(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100, # dollar amount
|
||||
price=0.50, # worst-price limit (slippage protection)
|
||||
options={"tick_size": "0.01", "neg_risk": False},
|
||||
order_args=MarketOrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100, # dollar amount
|
||||
price=0.50, # worst-price limit (slippage protection)
|
||||
),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
)
|
||||
client.post_order(buy_order, OrderType.FOK)
|
||||
|
||||
# FOK SELL: sell exactly 200 shares or cancel entirely
|
||||
sell_order = client.create_market_order(
|
||||
token_id="TOKEN_ID",
|
||||
side=SELL,
|
||||
amount=200, # number of shares
|
||||
price=0.45, # worst-price limit (slippage protection)
|
||||
options={"tick_size": "0.01", "neg_risk": False},
|
||||
order_args=MarketOrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
side=SELL,
|
||||
amount=200, # number of shares
|
||||
price=0.45, # worst-price limit (slippage protection)
|
||||
),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
)
|
||||
client.post_order(sell_order, OrderType.FOK)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::{Amount, OrderType, Side};
|
||||
use polymarket_client_sdk_v2::clob::types::{Amount, OrderType, Side};
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
|
||||
@@ -347,12 +342,17 @@ For convenience, `createAndPostMarketOrder` handles creation, signing, and submi
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_market_order(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100,
|
||||
price=0.50,
|
||||
options={"tick_size": "0.01", "neg_risk": False},
|
||||
order_args=MarketOrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100,
|
||||
price=0.50,
|
||||
),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
order_type=OrderType.FOK,
|
||||
)
|
||||
```
|
||||
@@ -446,26 +446,26 @@ Place up to **15 orders** in a single request:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderArgs, OrderType, PostOrdersArgs
|
||||
from py_clob_client.order_builder.constants import BUY, SELL
|
||||
from py_clob_client_v2 import OrderArgs, OrderType, PostOrdersV2Args, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||
|
||||
response = client.post_orders([
|
||||
PostOrdersArgs(
|
||||
PostOrdersV2Args(
|
||||
order=client.create_order(OrderArgs(
|
||||
price=0.48,
|
||||
size=500,
|
||||
side=BUY,
|
||||
token_id="TOKEN_ID",
|
||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
||||
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||
orderType=OrderType.GTC,
|
||||
),
|
||||
PostOrdersArgs(
|
||||
PostOrdersV2Args(
|
||||
order=client.create_order(OrderArgs(
|
||||
price=0.52,
|
||||
size=500,
|
||||
side=SELL,
|
||||
token_id="TOKEN_ID",
|
||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
||||
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||
orderType=OrderType.GTC,
|
||||
),
|
||||
])
|
||||
|
||||
@@ -60,8 +60,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderArgs, OrderType
|
||||
from py_clob_client.order_builder.constants import BUY
|
||||
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
@@ -70,10 +70,7 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": False,
|
||||
},
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
order_type=OrderType.GTC
|
||||
)
|
||||
|
||||
@@ -82,8 +79,8 @@ The simplest way to place a limit order — create, sign, and submit in one call
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::Side;
|
||||
use polymarket_client_sdk::types::dec;
|
||||
use polymarket_client_sdk_v2::clob::types::Side;
|
||||
use polymarket_client_sdk_v2::types::dec;
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
let order = client
|
||||
@@ -132,10 +129,7 @@ For more control, you can separate signing from submission. This is useful for b
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": False,
|
||||
}
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)
|
||||
)
|
||||
|
||||
# Step 2: Submit to the CLOB
|
||||
@@ -197,17 +191,14 @@ GTD orders auto-expire at a specified time. Useful for quoting around known even
|
||||
side=BUY,
|
||||
expiration=expiration,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": False,
|
||||
},
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
order_type=OrderType.GTD
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use chrono::{TimeDelta, Utc};
|
||||
use polymarket_client_sdk::clob::types::OrderType;
|
||||
use polymarket_client_sdk_v2::clob::types::OrderType;
|
||||
|
||||
let order = client
|
||||
.limit_order()
|
||||
@@ -266,32 +257,36 @@ Market orders execute immediately against resting liquidity using FOK or FAK typ
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.order_builder.constants import BUY, SELL
|
||||
from py_clob_client.clob_types import OrderType
|
||||
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||
|
||||
# FOK BUY: spend exactly $100 or cancel entirely
|
||||
buy_order = client.create_market_order(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100, # dollar amount
|
||||
price=0.50, # worst-price limit (slippage protection)
|
||||
options={"tick_size": "0.01", "neg_risk": False},
|
||||
order_args=MarketOrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100, # dollar amount
|
||||
price=0.50, # worst-price limit (slippage protection)
|
||||
),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
)
|
||||
client.post_order(buy_order, OrderType.FOK)
|
||||
|
||||
# FOK SELL: sell exactly 200 shares or cancel entirely
|
||||
sell_order = client.create_market_order(
|
||||
token_id="TOKEN_ID",
|
||||
side=SELL,
|
||||
amount=200, # number of shares
|
||||
price=0.45, # worst-price limit (slippage protection)
|
||||
options={"tick_size": "0.01", "neg_risk": False},
|
||||
order_args=MarketOrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
side=SELL,
|
||||
amount=200, # number of shares
|
||||
price=0.45, # worst-price limit (slippage protection)
|
||||
),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
)
|
||||
client.post_order(sell_order, OrderType.FOK)
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::{Amount, OrderType, Side};
|
||||
use polymarket_client_sdk_v2::clob::types::{Amount, OrderType, Side};
|
||||
|
||||
let token_id = "TOKEN_ID".parse()?;
|
||||
|
||||
@@ -347,12 +342,17 @@ For convenience, `createAndPostMarketOrder` handles creation, signing, and submi
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import MarketOrderArgs, OrderType, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_market_order(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100,
|
||||
price=0.50,
|
||||
options={"tick_size": "0.01", "neg_risk": False},
|
||||
order_args=MarketOrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
side=BUY,
|
||||
amount=100,
|
||||
price=0.50,
|
||||
),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
order_type=OrderType.FOK,
|
||||
)
|
||||
```
|
||||
@@ -446,26 +446,26 @@ Place up to **15 orders** in a single request:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderArgs, OrderType, PostOrdersArgs
|
||||
from py_clob_client.order_builder.constants import BUY, SELL
|
||||
from py_clob_client_v2 import OrderArgs, OrderType, PostOrdersV2Args, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY, SELL
|
||||
|
||||
response = client.post_orders([
|
||||
PostOrdersArgs(
|
||||
PostOrdersV2Args(
|
||||
order=client.create_order(OrderArgs(
|
||||
price=0.48,
|
||||
size=500,
|
||||
side=BUY,
|
||||
token_id="TOKEN_ID",
|
||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
||||
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||
orderType=OrderType.GTC,
|
||||
),
|
||||
PostOrdersArgs(
|
||||
PostOrdersV2Args(
|
||||
order=client.create_order(OrderArgs(
|
||||
price=0.52,
|
||||
size=500,
|
||||
side=SELL,
|
||||
token_id="TOKEN_ID",
|
||||
), options={"tick_size": "0.01", "neg_risk": False}),
|
||||
), options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False)),
|
||||
orderType=OrderType.GTC,
|
||||
),
|
||||
])
|
||||
|
||||
@@ -106,6 +106,9 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
@@ -113,10 +116,10 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": True, # Required for multi-outcome markets
|
||||
}
|
||||
options=PartialCreateOrderOptions(
|
||||
tick_size="0.01",
|
||||
neg_risk=True, # Required for multi-outcome markets
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
@@ -232,7 +235,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OpenOrderParams
|
||||
from py_clob_client_v2 import OpenOrderParams
|
||||
|
||||
# All open orders
|
||||
orders = client.get_orders()
|
||||
@@ -246,7 +249,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
@@ -360,7 +363,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import TradeParams
|
||||
from py_clob_client_v2 import TradeParams
|
||||
|
||||
# All trades
|
||||
trades = client.get_trades()
|
||||
@@ -374,7 +377,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
@@ -445,7 +448,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
|
||||
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
|
||||
|
||||
# Single order
|
||||
scoring = client.is_order_scoring(
|
||||
|
||||
@@ -106,6 +106,9 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
@@ -113,10 +116,10 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": True, # Required for multi-outcome markets
|
||||
}
|
||||
options=PartialCreateOrderOptions(
|
||||
tick_size="0.01",
|
||||
neg_risk=True, # Required for multi-outcome markets
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
@@ -232,7 +235,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OpenOrderParams
|
||||
from py_clob_client_v2 import OpenOrderParams
|
||||
|
||||
# All open orders
|
||||
orders = client.get_orders()
|
||||
@@ -246,7 +249,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
@@ -360,7 +363,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import TradeParams
|
||||
from py_clob_client_v2 import TradeParams
|
||||
|
||||
# All trades
|
||||
trades = client.get_trades()
|
||||
@@ -374,7 +377,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
@@ -445,7 +448,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
|
||||
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
|
||||
|
||||
# Single order
|
||||
scoring = client.is_order_scoring(
|
||||
|
||||
@@ -106,6 +106,9 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
@@ -113,10 +116,10 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": True, # Required for multi-outcome markets
|
||||
}
|
||||
options=PartialCreateOrderOptions(
|
||||
tick_size="0.01",
|
||||
neg_risk=True, # Required for multi-outcome markets
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
@@ -232,7 +235,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OpenOrderParams
|
||||
from py_clob_client_v2 import OpenOrderParams
|
||||
|
||||
# All open orders
|
||||
orders = client.get_orders()
|
||||
@@ -246,7 +249,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
@@ -360,7 +363,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import TradeParams
|
||||
from py_clob_client_v2 import TradeParams
|
||||
|
||||
# All trades
|
||||
trades = client.get_trades()
|
||||
@@ -374,7 +377,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
@@ -445,7 +448,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
|
||||
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
|
||||
|
||||
# Single order
|
||||
scoring = client.is_order_scoring(
|
||||
|
||||
@@ -106,6 +106,9 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import OrderArgs, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
token_id="TOKEN_ID",
|
||||
@@ -113,10 +116,10 @@ Multi-outcome events (e.g., "Who will win the election?" with 3+ candidates) use
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": True, # Required for multi-outcome markets
|
||||
}
|
||||
options=PartialCreateOrderOptions(
|
||||
tick_size="0.01",
|
||||
neg_risk=True, # Required for multi-outcome markets
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
@@ -232,7 +235,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OpenOrderParams
|
||||
from py_clob_client_v2 import OpenOrderParams
|
||||
|
||||
# All open orders
|
||||
orders = client.get_orders()
|
||||
@@ -246,7 +249,7 @@ Retrieve your open orders, optionally filtered by market or asset:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::OrdersRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::OrdersRequest;
|
||||
|
||||
// All open orders
|
||||
let orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
@@ -360,7 +363,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import TradeParams
|
||||
from py_clob_client_v2 import TradeParams
|
||||
|
||||
# All trades
|
||||
trades = client.get_trades()
|
||||
@@ -374,7 +377,7 @@ Retrieve your trades with the SDK:
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::TradesRequest;
|
||||
use polymarket_client_sdk_v2::clob::types::request::TradesRequest;
|
||||
|
||||
// All trades
|
||||
let trades = client.trades(&TradesRequest::default(), None).await?;
|
||||
@@ -445,7 +448,7 @@ Check if your resting orders are eligible for [maker rebates](/market-makers/mak
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderScoringParams, OrdersScoringParams
|
||||
from py_clob_client_v2 import OrderScoringParams, OrdersScoringParams
|
||||
|
||||
# Single order
|
||||
scoring = client.is_order_scoring(
|
||||
|
||||
@@ -12,7 +12,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
<Step title="Install the SDK">
|
||||
<CodeGroup>
|
||||
```bash TypeScript theme={null}
|
||||
npm install @polymarket/clob-client-v2 ethers@5
|
||||
npm install @polymarket/clob-client-v2 viem
|
||||
```
|
||||
|
||||
```bash Python theme={null}
|
||||
@@ -20,7 +20,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
```
|
||||
|
||||
```bash Rust theme={null}
|
||||
cargo add polymarket-client-sdk --features clob
|
||||
cargo add polymarket_client_sdk_v2 --features clob
|
||||
```
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
@@ -31,11 +31,13 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers"; // v5.8.0
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const HOST = "https://clob.polymarket.com";
|
||||
const CHAIN_ID = 137; // Polygon mainnet
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY);
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
// Derive API credentials
|
||||
const tempClient = new ClobClient({ host: HOST, chain: CHAIN_ID, signer });
|
||||
@@ -48,12 +50,12 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
signer,
|
||||
creds: apiCreds,
|
||||
signatureType: 0, // EOA
|
||||
funderAddress: signer.address,
|
||||
funderAddress: account.address,
|
||||
});
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
import os
|
||||
|
||||
host = "https://clob.polymarket.com"
|
||||
@@ -61,14 +63,14 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
private_key = os.getenv("PRIVATE_KEY")
|
||||
|
||||
# Derive API credentials
|
||||
temp_client = ClobClient(host, key=private_key, chain=chain)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
temp_client = ClobClient(host, key=private_key, chain_id=chain)
|
||||
api_creds = temp_client.create_or_derive_api_key()
|
||||
|
||||
# Initialize trading client
|
||||
client = ClobClient(
|
||||
host,
|
||||
key=private_key,
|
||||
chain=chain,
|
||||
chain_id=chain,
|
||||
creds=api_creds,
|
||||
signature_type=0, # EOA
|
||||
funder="YOUR_WALLET_ADDRESS"
|
||||
@@ -77,9 +79,9 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
|
||||
```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};
|
||||
use polymarket_client_sdk_v2::POLYGON;
|
||||
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
@@ -132,8 +134,8 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.clob_types import OrderArgs, OrderType
|
||||
from py_clob_client.order_builder.constants import BUY
|
||||
from py_clob_client_v2 import OrderArgs, OrderType, PartialCreateOrderOptions
|
||||
from py_clob_client_v2.order_builder.constants import BUY
|
||||
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
@@ -142,10 +144,10 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
size=10,
|
||||
side=BUY,
|
||||
),
|
||||
options={
|
||||
"tick_size": "0.01",
|
||||
"neg_risk": False, # Set to True for multi-outcome markets
|
||||
},
|
||||
options=PartialCreateOrderOptions(
|
||||
tick_size="0.01",
|
||||
neg_risk=False, # Set to True for multi-outcome markets
|
||||
),
|
||||
order_type=OrderType.GTC
|
||||
)
|
||||
|
||||
@@ -154,8 +156,8 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::Side;
|
||||
use polymarket_client_sdk::types::dec;
|
||||
use polymarket_client_sdk_v2::clob::types::Side;
|
||||
use polymarket_client_sdk_v2::types::dec;
|
||||
|
||||
let token_id = "YOUR_TOKEN_ID".parse()?;
|
||||
|
||||
@@ -212,7 +214,7 @@ This guide walks you through placing an order on Polymarket end-to-end.
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::request::{OrdersRequest, TradesRequest};
|
||||
use polymarket_client_sdk_v2::clob::types::request::{OrdersRequest, TradesRequest};
|
||||
|
||||
// View all open orders
|
||||
let open_orders = client.orders(&OrdersRequest::default(), None).await?;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -134,4 +134,4 @@ components:
|
||||
type: number
|
||||
format: float
|
||||
|
||||
````
|
||||
````
|
||||
@@ -13,7 +13,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
<CardGroup cols={3}>
|
||||
<Card title="TypeScript Client" icon="github" href="https://github.com/Polymarket/clob-client-v2">
|
||||
<p className="font-mono text-[0.8rem]">
|
||||
npm install @polymarket/clob-client-v2
|
||||
npm install @polymarket/clob-client-v2 viem
|
||||
</p>
|
||||
</Card>
|
||||
|
||||
@@ -22,7 +22,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
</Card>
|
||||
|
||||
<Card title="Rust Client" icon="github" href="https://github.com/Polymarket/rs-clob-client-v2">
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket-client-sdk</p>
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket\_client\_sdk\_v2 --features clob</p>
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -51,9 +51,11 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers"; // v5.8.0
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY);
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
// Derive L2 API credentials
|
||||
const tempClient = new ClobClient({ host: "https://clob.polymarket.com", chain: 137, signer });
|
||||
@@ -61,21 +63,21 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
import os
|
||||
|
||||
private_key = os.getenv("PRIVATE_KEY")
|
||||
|
||||
# Derive L2 API credentials
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain=137)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
|
||||
api_creds = temp_client.create_or_derive_api_key()
|
||||
```
|
||||
|
||||
```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};
|
||||
use polymarket_client_sdk_v2::POLYGON;
|
||||
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
@@ -125,7 +127,7 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
client = ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
key=private_key,
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
creds=api_creds,
|
||||
signature_type=2, # GNOSIS_SAFE
|
||||
funder="0x..." # Your proxy wallet address
|
||||
@@ -133,7 +135,7 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::SignatureType;
|
||||
use polymarket_client_sdk_v2::clob::types::SignatureType;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
@@ -192,7 +194,7 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
</Card>
|
||||
|
||||
<Card title="Builder Methods" icon="hammer" href="/trading/clients/builder">
|
||||
Track attributed trades and manage builder credentials.
|
||||
Track orders and trades attributed to your builder code.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
<CardGroup cols={3}>
|
||||
<Card title="TypeScript Client" icon="github" href="https://github.com/Polymarket/clob-client-v2">
|
||||
<p className="font-mono text-[0.8rem]">
|
||||
npm install @polymarket/clob-client-v2
|
||||
npm install @polymarket/clob-client-v2 viem
|
||||
</p>
|
||||
</Card>
|
||||
|
||||
@@ -22,7 +22,7 @@ We recommend using the open-source SDK clients, which handle order signing, auth
|
||||
</Card>
|
||||
|
||||
<Card title="Rust Client" icon="github" href="https://github.com/Polymarket/rs-clob-client-v2">
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket-client-sdk</p>
|
||||
<p className="font-mono text-[0.8rem]">cargo add polymarket\_client\_sdk\_v2 --features clob</p>
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -51,9 +51,11 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
import { Wallet } from "ethers"; // v5.8.0
|
||||
import { createWalletClient, http } from "viem";
|
||||
import { privateKeyToAccount } from "viem/accounts";
|
||||
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY);
|
||||
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
||||
const signer = createWalletClient({ account, transport: http() });
|
||||
|
||||
// Derive L2 API credentials
|
||||
const tempClient = new ClobClient({ host: "https://clob.polymarket.com", chain: 137, signer });
|
||||
@@ -61,21 +63,21 @@ You use your private key once to derive **L2 credentials** (API key, secret, pas
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client.client import ClobClient
|
||||
from py_clob_client_v2 import ClobClient
|
||||
import os
|
||||
|
||||
private_key = os.getenv("PRIVATE_KEY")
|
||||
|
||||
# Derive L2 API credentials
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain=137)
|
||||
api_creds = temp_client.create_or_derive_api_creds()
|
||||
temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
|
||||
api_creds = temp_client.create_or_derive_api_key()
|
||||
```
|
||||
|
||||
```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};
|
||||
use polymarket_client_sdk_v2::POLYGON;
|
||||
use polymarket_client_sdk_v2::auth::{LocalSigner, Signer};
|
||||
use polymarket_client_sdk_v2::clob::{Client, Config};
|
||||
|
||||
let private_key = std::env::var("POLYMARKET_PRIVATE_KEY")?;
|
||||
let signer = LocalSigner::from_str(&private_key)?
|
||||
@@ -125,7 +127,7 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
client = ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
key=private_key,
|
||||
chain=137,
|
||||
chain_id=137,
|
||||
creds=api_creds,
|
||||
signature_type=2, # GNOSIS_SAFE
|
||||
funder="0x..." # Your proxy wallet address
|
||||
@@ -133,7 +135,7 @@ When initializing the trading client, you must specify your wallet's **signature
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk::clob::types::SignatureType;
|
||||
use polymarket_client_sdk_v2::clob::types::SignatureType;
|
||||
|
||||
let client = Client::new("https://clob.polymarket.com", Config::default())?
|
||||
.authentication_builder(&signer)
|
||||
@@ -192,7 +194,7 @@ If you're using the REST API directly (without the SDK), you need to attach auth
|
||||
</Card>
|
||||
|
||||
<Card title="Builder Methods" icon="hammer" href="/trading/clients/builder">
|
||||
Track attributed trades and manage builder credentials.
|
||||
Track orders and trades attributed to your builder code.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user