Skip to main content
Place a market order to trade against available liquidity immediately, or use a limit order to specify a price and wait for a match. Before placing an order, choose an outcome token and confirm that the market is accepting orders. The examples below assume you already have a market object; to find or fetch one, see Discover Markets.
Given a market, read its outcome token IDs:

Limit Orders

A limit order specifies the price at which you are willing to trade and can rest on the book until it fills, expires, or you cancel it. Use one when price control matters more than immediate execution. A limit order also defines how long any unfilled amount remains active:
GTD orders expire one minute before their stated expiration as a security threshold. To set an effective lifetime of N seconds, use now + 60 + N. In addition, the expiration must be at least 3 minutes in the future — orders expiring sooner are rejected — so the minimum effective lifetime is about two minutes.

Place a Limit Order

Given a SecureClient, place the limit order and check its response:
1

Place the Order

First, call placeLimitOrder() with the price and number of shares. The price must follow the market’s minimum price increment, and the size must meet its minimum order size. Omit expiration for a GTC order or provide a Unix timestamp in seconds for a GTD order.
Both examples buy 10 shares at a price of 0.52 USD per share. The GTD order has an effective lifetime of one hour.
2

Check the Response

Then, check response.ok to determine whether the CLOB accepted the order:
An accepted response includes the order ID and one of these statuses. If the order fills fully or partially, the tradeIds collection identifies the resulting trades. When available, transactionsHashes contains their transaction hashes:A rejected order returns ok: false with a code and message.

Post-Only Orders

A post-only order adds liquidity only: if it would match immediately against the book, it is rejected instead of taking. Use it to guarantee you quote as a maker.
Market makers use post-only orders to add liquidity with resting orders.
Given a SecureClient, set postOnly when placing the limit order:

Market Orders

A market order uses the same underlying order as a limit order but derives a marketable price from current order-book liquidity. This allows it to execute immediately instead of resting on the book. Use a market order when execution matters more than setting an exact price. Read the market’s trading constraints before deciding how much to buy or sell.

Place a Market Order

The examples below use Fill and Kill (FAK), which fills available liquidity immediately and cancels any remainder. See Market Order Types for Fill or Kill (FOK).
Given a SecureClient, estimate the price and place the market order:
1

Estimate the Price

First, call estimateMarketPrice() to discover the price level the order would reach at the current order-book depth. For a BUY, amount is the USD notional to spend. For a SELL, shares is the number of shares to sell, rather than their USD value.
In these examples, amount: "10" means spending $10, while shares: "10" means selling 10 shares.The estimate is a snapshot of the current order book. The available price can change before you submit the order.
2

Place the Order

Then, if the estimated price is acceptable, pass it as the maximum price for a BUY or the minimum price for a SELL, and place the market order:
maxPrice prevents a BUY from crossing a higher price, while minPrice prevents a SELL from crossing a lower one. If the book moves before submission, the order may fill only partially or not at all.
3

Check the Response

Finally, check response.ok to determine whether the CLOB accepted the order:
An accepted response includes the order ID and one of these statuses. If the order fills fully or partially, tradeIds identifies the resulting trades. When available, transactionsHashes contains their transaction hashes:A rejected order returns ok: false with a code and message.

Cap Market Buy Spending

A market BUY’s amount is the pre-fee USD notional. Applicable platform fees and builder taker fees are charged on top. Set an all-in spending limit when the complete cost must remain within a fixed budget.
Set maxSpend to the most you want to spend, including fees:
Here, amount: "10" requests a 10 USD pre-fee buy, while maxSpend: "10" caps the total spend at 10 USD. The SDK reduces the signed buy amount so the order and its fees fit within the cap. Omit maxSpend to pay fees on top of amount.

Market Order Types

A market order uses one of two execution types, depending on whether a partial fill is acceptable:
Set orderType when calling placeMarketOrder() on a SecureClient. Fill and Kill is the default.

Create and Post Separately

Create and sign an order without submitting it when you need to inspect it, store it temporarily, or include it in a later batch.
Given a SecureClient, create the signed order locally, then post it when ready:

Post a Batch of Orders

Submit several signed orders in one request. This is useful for placing a ladder of quotes across multiple price levels when market making.
Given a SecureClient, create each signed order, then pass them together to postOrders():
Example
postOrders accepts between 1 and 15 signed orders per call. Each entry in responses can independently be accepted or rejected, so check ok on every entry rather than assuming the whole batch succeeded or failed together.

Builder Attribution

As part of the Builder Program, attach your builder code to orders so matched trades are credited to your builder profile. The code is a 32-byte hex string that identifies your profile.

Attach Your Builder Code

In the builder account, open polymarket.com → Settings → Builders and copy the Builder Code from your profile:
Open Settings, select Builders, and copy the Builder Code
Include the builder code in every order you want attributed to your integration. Because it is part of the signed order, add it before signing.
Given a SecureClient, pass the code as builderCode when placing the order:

Verify Attribution

After an attributed order matches, query builder trades using your builder code to confirm that the trade was credited to your profile. Orders that have not matched do not appear in builder trade results.
Use listBuilderTrades with a PublicClient or SecureClient, then fetch the first page of matching trades:
You can also monitor credited volume on the Builder Leaderboard. Allow up to 24 hours for matched volume to appear there.