docs: refresh all documentation - fill 98 empty files and update changelog
Date: 2026-06-19 Changes: - Fixed 98 empty .md files that had failed to scrape - Updated changelog with latest entries (Jun 15, 2026: CLOB DELETE /orders limit reduced to 1000) - Refreshed FAQ, Polymarket Learn, Developers, and other sections Notable updates: - Jun 15, 2026: CLOB DELETE /orders maximum batch size reduced to 1000 - Jun 1, 2026: Increased CLOB order rate limits - May 18, 2026: builderCode added to builders endpoints - May 14, 2026: GET /markets/keyset limit reduced to 100
This commit is contained in:
@@ -0,0 +1,305 @@
|
||||
> ## Documentation Index
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# Builder Methods
|
||||
|
||||
> Methods for querying orders and trades attributed to your builder code.
|
||||
|
||||
## Overview
|
||||
|
||||
Builder attribution in V2 is handled natively through the order struct — you attach your **builder code** (a `bytes32` identifier from your [Builder Profile](https://polymarket.com/settings?tab=builder)) to every order you submit. No separate client configuration is required.
|
||||
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
|
||||
const client = new ClobClient({
|
||||
host: "https://clob.polymarket.com",
|
||||
chain: 137,
|
||||
signer,
|
||||
creds: apiCreds,
|
||||
signatureType,
|
||||
funderAddress,
|
||||
});
|
||||
|
||||
// Attach your builder code on every order
|
||||
const response = await client.createAndPostOrder(
|
||||
{
|
||||
tokenID: "0x...",
|
||||
price: 0.55,
|
||||
size: 100,
|
||||
side: Side.BUY,
|
||||
builderCode: process.env.POLY_BUILDER_CODE!,
|
||||
},
|
||||
{ tickSize: "0.01", negRisk: false },
|
||||
);
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
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_id=137,
|
||||
key=os.getenv("PRIVATE_KEY"),
|
||||
creds=creds,
|
||||
signature_type=signature_type,
|
||||
funder=funder,
|
||||
)
|
||||
|
||||
# Attach your builder code on every order
|
||||
response = client.create_and_post_order(
|
||||
OrderArgs(
|
||||
token_id="0x...",
|
||||
price=0.55,
|
||||
size=100,
|
||||
side=BUY,
|
||||
builder_code=os.environ["POLY_BUILDER_CODE"],
|
||||
),
|
||||
options=PartialCreateOrderOptions(tick_size="0.01", neg_risk=False),
|
||||
)
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Info>
|
||||
See [Order Attribution](/trading/orders/attribution) for the full attribution flow.
|
||||
</Info>
|
||||
|
||||
***
|
||||
|
||||
## Methods
|
||||
|
||||
***
|
||||
|
||||
### getOrder
|
||||
|
||||
Get details for a specific order by ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOrder(orderID: string): Promise<OpenOrder>
|
||||
```
|
||||
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
const order = await client.getOrder("0xb816482a...");
|
||||
console.log(order);
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
order = client.get_order("0xb816482a...")
|
||||
print(order)
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
***
|
||||
|
||||
### getOpenOrders
|
||||
|
||||
Get all open orders attributed to your builder code.
|
||||
|
||||
```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 client.getOpenOrders();
|
||||
|
||||
// Filtered by market
|
||||
const marketOrders = await client.getOpenOrders({
|
||||
market: "0xbd31dc8a...",
|
||||
});
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### getBuilderTrades
|
||||
|
||||
Retrieves all trades attributed to your builder code. Use this to track which trades were routed through your platform.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getBuilderTrades(
|
||||
params?: TradeParams,
|
||||
): Promise<BuilderTradesPaginatedResponse>
|
||||
```
|
||||
|
||||
**Params (`TradeParams`)**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
Optional. Filter trades by trade ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_address" type="string">
|
||||
Optional. Filter trades by maker address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
Optional. Filter trades by market condition ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
Optional. Filter trades by asset (token) ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="before" type="string">
|
||||
Optional. Return trades created before this cursor value.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="after" type="string">
|
||||
Optional. Return trades created after this cursor value.
|
||||
</ResponseField>
|
||||
|
||||
**Response (`BuilderTradesPaginatedResponse`)**
|
||||
|
||||
<ResponseField name="trades" type="BuilderTrade[]">
|
||||
Array of trades attributed to the builder account.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="next_cursor" type="string">
|
||||
Cursor string for fetching the next page of results.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="limit" type="number">
|
||||
Maximum number of trades returned per page.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="count" type="number">
|
||||
Total number of trades returned in this response.
|
||||
</ResponseField>
|
||||
|
||||
**`BuilderTrade` fields**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
Unique identifier for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tradeType" type="string">
|
||||
Type of the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takerOrderHash" type="string">
|
||||
Hash of the taker order associated with this trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="builder" type="string">
|
||||
Builder code attributed to this trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
Condition ID of the market this trade belongs to.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="assetId" type="string">
|
||||
Token ID of the asset traded.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="string">
|
||||
Side of the trade (e.g. BUY or SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size" type="string">
|
||||
Size of the trade in shares.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="sizeUsdc" type="string">
|
||||
Size of the trade denominated in USDC.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
Price at which the trade was executed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
Current status of the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcome" type="string">
|
||||
Outcome label associated with the traded asset.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcomeIndex" type="number">
|
||||
Index of the outcome within the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="owner" type="string">
|
||||
Address of the order owner (taker).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker" type="string">
|
||||
Address of the maker in the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transactionHash" type="string">
|
||||
On-chain transaction hash for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="matchTime" type="string">
|
||||
Timestamp when the trade was matched.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="bucketIndex" type="number">
|
||||
Bucket index used for trade grouping.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="fee" type="string">
|
||||
Fee charged for the trade in shares.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="feeUsdc" type="string">
|
||||
Fee charged for the trade denominated in USDC.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="err_msg" type="string | null">
|
||||
Optional. Error message if the trade encountered an issue, otherwise null.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="createdAt" type="string | null">
|
||||
Timestamp when the trade record was created, or null if unavailable.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="updatedAt" type="string | null">
|
||||
Timestamp when the trade record was last updated, or null if unavailable.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## See Also
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Builders Program" icon="hammer" href="/builders/overview">
|
||||
Learn about the Builders Program and its benefits.
|
||||
</Card>
|
||||
|
||||
<Card title="Order Attribution" icon="key" href="/trading/orders/attribution">
|
||||
Attach your builder code to orders for volume credit.
|
||||
</Card>
|
||||
|
||||
<Card title="L2 Methods" icon="lock" href="/trading/clients/l2">
|
||||
Place and manage orders with API credentials.
|
||||
</Card>
|
||||
|
||||
<Card title="Gasless Transactions" icon="gas-pump" href="/trading/gasless">
|
||||
Execute onchain operations without paying gas.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
> ## Documentation Index
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# L1 Methods
|
||||
|
||||
> These methods require a wallet signer (private key) but do not require user API credentials. Use these for initial setup.
|
||||
|
||||
## Client Initialization
|
||||
|
||||
L1 methods require the client to initialize with a signer.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
import { ClobClient } 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, // Signer required for L1 methods
|
||||
});
|
||||
|
||||
// Ready to create user API credentials
|
||||
const apiKey = await client.createApiKey();
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client_v2 import ClobClient
|
||||
import os
|
||||
|
||||
private_key = os.getenv("PRIVATE_KEY")
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain_id=137,
|
||||
key=private_key # Signer required for L1 methods
|
||||
)
|
||||
|
||||
# Ready to create user API credentials
|
||||
api_key = client.create_api_key()
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Warning>
|
||||
Never commit private keys to version control. Always use environment variables
|
||||
or a secure key management system.
|
||||
</Warning>
|
||||
|
||||
***
|
||||
|
||||
## API Key Management
|
||||
|
||||
***
|
||||
|
||||
### createApiKey
|
||||
|
||||
Creates a new API key (L2 credentials) for the wallet signer.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
```
|
||||
|
||||
<ResponseField name="nonce" type="number">
|
||||
Optional custom nonce for deterministic key generation. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="apiKey" type="string">
|
||||
The generated API key string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="secret" type="string">
|
||||
The secret associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="passphrase" type="string">
|
||||
The passphrase associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### 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.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async deriveApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
```
|
||||
|
||||
<ResponseField name="nonce" type="number">
|
||||
The nonce used when originally creating the key. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="apiKey" type="string">
|
||||
The derived API key string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="secret" type="string">
|
||||
The secret associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="passphrase" type="string">
|
||||
The passphrase associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### 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.**
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createOrDeriveApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
```
|
||||
|
||||
<ResponseField name="apiKey" type="string">
|
||||
The API key string, either derived or newly created.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="secret" type="string">
|
||||
The secret associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="passphrase" type="string">
|
||||
The passphrase associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## 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).
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createOrder(
|
||||
userOrder: UserOrder,
|
||||
options?: Partial<CreateOrderOptions>
|
||||
): Promise<SignedOrder>
|
||||
```
|
||||
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the market outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="number">
|
||||
The limit price for the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size" type="number">
|
||||
The size (number of shares) for the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order (buy or sell).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="number">
|
||||
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">
|
||||
The tick size used for order validation (CreateOrderOptions).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="negRisk" type="boolean">
|
||||
Optional flag for negative risk markets (CreateOrderOptions). Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="salt" type="string">
|
||||
A random salt value for the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker" type="string">
|
||||
The maker's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signer" type="string">
|
||||
The signer's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tokenId" type="string">
|
||||
The token ID in the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makerAmount" type="string">
|
||||
The maker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takerAmount" type="string">
|
||||
The taker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="number">
|
||||
The side of the order as a number (0 = BUY, 1 = SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="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">
|
||||
The type identifier for the signature scheme used.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signature" type="string">
|
||||
The cryptographic signature of the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### 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).
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createMarketOrder(
|
||||
userMarketOrder: UserMarketOrder,
|
||||
options?: Partial<CreateOrderOptions>
|
||||
): Promise<SignedOrder>
|
||||
```
|
||||
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the market outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="amount" type="number">
|
||||
The order amount. For BUY orders this is a dollar amount; for SELL orders this
|
||||
is the number of shares.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order (buy or sell).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="number">
|
||||
Optional price limit for the market order. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderType" type="OrderType.FOK | OrderType.FAK">
|
||||
Optional order type, either FOK (Fill-Or-Kill) or FAK (Fill-And-Kill).
|
||||
Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="salt" type="string">
|
||||
A random salt value for the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker" type="string">
|
||||
The maker's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signer" type="string">
|
||||
The signer's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tokenId" type="string">
|
||||
The token ID in the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makerAmount" type="string">
|
||||
The maker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takerAmount" type="string">
|
||||
The taker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="number">
|
||||
The side of the order as a number (0 = BUY, 1 = SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="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">
|
||||
The type identifier for the signature scheme used.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signature" type="string">
|
||||
The cryptographic signature of the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Error - INVALID_SIGNATURE">
|
||||
Your wallet's private key is incorrect or improperly formatted.
|
||||
|
||||
**Solution:**
|
||||
|
||||
* Verify your private key is a valid hex string (starts with `0x`)
|
||||
* Ensure you're using the correct key for the intended address
|
||||
* Check that the key has proper permissions
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Error - NONCE_ALREADY_USED">
|
||||
The nonce you provided has already been used to create an API key.
|
||||
|
||||
**Solution:**
|
||||
|
||||
* Use `deriveApiKey()` with the same nonce to retrieve existing credentials
|
||||
* Or use a different nonce with `createApiKey()`
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Error - Invalid Funder Address">
|
||||
Your funder address is incorrect or doesn't match your wallet.
|
||||
|
||||
**Solution:** New API users should use the deposit wallet address as the
|
||||
funder with signature type `3`. Existing Safe and Proxy users should use
|
||||
their current smart-wallet address.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Lost API credentials but have nonce">
|
||||
Use `deriveApiKey()` with the original nonce:
|
||||
|
||||
```typescript theme={null}
|
||||
const recovered = await client.deriveApiKey(originalNonce);
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Lost both credentials and nonce">
|
||||
There's no way to recover lost credentials without the nonce. Create new ones:
|
||||
|
||||
```typescript theme={null}
|
||||
// Create fresh credentials with a new nonce
|
||||
const newCreds = await client.createApiKey();
|
||||
// Save the nonce this time!
|
||||
```
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
***
|
||||
|
||||
## See Also
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Authentication" icon="shield" href="/api-reference/authentication">
|
||||
Deep dive into L1 and L2 authentication.
|
||||
</Card>
|
||||
|
||||
<Card title="Trading Quickstart" icon="bolt" href="/trading/quickstart">
|
||||
Initialize the client and place your first order.
|
||||
</Card>
|
||||
|
||||
<Card title="Public Methods" icon="globe" href="/trading/clients/public">
|
||||
Access market data, orderbooks, and prices without auth.
|
||||
</Card>
|
||||
|
||||
<Card title="L2 Methods" icon="lock" href="/trading/clients/l2">
|
||||
Place and manage orders with API credentials.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -0,0 +1,752 @@
|
||||
> ## Documentation Index
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# L2 Methods
|
||||
|
||||
> These methods require user API credentials (L2 headers). Use these for placing trades and managing your positions.
|
||||
|
||||
## Client Initialization
|
||||
|
||||
L2 methods require the client to initialize with a signer, signature type, API credentials, and funder address.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
import { ClobClient } 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 apiCreds = {
|
||||
key: process.env.API_KEY,
|
||||
secret: process.env.SECRET,
|
||||
passphrase: process.env.PASSPHRASE,
|
||||
};
|
||||
const depositWalletAddress = process.env.DEPOSIT_WALLET_ADDRESS!;
|
||||
|
||||
const client = new ClobClient({
|
||||
host: "https://clob.polymarket.com",
|
||||
chain: 137,
|
||||
signer,
|
||||
creds: apiCreds,
|
||||
signatureType: 3, // POLY_1271
|
||||
funderAddress: depositWalletAddress,
|
||||
});
|
||||
|
||||
// Ready to send authenticated requests
|
||||
const order = await client.postOrder(signedOrder);
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client_v2 import ClobClient
|
||||
from py_clob_client_v2 import ApiCreds
|
||||
import os
|
||||
|
||||
api_creds = ApiCreds(
|
||||
api_key=os.getenv("API_KEY"),
|
||||
api_secret=os.getenv("SECRET"),
|
||||
api_passphrase=os.getenv("PASSPHRASE")
|
||||
)
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain_id=137,
|
||||
key=os.getenv("PRIVATE_KEY"),
|
||||
creds=api_creds,
|
||||
signature_type=3, # POLY_1271
|
||||
funder=os.getenv("DEPOSIT_WALLET_ADDRESS")
|
||||
)
|
||||
|
||||
# Ready to send authenticated requests
|
||||
order = client.post_order(signed_order)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
***
|
||||
|
||||
## Order Creation and Management
|
||||
|
||||
***
|
||||
|
||||
### 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.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createAndPostOrder(
|
||||
userOrder: UserOrder,
|
||||
options?: Partial<CreateOrderOptions>,
|
||||
orderType?: OrderType.GTC | OrderType.GTD, // Defaults to GTC
|
||||
): Promise<OrderResponse>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="number">
|
||||
The limit price for the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size" type="number">
|
||||
The size of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order (buy or sell).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="number">
|
||||
Optional expiration timestamp for the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tickSize" type="TickSize">
|
||||
Tick size for the order. One of `"0.1"`, `"0.01"`, `"0.001"`, `"0.0001"`.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="negRisk" type="boolean">
|
||||
Optional. Whether the market uses negative risk.
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="success" type="boolean">
|
||||
Whether the order was successfully placed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="errorMsg" type="string">
|
||||
Error message if the order was not successful.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderID" type="string">
|
||||
The ID of the placed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transactionsHashes" type="string[]">
|
||||
Array of transaction hashes associated with the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takingAmount" type="string">
|
||||
The amount being taken in the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makingAmount" type="string">
|
||||
The amount being made in the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### 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.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createAndPostMarketOrder(
|
||||
userMarketOrder: UserMarketOrder,
|
||||
options?: Partial<CreateOrderOptions>,
|
||||
orderType?: OrderType.FOK | OrderType.FAK, // Defaults to FOK
|
||||
): Promise<OrderResponse>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="amount" type="number">
|
||||
The amount for the market order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order (buy or sell).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="number">
|
||||
Optional price hint for the market order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderType" type="OrderType.FOK | OrderType.FAK">
|
||||
Optional order type override. Defaults to FOK.
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="success" type="boolean">
|
||||
Whether the order was successfully placed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="errorMsg" type="string">
|
||||
Error message if the order was not successful.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderID" type="string">
|
||||
The ID of the placed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transactionsHashes" type="string[]">
|
||||
Array of transaction hashes associated with the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takingAmount" type="string">
|
||||
The amount being taken in the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makingAmount" type="string">
|
||||
The amount being made in the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### 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.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async postOrder(
|
||||
order: SignedOrder,
|
||||
orderType?: OrderType, // Defaults to GTC
|
||||
postOnly?: boolean, // Defaults to false
|
||||
): Promise<OrderResponse>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### postOrders
|
||||
|
||||
Posts up to 15 pre-signed orders in a single batch.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async postOrders(
|
||||
args: PostOrdersArgs[],
|
||||
): Promise<OrderResponse[]>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="order" type="SignedOrder">
|
||||
The pre-signed order to post.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderType" type="OrderType">
|
||||
The order type (e.g. GTC, FOK, FAK).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="postOnly" type="boolean">
|
||||
Optional. Whether to post the order as post-only. Defaults to false.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### cancelOrder
|
||||
|
||||
Cancels a single open order.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async cancelOrder(orderID: string): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="canceled" type="string[]">
|
||||
Array of order IDs that were successfully canceled.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="not_canceled" type="Record<string, any>">
|
||||
Map of order IDs to reasons why they could not be canceled.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### cancelOrders
|
||||
|
||||
Cancels multiple orders in a single batch.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async cancelOrders(orderIDs: string[]): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### cancelAll
|
||||
|
||||
Cancels all open orders.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async cancelAll(): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### cancelMarketOrders
|
||||
|
||||
Cancels all open orders for a specific market.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async cancelMarketOrders(
|
||||
payload: OrderMarketCancelParams
|
||||
): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
Optional. The market condition ID to cancel orders for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
Optional. The token ID to cancel orders for.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## Order and Trade Queries
|
||||
|
||||
***
|
||||
|
||||
### getOrder
|
||||
|
||||
Get details for a specific order by ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOrder(orderID: string): Promise<OpenOrder>
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
The unique order ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="owner" type="string">
|
||||
The API key of the order owner.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_address" type="string">
|
||||
The on-chain address of the order maker.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
The market condition ID the order belongs to.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
The token ID the order is for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="string">
|
||||
The side of the order (BUY or SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="original_size" type="string">
|
||||
The original size of the order when it was placed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size_matched" type="string">
|
||||
The amount of the order that has been matched so far.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The limit price of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="associate_trades" type="string[]">
|
||||
Array of trade IDs associated with this order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcome" type="string">
|
||||
The outcome label for the order's token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="created_at" type="number">
|
||||
Unix timestamp of when the order was created.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="string">
|
||||
The expiration time of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="order_type" type="string">
|
||||
The order type (e.g. GTC, FOK, FAK, GTD).
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getOpenOrders
|
||||
|
||||
Get all your open orders.
|
||||
|
||||
```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>
|
||||
|
||||
***
|
||||
|
||||
### getTrades
|
||||
|
||||
Get your trade history (filled orders).
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getTrades(
|
||||
params?: TradeParams,
|
||||
only_first_page?: boolean,
|
||||
): Promise<Trade[]>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
Optional. Filter by trade ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_address" type="string">
|
||||
Optional. Filter by maker address.
|
||||
</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>
|
||||
|
||||
<ResponseField name="before" type="string">
|
||||
Optional. Return trades before this timestamp.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="after" type="string">
|
||||
Optional. Return trades after this timestamp.
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
The unique trade ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker_order_id" type="string">
|
||||
The order ID of the taker side.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
The market condition ID for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
The token ID for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the trade (BUY or SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size" type="string">
|
||||
The size of the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="fee_rate_bps" type="string">
|
||||
The fee rate in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The price at which the trade was matched.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="match_time" type="string">
|
||||
The time at which the trade was matched.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="last_update" type="string">
|
||||
The time of the last update to this trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcome" type="string">
|
||||
The outcome label for the traded token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="bucket_index" type="number">
|
||||
The bucket index for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="owner" type="string">
|
||||
The API key of the trade owner.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_address" type="string">
|
||||
The on-chain address of the maker.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders" type="MakerOrder[]">
|
||||
Array of maker order objects that participated in this trade. Each
|
||||
`MakerOrder` contains the following fields:
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].order_id" type="string">
|
||||
The maker order ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].owner" type="string">
|
||||
The API key of the maker order owner.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].maker_address" type="string">
|
||||
The on-chain address of the maker order maker.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].matched_amount" type="string">
|
||||
The amount matched for this maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].price" type="string">
|
||||
The price of the maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].fee_rate_bps" type="string">
|
||||
The fee rate in basis points for the maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].asset_id" type="string">
|
||||
The token ID for the maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].outcome" type="string">
|
||||
The outcome label for the maker order's token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].side" type="Side">
|
||||
The side of the maker order (BUY or SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transaction_hash" type="string">
|
||||
The on-chain transaction hash for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="trader_side" type=""TAKER" | "MAKER"">
|
||||
Whether the authenticated user is the taker or a maker in this trade.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getTradesPaginated
|
||||
|
||||
Get trade history with pagination for large result sets.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getTradesPaginated(
|
||||
params?: TradeParams,
|
||||
): Promise<TradesPaginatedResponse>
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="trades" type="Trade[]">
|
||||
Array of trade objects for the current page.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="limit" type="number">
|
||||
The maximum number of trades returned per page.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="count" type="number">
|
||||
The total number of trades matching the query.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## Balance and Allowances
|
||||
|
||||
***
|
||||
|
||||
### getBalanceAllowance
|
||||
|
||||
Get your balance and allowance for specific tokens.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getBalanceAllowance(
|
||||
params?: BalanceAllowanceParams
|
||||
): Promise<BalanceAllowanceResponse>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="asset_type" type="AssetType">
|
||||
The type of asset to query. One of `"COLLATERAL"` or `"CONDITIONAL"`.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="token_id" type="string">
|
||||
Optional. The token ID to query (required when `asset_type` is `CONDITIONAL`).
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="balance" type="string">
|
||||
The current balance for the specified asset.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="allowance" type="string">
|
||||
The current allowance for the specified asset.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### updateBalanceAllowance
|
||||
|
||||
Updates the cached balance and allowance for specific tokens.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async updateBalanceAllowance(
|
||||
params?: BalanceAllowanceParams
|
||||
): Promise<void>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## API Key Management
|
||||
|
||||
***
|
||||
|
||||
### getApiKeys
|
||||
|
||||
Get all API keys associated with your account.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getApiKeys(): Promise<ApiKeysResponse>
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="apiKeys" type="ApiKeyCreds[]">
|
||||
Array of API key credential objects associated with the account.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### deleteApiKey
|
||||
|
||||
Deletes (revokes) the currently authenticated API key.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async deleteApiKey(): Promise<any>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Notifications
|
||||
|
||||
***
|
||||
|
||||
### getNotifications
|
||||
|
||||
Retrieves all event notifications for the authenticated user. Records are automatically removed after 48 hours.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getNotifications(): Promise<Notification[]>
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="id" type="number">
|
||||
Unique notification ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="owner" type="string">
|
||||
The user's API key, or an empty string for global notifications.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="payload" type="any">
|
||||
Type-specific payload data for the notification.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="timestamp" type="number">
|
||||
Optional Unix timestamp of when the notification was created.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="type" type="number">
|
||||
Notification type (see below).
|
||||
</ResponseField>
|
||||
|
||||
| Name | Value | Description |
|
||||
| ------------------ | ----- | ---------------------------------------- |
|
||||
| Order Cancellation | `1` | User's order was canceled |
|
||||
| Order Fill | `2` | User's order was filled (maker or taker) |
|
||||
| Market Resolved | `4` | Market was resolved |
|
||||
|
||||
***
|
||||
|
||||
### dropNotifications
|
||||
|
||||
Mark notifications as read/dismissed.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async dropNotifications(params?: DropNotificationParams): Promise<void>
|
||||
```
|
||||
|
||||
**Params**
|
||||
|
||||
<ResponseField name="ids" type="string[]">
|
||||
Array of notification IDs to dismiss.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## See Also
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Authentication" icon="shield" href="/api-reference/authentication">
|
||||
Deep dive into L1 and L2 authentication.
|
||||
</Card>
|
||||
|
||||
<Card title="L1 Methods" icon="key" href="/trading/clients/l1">
|
||||
Sign orders and derive API credentials with your private key.
|
||||
</Card>
|
||||
|
||||
<Card title="Public Methods" icon="globe" href="/trading/clients/public">
|
||||
Read market data and orderbooks without auth.
|
||||
</Card>
|
||||
|
||||
<Card title="WebSocket" icon="bolt" href="/market-data/websocket/overview">
|
||||
Real-time market data streaming.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
> ## Documentation Index
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# Clients & SDKs
|
||||
|
||||
> Official open-source libraries for interacting with Polymarket
|
||||
|
||||
Polymarket provides official open-source clients in TypeScript, Python, and Rust. All three support the full CLOB API including market data, order management, and authentication.
|
||||
|
||||
## Installation
|
||||
|
||||
<CodeGroup>
|
||||
```bash TypeScript theme={null}
|
||||
npm install @polymarket/clob-client-v2 viem
|
||||
```
|
||||
|
||||
```bash Python theme={null}
|
||||
pip install py-clob-client-v2
|
||||
```
|
||||
|
||||
```bash Rust theme={null}
|
||||
cargo add polymarket_client_sdk_v2 --features clob
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Quick Example
|
||||
|
||||
<CodeGroup>
|
||||
```typescript TypeScript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
|
||||
const client = new ClobClient({
|
||||
host: "https://clob.polymarket.com",
|
||||
chain: 137,
|
||||
signer,
|
||||
creds: apiCreds,
|
||||
});
|
||||
|
||||
const markets = await client.getMarkets();
|
||||
```
|
||||
|
||||
```python Python theme={null}
|
||||
from py_clob_client_v2 import ClobClient
|
||||
|
||||
client = ClobClient(
|
||||
"https://clob.polymarket.com",
|
||||
key=private_key,
|
||||
chain_id=137,
|
||||
creds=api_creds,
|
||||
)
|
||||
|
||||
markets = client.get_markets()
|
||||
```
|
||||
|
||||
```rust Rust theme={null}
|
||||
use polymarket_client_sdk_v2::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
|
||||
|
||||
| Language | Package | Repository |
|
||||
| ---------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
|
||||
| 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_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.
|
||||
|
||||
## Relayer SDK
|
||||
|
||||
For [gasless transactions](/trading/gasless), the relayer client handles deposit
|
||||
wallet creation and signed wallet batches for new API users. Existing Safe and
|
||||
Proxy wallet flows remain supported.
|
||||
|
||||
| Language | Package | Repository |
|
||||
| ---------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
|
||||
| TypeScript | `@polymarket/builder-relayer-client` | [github.com/Polymarket/builder-relayer-client](https://github.com/Polymarket/builder-relayer-client) |
|
||||
| Python | `py-builder-relayer-client` | [github.com/Polymarket/py-builder-relayer-client](https://github.com/Polymarket/py-builder-relayer-client) |
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Quickstart" icon="rocket" href="/quickstart">
|
||||
Set up your client and place your first order.
|
||||
</Card>
|
||||
|
||||
<Card title="Authentication" icon="lock" href="/api-reference/authentication">
|
||||
Understand L1/L2 auth and API credentials.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
@@ -0,0 +1,748 @@
|
||||
> ## Documentation Index
|
||||
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
|
||||
> Use this file to discover all available pages before exploring further.
|
||||
|
||||
# Public Methods
|
||||
|
||||
> These methods can be called without a signer or user credentials. Use these for reading market data, prices, and order books.
|
||||
|
||||
## Client Initialization
|
||||
|
||||
Public methods require the client to initialize with the host URL and Polygon chain ID.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
```typescript theme={null}
|
||||
import { ClobClient } from "@polymarket/clob-client-v2";
|
||||
|
||||
const client = new ClobClient({
|
||||
host: "https://clob.polymarket.com",
|
||||
chain: 137,
|
||||
});
|
||||
|
||||
// Ready to call public methods
|
||||
const markets = await client.getMarkets();
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab title="Python">
|
||||
```python theme={null}
|
||||
from py_clob_client_v2 import ClobClient
|
||||
|
||||
client = ClobClient(
|
||||
host="https://clob.polymarket.com",
|
||||
chain_id=137
|
||||
)
|
||||
|
||||
# Ready to call public methods
|
||||
markets = client.get_markets()
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
***
|
||||
|
||||
## Health Check
|
||||
|
||||
***
|
||||
|
||||
### getOk
|
||||
|
||||
Health check endpoint to verify the CLOB service is operational.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOk(): Promise<any>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Markets
|
||||
|
||||
***
|
||||
|
||||
### getMarket
|
||||
|
||||
Get details for a single market by condition ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getMarket(conditionId: string): Promise<Market>
|
||||
```
|
||||
|
||||
<ResponseField name="accepting_order_timestamp" type="string">
|
||||
Timestamp from which the market started accepting orders, or null if not set.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="accepting_orders" type="boolean">
|
||||
Whether the market is currently accepting orders.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="active" type="boolean">
|
||||
Whether the market is active.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="archived" type="boolean">
|
||||
Whether the market has been archived.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="closed" type="boolean">
|
||||
Whether the market is closed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="condition_id" type="string">
|
||||
The unique condition ID for the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="description" type="string">
|
||||
Human-readable description of the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="enable_order_book" type="boolean">
|
||||
Whether the order book is enabled for this market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="end_date_iso" type="string">
|
||||
ISO 8601 end date of the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="fpmm" type="string">
|
||||
Address of the Fixed Product Market Maker contract.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="game_start_time" type="string">
|
||||
Start time of the underlying game or event.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="icon" type="string">
|
||||
URL of the market icon image.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="image" type="string">
|
||||
URL of the market image.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="is_50_50_outcome" type="boolean">
|
||||
Whether the market has equal 50/50 outcomes.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_base_fee" type="number">
|
||||
Base fee charged to makers in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market_slug" type="string">
|
||||
URL-friendly slug identifier for the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="minimum_order_size" type="number">
|
||||
Minimum order size allowed in this market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="minimum_tick_size" type="number">
|
||||
Minimum price increment allowed in this market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="neg_risk" type="boolean">
|
||||
Whether the market uses negative risk (binary complementary tokens).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="neg_risk_market_id" type="string">
|
||||
Negative risk market identifier, if applicable.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="neg_risk_request_id" type="string">
|
||||
Negative risk request identifier, if applicable.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="notifications_enabled" type="boolean">
|
||||
Whether notifications are enabled for this market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="question" type="string">
|
||||
The market question text.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="question_id" type="string">
|
||||
Unique identifier for the market question.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="rewards" type="object">
|
||||
Object containing reward config: `max_spread` (number), `min_size` (number), `rates` (any)
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="seconds_delay" type="number">
|
||||
Delay in seconds before orders are processed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tags" type="string[]">
|
||||
List of tags associated with the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker_base_fee" type="number">
|
||||
Base fee charged to takers in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tokens" type="MarketToken[]">
|
||||
Array of market tokens, each containing `outcome` (string), `price` (number), `token_id` (string), and `winner` (boolean).
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getMarkets
|
||||
|
||||
Get details for multiple markets paginated.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getMarkets(): Promise<PaginationPayload>
|
||||
```
|
||||
|
||||
<ResponseField name="limit" type="number">
|
||||
Maximum number of results per page.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="count" type="number">
|
||||
Total number of markets returned.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="data" type="Market[]">
|
||||
Array of Market objects. See `getMarket()` for the full Market structure.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getSimplifiedMarkets
|
||||
|
||||
Get simplified market data paginated for faster loading.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getSimplifiedMarkets(): Promise<PaginationPayload>
|
||||
```
|
||||
|
||||
<ResponseField name="limit" type="number">
|
||||
Maximum number of results per page.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="count" type="number">
|
||||
Total number of markets returned.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="data" type="SimplifiedMarket[]">
|
||||
Array of simplified market objects, each containing `accepting_orders` (boolean), `active` (boolean), `archived` (boolean), `closed` (boolean), `condition_id` (string), `rewards` (object with `rates`, `min_size`, `max_spread`), and `tokens` (SimplifiedToken\[]) with `outcome` (string), `price` (number), `token_id` (string).
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getSamplingMarkets
|
||||
|
||||
Get markets eligible for sampling/liquidity rewards.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getSamplingMarkets(): Promise<PaginationPayload>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### getSamplingSimplifiedMarkets
|
||||
|
||||
Get simplified market data for markets eligible for sampling/liquidity rewards.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getSamplingSimplifiedMarkets(): Promise<PaginationPayload>
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## Order Books and Prices
|
||||
|
||||
***
|
||||
|
||||
### calculateMarketPrice
|
||||
|
||||
Calculate the estimated price for a market order of a given size.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async calculateMarketPrice(
|
||||
tokenID: string,
|
||||
side: Side,
|
||||
amount: number,
|
||||
orderType: OrderType = OrderType.FOK
|
||||
): Promise<number>
|
||||
```
|
||||
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID to calculate the market price for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order. One of: `BUY`, `SELL`
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="amount" type="number">
|
||||
The size of the order to calculate price for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderType" type="OrderType">
|
||||
The order type. One of: `GTC` (Good Till Cancelled), `FOK` (Fill or Kill), `GTD` (Good Till Date), `FAK` (Fill and Kill). Defaults to `FOK`.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="returns" type="number">
|
||||
The calculated estimated market price for the given order size.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getOrderBook
|
||||
|
||||
Get the order book for a specific token ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOrderBook(tokenID: string): Promise<OrderBookSummary>
|
||||
```
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
The market condition ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
The token/asset ID for this order book.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="timestamp" type="string">
|
||||
Timestamp of the order book snapshot.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="bids" type="OrderSummary[]">
|
||||
Array of bid entries, each with `price` (string) and `size` (string).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asks" type="OrderSummary[]">
|
||||
Array of ask entries, each with `price` (string) and `size` (string).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="min_order_size" type="string">
|
||||
Minimum order size for this market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tick_size" type="string">
|
||||
Minimum price increment for this market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="neg_risk" type="boolean">
|
||||
Whether the market uses negative risk.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="hash" type="string">
|
||||
Hash of the order book state.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getOrderBooks
|
||||
|
||||
Get order books for multiple token IDs.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOrderBooks(params: BookParams[]): Promise<OrderBookSummary[]>
|
||||
```
|
||||
|
||||
<ResponseField name="token_id" type="string">
|
||||
The token ID to fetch the order book for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the book to query. One of: `BUY`, `SELL`
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="returns" type="OrderBookSummary[]">
|
||||
Array of OrderBookSummary objects. See `getOrderBook()` for the full structure.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getPrice
|
||||
|
||||
Get the current best price for buying or selling a token ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getPrice(
|
||||
tokenID: string,
|
||||
side: "BUY" | "SELL"
|
||||
): Promise<any>
|
||||
```
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The current best price for the requested side.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getPrices
|
||||
|
||||
Get the current best prices for multiple token IDs.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getPrices(params: BookParams[]): Promise<PricesResponse>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="PricesResponse">
|
||||
A map of token IDs to their prices. Each entry contains an optional `BUY` (string) and/or `SELL` (string) price.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getMidpoint
|
||||
|
||||
Get the midpoint price (average of best bid and best ask) for a token ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getMidpoint(tokenID: string): Promise<any>
|
||||
```
|
||||
|
||||
<ResponseField name="mid" type="string">
|
||||
The midpoint price, calculated as the average of best bid and best ask.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getMidpoints
|
||||
|
||||
Get the midpoint prices for multiple token IDs.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getMidpoints(params: BookParams[]): Promise<any>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="object">
|
||||
A map of token IDs to their midpoint price strings. Each key is a token ID and its value is the midpoint price as a string.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getSpread
|
||||
|
||||
Get the spread (difference between best ask and best bid) for a token ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getSpread(tokenID: string): Promise<SpreadResponse>
|
||||
```
|
||||
|
||||
<ResponseField name="spread" type="string">
|
||||
The spread value, calculated as the difference between best ask and best bid.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getSpreads
|
||||
|
||||
Get the spreads for multiple token IDs.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getSpreads(params: BookParams[]): Promise<SpreadsResponse>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="object">
|
||||
A map of token IDs to their spread strings. Each key is a token ID and its value is the spread as a string.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getPricesHistory
|
||||
|
||||
Get historical price data for a token.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getPricesHistory(params: PriceHistoryFilterParams): Promise<MarketPrice[]>
|
||||
```
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
The token ID to fetch price history for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="startTs" type="number">
|
||||
Optional start timestamp (Unix seconds) for the price history range.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="endTs" type="number">
|
||||
Optional end timestamp (Unix seconds) for the price history range.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="fidelity" type="number">
|
||||
Optional fidelity/resolution of the price history data.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="interval" type="PriceHistoryInterval">
|
||||
Time interval for the price history. One of: `max`, `1w`, `1d`, `6h`, `1h`
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="t" type="number">
|
||||
Unix timestamp of the price data point.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="p" type="number">
|
||||
Price value at the corresponding timestamp.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## Trades
|
||||
|
||||
***
|
||||
|
||||
### getLastTradePrice
|
||||
|
||||
Get the price of the most recent trade for a token.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getLastTradePrice(tokenID: string): Promise<LastTradePrice>
|
||||
```
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The price of the most recent trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="string">
|
||||
The side of the most recent trade.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getLastTradesPrices
|
||||
|
||||
Get the most recent trade prices for multiple tokens.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getLastTradesPrices(params: BookParams[]): Promise<LastTradePriceWithToken[]>
|
||||
```
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The price of the most recent trade for the token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="string">
|
||||
The side of the most recent trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="token_id" type="string">
|
||||
The token ID this trade price corresponds to.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getMarketTradesEvents
|
||||
|
||||
Get recent trade events for a market.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getMarketTradesEvents(conditionID: string): Promise<MarketTradeEvent[]>
|
||||
```
|
||||
|
||||
<ResponseField name="event_type" type="string">
|
||||
The type of trade event.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="object">
|
||||
Object containing market info: `condition_id` (string), `asset_id` (string), `question` (string), `icon` (string), `slug` (string).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="user" type="object">
|
||||
Object containing user info: `address` (string), `username` (string), `profile_picture` (string), `optimized_profile_picture` (string), `pseudonym` (string).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the trade. One of: `BUY`, `SELL`
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size" type="string">
|
||||
The size of the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="fee_rate_bps" type="string">
|
||||
The fee rate in basis points for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The price at which the trade was executed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcome" type="string">
|
||||
The outcome label for the traded token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcome_index" type="number">
|
||||
The index of the outcome in the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transaction_hash" type="string">
|
||||
The on-chain transaction hash for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="timestamp" type="string">
|
||||
The timestamp of when the trade event occurred.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## Market Parameters
|
||||
|
||||
***
|
||||
|
||||
### getClobMarketInfo
|
||||
|
||||
Fetch all CLOB-level parameters for a market in a single call — tokens, tick size, base fees, rewards config, RFQ status, and fee details.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getClobMarketInfo(conditionID: string): Promise<ClobMarketDetails>
|
||||
```
|
||||
|
||||
<ResponseField name="conditionID" type="string">
|
||||
The condition ID of the market.
|
||||
</ResponseField>
|
||||
|
||||
**Response (`ClobMarketDetails`)**
|
||||
|
||||
<ResponseField name="gst" type="string | null">
|
||||
Game start time (used for sports markets), ISO 8601 timestamp or `null`.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="r" type="object">
|
||||
Rewards configuration for the market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="t" type="ClobToken[]">
|
||||
Tokens for this market. Each entry has:
|
||||
|
||||
* `t` (string) — token ID
|
||||
* `o` (string) — outcome label (e.g. `Yes`, `No`)
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="mos" type="number">
|
||||
Minimum order size.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="mts" type="number">
|
||||
Minimum tick size (price increment).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="mbf" type="number">
|
||||
Maker base fee in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tbf" type="number">
|
||||
Taker base fee in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="rfqe" type="boolean">
|
||||
Whether RFQ (Request for Quote) is enabled for this market.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="itode" type="boolean">
|
||||
Whether taker order delay is enabled.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="ibce" type="boolean">
|
||||
Whether Blockaid check is enabled.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="fd" type="object">
|
||||
Fee curve parameters:
|
||||
|
||||
* `r` (number) — fee rate
|
||||
* `e` (number) — fee curve exponent
|
||||
* `to` (boolean) — whether fees apply to takers only
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="oas" type="number">
|
||||
Minimum order age in seconds.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getFeeRateBps
|
||||
|
||||
Get the fee rate in basis points for a token.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getFeeRateBps(tokenID: string): Promise<number>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="number">
|
||||
The fee rate in basis points for the specified token.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getFeeExponent
|
||||
|
||||
Get the fee curve exponent for a token. The exponent shapes the fee curve used by the protocol when calculating fees at match time.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getFeeExponent(tokenID: string): Promise<number>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="number">
|
||||
The fee curve exponent for the specified token's market.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getTickSize
|
||||
|
||||
Get the tick size (minimum price increment) for a market.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getTickSize(tokenID: string): Promise<TickSize>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="string">
|
||||
The tick size for the market. One of: `0.1`, `0.01`, `0.001`, `0.0001`
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### getNegRisk
|
||||
|
||||
Check if a market uses negative risk (binary complementary tokens).
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getNegRisk(tokenID: string): Promise<boolean>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="boolean">
|
||||
Whether the market uses negative risk.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## Time and Server Info
|
||||
|
||||
### getServerTime
|
||||
|
||||
Get the current server timestamp.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getServerTime(): Promise<number>
|
||||
```
|
||||
|
||||
<ResponseField name="returns" type="number">
|
||||
Unix timestamp in seconds representing the current server time.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## See Also
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="L1 Methods" icon="key" href="/trading/clients/l1">
|
||||
Private key authentication to create or derive API credentials.
|
||||
</Card>
|
||||
|
||||
<Card title="L2 Methods" icon="lock" href="/trading/clients/l2">
|
||||
Place orders, cancel orders, and query your trades.
|
||||
</Card>
|
||||
|
||||
<Card title="REST API Reference" icon="code" href="/api-reference/introduction">
|
||||
Complete REST endpoint documentation.
|
||||
</Card>
|
||||
|
||||
<Card title="WebSocket" icon="bolt" href="/market-data/websocket/overview">
|
||||
Real-time market data streaming.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
Reference in New Issue
Block a user