Skip to main content

Client Initialization

Builder methods require the client to initialize with a separate builder config using credentials acquired from Polymarket.com and the @polymarket/builder-signing-sdk package.
import { ClobClient } from "@polymarket/clob-client";
import { BuilderConfig, BuilderApiKeyCreds } from "@polymarket/builder-signing-sdk";

const builderConfig = new BuilderConfig({
  localBuilderCreds: new BuilderApiKeyCreds({
    key: process.env.BUILDER_API_KEY,
    secret: process.env.BUILDER_SECRET,
    passphrase: process.env.BUILDER_PASS_PHRASE,
  }),
});

const clobClient = new ClobClient(
  "https://clob.polymarket.com",
  137,
  signer,
  apiCreds, // User's API credentials from L1 authentication
  signatureType,
  funderAddress,
  undefined,
  false,
  builderConfig
);
See Order Attribution for more information on builder signing.

Methods


getOrder

Get details for a specific order by ID using builder authentication. When called from a builder-configured client, the request authenticates with builder headers and returns orders attributed to the builder.
Signature
async getOrder(orderID: string): Promise<OpenOrder>
When a BuilderConfig is present, the client automatically sends builder headers. If builder auth is unavailable, it falls back to standard L2 headers.
const order = await clobClient.getOrder("0xb816482a...");
console.log(order);

getOpenOrders

Get all open orders attributed to the builder. When called from a builder-configured client, returns orders placed through the builder rather than orders owned by the authenticated user.
Signature
async getOpenOrders(
  params?: OpenOrderParams,
  only_first_page?: boolean,
): Promise<OpenOrder[]>
Params
id
string
Optional. Filter by order ID.
market
string
Optional. Filter by market condition ID.
asset_id
string
Optional. Filter by token ID.
TypeScript
// All open orders for this builder
const orders = await clobClient.getOpenOrders();

// Filtered by market
const marketOrders = await clobClient.getOpenOrders({
  market: "0xbd31dc8a...",
});

getBuilderTrades

Retrieves all trades attributed to your builder account. Use this to track which trades were routed through your platform.
Signature
async getBuilderTrades(
  params?: TradeParams,
): Promise<BuilderTradesPaginatedResponse>
Params (TradeParams)
id
string
Optional. Filter trades by trade ID.
maker_address
string
Optional. Filter trades by maker address.
market
string
Optional. Filter trades by market condition ID.
asset_id
string
Optional. Filter trades by asset (token) ID.
before
string
Optional. Return trades created before this cursor value.
after
string
Optional. Return trades created after this cursor value.
Response (BuilderTradesPaginatedResponse)
trades
BuilderTrade[]
Array of trades attributed to the builder account.
next_cursor
string
Cursor string for fetching the next page of results.
limit
number
Maximum number of trades returned per page.
count
number
Total number of trades returned in this response.
BuilderTrade fields
id
string
Unique identifier for the trade.
tradeType
string
Type of the trade.
takerOrderHash
string
Hash of the taker order associated with this trade.
builder
string
Address of the builder who attributed this trade.
market
string
Condition ID of the market this trade belongs to.
assetId
string
Token ID of the asset traded.
side
string
Side of the trade (e.g. BUY or SELL).
size
string
Size of the trade in shares.
sizeUsdc
string
Size of the trade denominated in USDC.
price
string
Price at which the trade was executed.
status
string
Current status of the trade.
outcome
string
Outcome label associated with the traded asset.
outcomeIndex
number
Index of the outcome within the market.
owner
string
Address of the order owner (taker).
maker
string
Address of the maker in the trade.
transactionHash
string
On-chain transaction hash for the trade.
matchTime
string
Timestamp when the trade was matched.
bucketIndex
number
Bucket index used for trade grouping.
fee
string
Fee charged for the trade in shares.
feeUsdc
string
Fee charged for the trade denominated in USDC.
err_msg
string | null
Optional. Error message if the trade encountered an issue, otherwise null.
createdAt
string | null
Timestamp when the trade record was created, or null if unavailable.
updatedAt
string | null
Timestamp when the trade record was last updated, or null if unavailable.

revokeBuilderApiKey

Revokes the builder API key used to authenticate the current request. After revocation, the key can no longer be used for builder-authenticated requests.
Signature
async revokeBuilderApiKey(): Promise<any>
returns
any
Response from the revocation request.

See Also