Documentation Index
Fetch the complete documentation index at: https://docs.polymarket.us/llms.txt
Use this file to discover all available pages before exploring further.
The Orders resource provides order entry and management capabilities for trading on markets.
Methods
| Method | Endpoint | Description |
|---|
create(params) | POST /v1/orders | Create a new order |
list(params?) | GET /v1/orders/open | Get open orders |
retrieve(orderId) | GET /v1/order/{orderId} | Get order by ID |
cancel(orderId, params) | POST /v1/order/{orderId}/cancel | Cancel an order |
modify(orderId, params) | POST /v1/order/{orderId}/modify | Modify an order |
cancelAll(params?) | POST /v1/orders/open/cancel | Cancel all open orders |
preview(params) | POST /v1/order/preview | Preview order before submission |
closePosition(params) | POST /v1/order/close-position | Close an existing position |
Create a new order on a market.
const order = await client.orders.create({
marketSlug: 'btc-100k-2025',
intent: 'ORDER_INTENT_BUY_LONG',
type: 'ORDER_TYPE_LIMIT',
price: { value: '0.55', currency: 'USD' },
quantity: 100,
tif: 'TIME_IN_FORCE_GOOD_TILL_CANCEL',
});
console.log(`Order ID: ${order.id}`);
console.log(`State: ${order.state}`);
Parameters
| Parameter | Type | Required | Description |
|---|
marketSlug | string | Yes | Market to trade |
intent | string | Yes | Order intent (see below) |
type | string | Yes | ORDER_TYPE_LIMIT or ORDER_TYPE_MARKET |
price | Amount | Limit only | Limit price |
quantity | number | Yes | Number of contracts |
tif | string | Yes | Time in force (see below) |
Order Intent
| Value | Description |
|---|
ORDER_INTENT_BUY_LONG | Buy YES shares |
ORDER_INTENT_SELL_LONG | Sell YES shares |
ORDER_INTENT_BUY_SHORT | Buy NO shares |
ORDER_INTENT_SELL_SHORT | Sell NO shares |
Time in Force
| Value | Description |
|---|
TIME_IN_FORCE_GOOD_TILL_CANCEL | Remains active until filled or canceled |
TIME_IN_FORCE_GOOD_TILL_DATE | Expires at specified time |
TIME_IN_FORCE_IMMEDIATE_OR_CANCEL | Fill immediately available quantity, cancel rest |
TIME_IN_FORCE_FILL_OR_KILL | Fill entirely or cancel completely |
Get all open orders.
const orders = await client.orders.list();
for (const order of orders.orders) {
console.log(`${order.id}: ${order.marketSlug} - ${order.state}`);
}
Cancel a specific order.
await client.orders.cancel('order-id-123', {
marketSlug: 'btc-100k-2025',
});
cancelAll
Cancel all open orders, optionally filtered by market.
const result = await client.orders.cancelAll();
console.log(`Canceled: ${result.canceledOrderIds}`);
// Or cancel for a specific market
const result = await client.orders.cancelAll({ marketSlug: 'btc-100k-2025' });
preview
Preview an order before submitting. Returns estimated fills and costs.
const preview = await client.orders.preview({
marketSlug: 'btc-100k-2025',
intent: 'ORDER_INTENT_BUY_LONG',
type: 'ORDER_TYPE_LIMIT',
price: { value: '0.55', currency: 'USD' },
quantity: 100,
});
console.log(`Estimated Cost: $${preview.estimatedCost}`);
closePosition
Close an existing position at market price. This sells your entire position in a single call.
const result = await client.orders.closePosition({
marketSlug: 'btc-100k-2025',
});
closePosition vs Sell Order
| closePosition | Sell Order (create) |
|---|
| Position size | Entire position | Any quantity |
| Order type | Market only | Limit or market |
| Use case | Quick full exit | Partial sells, limit prices |
Use closePosition when you want to fully exit a position at market price. Use a sell order (ORDER_INTENT_SELL_LONG or ORDER_INTENT_SELL_SHORT) when you need to sell a specific quantity or set a limit price.
Slippage Tolerance
For market orders and close position, you can specify slippage tolerance:
const result = await client.orders.closePosition({
marketSlug: 'btc-100k-2025',
slippageTolerance: {
currentPrice: { value: '0.50', currency: 'USD' },
ticks: 5,
},
});
Order States
Orders progress through these states:
| State | Description |
|---|
ORDER_STATE_PENDING_NEW | Received, not yet processed |
ORDER_STATE_PARTIALLY_FILLED | Partially executed |
ORDER_STATE_FILLED | Fully executed |
ORDER_STATE_CANCELED | Canceled |
ORDER_STATE_REJECTED | Rejected by exchange |
ORDER_STATE_EXPIRED | Expired (GTD orders) |
For real-time order updates, use the WebSocket with SUBSCRIPTION_TYPE_ORDER instead of polling.