Cancel Order
Cancel orders and query order history for a user.
Cancel Single Order
import { BuilderClient } from '@opinion-labs/opinion-clob-sdk';
const builder = new BuilderClient({
host: 'https://openapi.opinion.trade/openapi',
builderApiKey: 'YOUR_BUILDER_KEY',
chainId: 56,
});
const result = await builder.cancelOrderForUser(userApiKey, 'order_id_here');userApiKey
string
Yes
User's API key
orderId
string
Yes
Order ID to cancel
Cancel Batch
Cancel multiple orders at once:
const results = await builder.cancelOrdersBatchForUser(userApiKey, [
'order_id_1',
'order_id_2',
'order_id_3',
]);
for (const r of results) {
if (r.success) {
console.log(`Order ${r.orderId} cancelled`);
} else {
console.log(`Order ${r.orderId} failed: ${r.error}`);
}
}userApiKey
string
Yes
User's API key
orderIds
string[]
Yes
Array of order IDs to cancel
Batch Response
Cancel All Orders
Cancel all open orders with optional filters:
userApiKey
string
Yes
User's API key
options.marketId
number
No
Filter by market ID
options.side
OrderSide
No
Filter by side (BUY or SELL)
Cancel All Response
Get User Orders
Query a user's orders:
userApiKey
string
Yes
User's API key
options.marketId
number
No
Filter by market ID
options.status
string
No
Filter by status (e.g., '1' for open)
options.limit
number
No
Results per page (default: 10, max: 20)
options.page
number
No
Page number (default: 1)
Notes
Order cancellation uses the user's API key, not the builder API key.
Cancellation is gasless (counts toward the 2,000/day limit).
cancelAllOrdersForUser()automatically paginates through all open orders before cancelling.