- Added new documentation URLs from llms.txt index - Updated TARGET.md with 244 total documentation pages - Scraped new pages for trading, concepts, and API reference sections - Updated changelog and new index pages
18 KiB
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.
```typescript theme={null} import { ClobClient } from "@polymarket/clob-client"; import { Wallet } from "ethers";const signer = new Wallet(process.env.PRIVATE_KEY);
const apiCreds = {
apiKey: process.env.API_KEY,
secret: process.env.SECRET,
passphrase: process.env.PASSPHRASE,
};
const client = new ClobClient(
"https://clob.polymarket.com",
137,
signer,
apiCreds,
2, // GNOSIS_SAFE
process.env.FUNDER_ADDRESS
);
// Ready to send authenticated requests
const order = await client.postOrder(signedOrder);
```
```python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client.clob_types 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=2, # GNOSIS_SAFE
funder=os.getenv("FUNDER_ADDRESS")
)
# Ready to send authenticated requests
order = client.post_order(signed_order)
```
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.
async createAndPostOrder(
userOrder: UserOrder,
options?: Partial<CreateOrderOptions>,
orderType?: OrderType.GTC | OrderType.GTD, // Defaults to GTC
): Promise<OrderResponse>
Params
The token ID of the outcome to trade. The limit price for the order. The size of the order. The side of the order (buy or sell). Optional fee rate in basis points. Optional nonce for the order. Optional expiration timestamp for the order. Optional taker address. Tick size for the order. One of `"0.1"`, `"0.01"`, `"0.001"`, `"0.0001"`. Optional. Whether the market uses negative risk.Response
Whether the order was successfully placed. Error message if the order was not successful. The ID of the placed order. Array of transaction hashes associated with the order. The current status of the order. The amount being taken in the order. The amount being made in the order.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.
async createAndPostMarketOrder(
userMarketOrder: UserMarketOrder,
options?: Partial<CreateOrderOptions>,
orderType?: OrderType.FOK | OrderType.FAK, // Defaults to FOK
): Promise<OrderResponse>
Params
The token ID of the outcome to trade. The amount for the market order. The side of the order (buy or sell). Optional price hint for the market order. Optional fee rate in basis points. Optional nonce for the order. Optional taker address. Optional order type override. Defaults to FOK.Response
Whether the order was successfully placed. Error message if the order was not successful. The ID of the placed order. Array of transaction hashes associated with the order. The current status of the order. The amount being taken in the order. The amount being made in the order.postOrder()
Posts a pre-signed order to the CLOB. Use with createOrder() or createMarketOrder() from L1 methods.
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.
async postOrders(
args: PostOrdersArgs[],
): Promise<OrderResponse[]>
Params
The pre-signed order to post. The order type (e.g. GTC, FOK, FAK). Optional. Whether to post the order as post-only. Defaults to false.cancelOrder()
Cancels a single open order.
async cancelOrder(orderID: string): Promise<CancelOrdersResponse>
Response
Array of order IDs that were successfully canceled. Map of order IDs to reasons why they could not be canceled.cancelOrders()
Cancels multiple orders in a single batch.
async cancelOrders(orderIDs: string[]): Promise<CancelOrdersResponse>
cancelAll()
Cancels all open orders.
async cancelAll(): Promise<CancelOrdersResponse>
cancelMarketOrders()
Cancels all open orders for a specific market.
async cancelMarketOrders(
payload: OrderMarketCancelParams
): Promise<CancelOrdersResponse>
Params
Optional. The market condition ID to cancel orders for. Optional. The token ID to cancel orders for.Order and Trade Queries
getOrder()
Get details for a specific order by ID.
async getOrder(orderID: string): Promise<OpenOrder>
Response
The unique order ID. The current status of the order. The API key of the order owner. The on-chain address of the order maker. The market condition ID the order belongs to. The token ID the order is for. The side of the order (BUY or SELL). The original size of the order when it was placed. The amount of the order that has been matched so far. The limit price of the order. Array of trade IDs associated with this order. The outcome label for the order's token. Unix timestamp of when the order was created. The expiration time of the order. The order type (e.g. GTC, FOK, FAK, GTD).getOpenOrders()
Get all your open orders.
async getOpenOrders(
params?: OpenOrderParams,
only_first_page?: boolean,
): Promise<OpenOrder[]>
Params
Optional. Filter by order ID. Optional. Filter by market condition ID. Optional. Filter by token ID.getTrades()
Get your trade history (filled orders).
async getTrades(
params?: TradeParams,
only_first_page?: boolean,
): Promise<Trade[]>
Params
Optional. Filter by trade ID. Optional. Filter by maker address. Optional. Filter by market condition ID. Optional. Filter by token ID. Optional. Return trades before this timestamp. Optional. Return trades after this timestamp.Response
The unique trade ID. The order ID of the taker side. The market condition ID for the trade. The token ID for the trade. The side of the trade (BUY or SELL). The size of the trade. The fee rate in basis points. The price at which the trade was matched. The current status of the trade. The time at which the trade was matched. The time of the last update to this trade. The outcome label for the traded token. The bucket index for the trade. The API key of the trade owner. The on-chain address of the maker. Array of maker order objects that participated in this trade. Each `MakerOrder` contains the following fields: The maker order ID. The API key of the maker order owner. The on-chain address of the maker order maker. The amount matched for this maker order. The price of the maker order. The fee rate in basis points for the maker order. The token ID for the maker order. The outcome label for the maker order's token. The side of the maker order (BUY or SELL). The on-chain transaction hash for the trade. Whether the authenticated user is the taker or a maker in this trade.getTradesPaginated()
Get trade history with pagination for large result sets.
async getTradesPaginated(
params?: TradeParams,
): Promise<TradesPaginatedResponse>
Response
Array of trade objects for the current page. The maximum number of trades returned per page. The total number of trades matching the query.Balance and Allowances
getBalanceAllowance()
Get your balance and allowance for specific tokens.
async getBalanceAllowance(
params?: BalanceAllowanceParams
): Promise<BalanceAllowanceResponse>
Params
The type of asset to query. One of `"COLLATERAL"` or `"CONDITIONAL"`. Optional. The token ID to query (required when `asset_type` is `CONDITIONAL`).Response
The current balance for the specified asset. The current allowance for the specified asset.updateBalanceAllowance()
Updates the cached balance and allowance for specific tokens.
async updateBalanceAllowance(
params?: BalanceAllowanceParams
): Promise<void>
API Key Management
getApiKeys()
Get all API keys associated with your account.
async getApiKeys(): Promise<ApiKeysResponse>
Response
Array of API key credential objects associated with the account.deleteApiKey()
Deletes (revokes) the currently authenticated API key.
async deleteApiKey(): Promise<any>
Notifications
getNotifications()
Retrieves all event notifications for the authenticated user. Records are automatically removed after 48 hours.
async getNotifications(): Promise<Notification[]>
Response
Unique notification ID. The user's API key, or an empty string for global notifications. Type-specific payload data for the notification. Optional Unix timestamp of when the notification was created. Notification type (see below).| 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.
async dropNotifications(params?: DropNotificationParams): Promise<void>
Params
Array of notification IDs to dismiss.