How to Find a Polymarket Market ID and Condition ID

The Short Answer
A single Polymarket market carries five different identifiers, and they are not interchangeable. The Gamma id is a short number for the catalog, the slug is the human-readable URL fragment, the conditionId is a 32-byte hex string identifying the on-chain condition, the questionID is the oracle's identifier for the resolution question, and clobTokenIds is an array of two very long decimal strings, one per outcome. Order books and prices key on a CLOB token id, not on the market. Fetch the market from Gamma first, then read the token id for the side you want.
Key Takeaways
- Five identifiers, three formats. Short integer, hex string, and very long decimal string, and mixing them up produces confusing errors rather than clear ones.
- The CLOB never takes a market id. It takes a token id, and a binary market has two.
conditionIdidentifies the on-chain condition;questionIDidentifies the oracle question. They are different values.- The slug is stable enough to be useful and is the only identifier a human can read back to you from a URL.
- Getting the wrong token id from a pair gives you the opposite side of the book, with no error at all.
- A normalized layer collapses this to one outcome identifier that means the same thing on every venue.
What identifiers does a Polymarket market carry?
Here is a real market as Gamma returns it, trimmed to the identifier fields:
{
"id": "559651",
"slug": "xi-jinping-out-before-2027",
"question": "Xi Jinping out before 2027?",
"conditionId": "0xa467b14d51f01b957109d9cbb1d6c124fab2a089d52ed8f471d23c2812e743b7",
"questionID": "0x1d925c6933062c2e38031293612d8680ffa097c5d3ba2f87a8ecc565bd47183e",
"clobTokenIds": ["32338220190071351435772801779725302244575775216413325951443816017994629993401", "..."],
"negRisk": false
}
| Field | Format | What it identifies |
|---|---|---|
id | Short integer | The market row in Gamma's catalog |
slug | Kebab-case text | The market's URL fragment on polymarket.com |
conditionId | 0x + 64 hex | The on-chain condition in the conditional token framework |
questionID | 0x + 64 hex | The oracle's resolution question |
clobTokenIds | Array of long decimals | One ERC-1155 token per outcome, which is what the order book keys on |
The two hex values are the ones people most often confuse, because they look identical in shape. conditionId is the condition under which the tokens were minted. questionID is what the oracle answers to resolve it. Same length, same prefix, different things.
Why does the order book not take a market id?
Because a market is not a tradable thing. Its outcomes are.
A binary market is two tokens, one for Yes and one for No, each with its own order book and its own price. Asking for "the price of the market" is under-specified, which is why every CLOB call takes a token id rather than a market id.
This is the source of a bug that is genuinely hard to spot, because it does not throw. Pick the wrong element of clobTokenIds and you get a perfectly valid order book for the opposite side. A comparison reading the Yes book on one venue and the No book on another produces numbers that look plausible and are wrong.
How do you go from a URL to a token id?
The slug is usually where you start, because it is the part of the URL a person can read out loud.
curl -s "https://gamma-api.polymarket.com/markets?slug=xi-jinping-out-before-2027"
That returns the market object with every identifier on it. Read clobTokenIds, pick the element matching the outcome you want, and use that value for order book, price and midpoint calls against the CLOB. Store the mapping if you are going to query repeatedly, since resolving the slug on every request is wasted work.
Going the other way, from a condition id back to a market, is also supported by filtering Gamma on condition_ids. That is the path you take when something on-chain references a condition and you want the human-readable market behind it.
What is negRisk and why does it change things?
The negRisk flag marks markets that belong to a mutually exclusive group, where exactly one outcome in a set can resolve Yes. Multi-candidate election markets are the obvious case.
It matters for identifiers because those markets sit behind a different adapter contract, and because the arithmetic across the group is not the same as the arithmetic on a standalone binary market. If you are building anything that reasons about a set of related outcomes, read the flag rather than assuming every market in a group behaves independently.
How does a normalized layer handle this?
By giving you one identifier that means the same thing everywhere.
The problem compounds across venues. Kalshi uses structured tickers with a view per side. Limitless uses a slug with a yes or no suffix. Polymarket uses the long decimal token id above. Every venue you add is another identifier format and another conversion to maintain.
curl -s "https://data.predictefy.com/api/polymarket/fetchMarkets?query=xi+jinping&limit=1" \
-H "Authorization: Bearer pk_live_YOUR_KEY"
Each returned market carries an outcomes array, and each outcome carries an outcomeId that order book and candle calls accept directly. The venue's native id is still accepted where you already have one, so a partial migration works. Change polymarket to any served venue and the shape of both request and response is unchanged.
Frequently Asked Questions
What is the difference between a Polymarket condition ID and a market ID?
The market ID is a short integer identifying the row in Gamma's catalog. The condition ID is a 32-byte hex string identifying the on-chain condition under which the outcome tokens were minted. One is a database key for the API, the other is a blockchain identifier, and neither is accepted where the other is expected.
How do I get a Polymarket token ID?
Fetch the market from the Gamma API by slug, id or condition id, then read the clobTokenIds array on the response. It contains one very long decimal string per outcome. Pick the element for the side you want, because the CLOB keys order books and prices on the token rather than the market.
Why does my order book look inverted?
You almost certainly took the wrong element from clobTokenIds, so you are reading the opposite outcome's book. This fails silently because both token ids are valid and both return real data. Verify which outcome a token corresponds to before trusting any comparison built on top of it.
Can I look up a Polymarket market by its URL slug?
Yes. Query the Gamma markets endpoint filtering on the slug, and the response carries every other identifier including the condition id and the CLOB token ids. The slug is the most convenient starting point because it is the only identifier that appears in a shareable link a person can read.
What does the negRisk flag mean?
It marks a market belonging to a mutually exclusive group where exactly one outcome across the set resolves Yes, most commonly a multi-candidate election. Those markets sit behind a different adapter contract, so treat the group as related rather than assuming each market in it prices and settles independently.