Skip to main content

Client Initialization

Builder methods require the client to initialize with a separate authentication setup using builder configs acquired from Polymarket.com and the @polymarket/builder-signing-sdk package.
  • Local Builder Credentials
  • Remote Builder Signing
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, // The user's API credentials generated from L1 authentication
  signatureType,
  funderAddress,
  undefined,
  false,
  builderConfig
);

Methods


getBuilderTrades()

Retrieves all trades attributed to your builder account. This method allows builders to track which trades were routed through your platform.
Signature
async getBuilderTrades(
  params?: TradeParams,
): Promise<BuilderTradesPaginatedResponse>
Params
interface TradeParams {
  id?: string;
  maker_address?: string;
  market?: string;
  asset_id?: string;
  before?: string;
  after?: string;
}
Response
interface BuilderTradesPaginatedResponse {
  trades: BuilderTrade[];
  next_cursor: string;
  limit: number;
  count: number;
}

interface BuilderTrade {
  id: string;
  tradeType: string;
  takerOrderHash: string;
  builder: string;
  market: string;
  assetId: string;
  side: string;
  size: string;
  sizeUsdc: string;
  price: string;
  status: string;
  outcome: string;
  outcomeIndex: number;
  owner: string;
  maker: string;
  transactionHash: string;
  matchTime: string;
  bucketIndex: number;
  fee: string;
  feeUsdc: string;
  err_msg?: string | null;
  createdAt: string | null;
  updatedAt: string | null;
}

revokeBuilderApiKey()

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

See Also