|
| 1 | +--- |
| 2 | +title: "Polymarket Markets API - Filter by Slug, Condition & Token" |
| 3 | +description: "Find Polymarket markets using market slug, event slug, condition ID, and token ID filters. Query markets with multiple filter options for integration with trades and settlements." |
| 4 | +keywords: |
| 5 | + - Polymarket Markets API |
| 6 | + - Polymarket market slug |
| 7 | + - Polymarket event slug |
| 8 | + - condition ID Polymarket |
| 9 | + - token ID filter |
| 10 | + - prediction market filters |
| 11 | + - Polymarket market search |
| 12 | + - filter markets by slug |
| 13 | +--- |
| 14 | + |
| 15 | +# Markets API |
| 16 | + |
| 17 | +Find markets on Polymarket using various filters, including **market slug**, **event slug**, **condition ID**, and **token ID**. Use these parameters to narrow results to specific markets or events when building apps that combine market metadata with [trades](https://docs.bitquery.io/docs/examples/prediction-market/prediction-trades-api/) and [settlements](https://docs.bitquery.io/docs/examples/prediction-market/prediction-settlements-api/). |
| 18 | + |
| 19 | +**Network:** Polygon (`network: matic`). For full lifecycle and trade data, see the [Polymarket API](https://docs.bitquery.io/docs/examples/polymarket-api/polymarket-api/) overview and the [Prediction Market API](https://docs.bitquery.io/docs/examples/prediction-market/prediction-market-api/). |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Filter parameters |
| 24 | + |
| 25 | +All parameters are optional. You can combine multiple filters; results match markets that satisfy the criteria you provide. |
| 26 | + |
| 27 | +| Parameter | Type | Description | |
| 28 | +| ---------------- | -------- | ------------------------------------------------------------------- | |
| 29 | +| **market_slug** | string[] | Filter markets by market slug(s). Can provide multiple values. | | |
| 30 | +| **condition_id** | string[] | Filter markets by condition ID(s). Can provide multiple values. | |
| 31 | +| **token_id** | string[] | Filter markets by outcome token ID(s). Can provide multiple values. | |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +## Find markets by condition_id |
| 36 | + |
| 37 | +Use when you have on-chain condition IDs (e.g. from [Main Polymarket Contract](https://docs.bitquery.io/docs/examples/polymarket-api/main-polymarket-contract/) or [CTF Exchange](https://docs.bitquery.io/docs/examples/polymarket-api/polymarket-ctf-exchange/) events). Condition IDs are hex strings; you can pass one or more. |
| 38 | + |
| 39 | +Get market lifecycle events (created/resolved) for one or more condition IDs. Condition IDs are hex strings (with or without `0x`). [Run Query](https://ide.bitquery.io/Filter-markets-by-condition-ID-Polymarket) |
| 40 | + |
| 41 | +```graphql |
| 42 | +query MarketsByConditionId($conditionIds: [String!]) { |
| 43 | + EVM(network: matic) { |
| 44 | + PredictionManagements( |
| 45 | + limit: { count: 50 } |
| 46 | + orderBy: { descending: Block_Time } |
| 47 | + where: { |
| 48 | + Management: { |
| 49 | + Prediction: { |
| 50 | + Condition: { Id: { in: $conditionIds } } |
| 51 | + Marketplace: { ProtocolName: { is: "polymarket" } } |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + ) { |
| 56 | + Block { |
| 57 | + Time |
| 58 | + Number |
| 59 | + } |
| 60 | + Transaction { |
| 61 | + Hash |
| 62 | + Time |
| 63 | + } |
| 64 | + Management { |
| 65 | + EventType |
| 66 | + Prediction { |
| 67 | + Condition { |
| 68 | + Id |
| 69 | + QuestionId |
| 70 | + Outcomes { |
| 71 | + Id |
| 72 | + Index |
| 73 | + Label |
| 74 | + } |
| 75 | + } |
| 76 | + Question { |
| 77 | + MarketId |
| 78 | + Title |
| 79 | + Image |
| 80 | + ResolutionSource |
| 81 | + CreatedAt |
| 82 | + } |
| 83 | + CollateralToken { |
| 84 | + Symbol |
| 85 | + Name |
| 86 | + } |
| 87 | + Outcome { |
| 88 | + Id |
| 89 | + Label |
| 90 | + } |
| 91 | + OutcomeToken { |
| 92 | + AssetId |
| 93 | + SmartContract |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +**Variables (example):** |
| 103 | + |
| 104 | +```json |
| 105 | +{ |
| 106 | + "conditionIds": [ |
| 107 | + "0x4567b275e6b667a6217f5cb4f06a797d3a1eaf1d0281fb5bc8c75e2046ae7e57" |
| 108 | + ] |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | + |
| 113 | +## Find markets by token_id (AssetId) |
| 114 | + |
| 115 | +Use when you have outcome token IDs (e.g. from [Prediction Trades](https://docs.bitquery.io/docs/examples/prediction-market/prediction-trades-api/) `OutcomeToken.AssetId` or [CTF Exchange](https://docs.bitquery.io/docs/examples/polymarket-api/polymarket-ctf-exchange/) order data). Pass one or more AssetIds. |
| 116 | + |
| 117 | +[Run query](https://ide.bitquery.io/Filter-markets-by-asset-ID-Polymarket) |
| 118 | + |
| 119 | +```graphql |
| 120 | +query MarketsByAssetId($assetIds: [String!]) { |
| 121 | + EVM(network: matic) { |
| 122 | + PredictionManagements( |
| 123 | + limit: { count: 50 } |
| 124 | + orderBy: { descending: Block_Time } |
| 125 | + where: { |
| 126 | + Management: { |
| 127 | + Prediction: { |
| 128 | + Marketplace: { ProtocolName: { is: "polymarket" } } |
| 129 | + OutcomeToken: { AssetId: { in: $assetIds } } |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + ) { |
| 134 | + Block { |
| 135 | + Time |
| 136 | + Number |
| 137 | + } |
| 138 | + Transaction { |
| 139 | + Hash |
| 140 | + Time |
| 141 | + } |
| 142 | + Management { |
| 143 | + EventType |
| 144 | + Prediction { |
| 145 | + Condition { |
| 146 | + Id |
| 147 | + QuestionId |
| 148 | + Outcomes { |
| 149 | + Id |
| 150 | + Index |
| 151 | + Label |
| 152 | + } |
| 153 | + } |
| 154 | + Question { |
| 155 | + MarketId |
| 156 | + Title |
| 157 | + Image |
| 158 | + ResolutionSource |
| 159 | + CreatedAt |
| 160 | + } |
| 161 | + CollateralToken { |
| 162 | + Symbol |
| 163 | + Name |
| 164 | + } |
| 165 | + Outcome { |
| 166 | + Id |
| 167 | + Label |
| 168 | + } |
| 169 | + OutcomeToken { |
| 170 | + AssetId |
| 171 | + SmartContract |
| 172 | + } |
| 173 | + } |
| 174 | + } |
| 175 | + } |
| 176 | + } |
| 177 | +} |
| 178 | +``` |
| 179 | + |
| 180 | +**Variables (example):** |
| 181 | + |
| 182 | +```json |
| 183 | +{ |
| 184 | + "assetIds": [ |
| 185 | + "19443761038809394075988687891855393102730862479306560066876868792031660494383" |
| 186 | + ] |
| 187 | +} |
| 188 | +``` |
| 189 | + |
| 190 | +## Find markets by market_slug |
| 191 | + |
| 192 | +Filter by market slug or keyword using **Question.Title** with case-insensitive match. Use the URL slug (e.g. `bitcoin-up-or-down-july-25-8pm-et`) or a keyword (e.g. `XRP`). |
| 193 | + |
| 194 | +[Run query](https://ide.bitquery.io/Find-Markets-by-market_slug-on-Polymarket) |
| 195 | + |
| 196 | +```graphql |
| 197 | +query MarketsByMarketSlug($marketSlug: String!) { |
| 198 | + EVM(network: matic) { |
| 199 | + PredictionManagements( |
| 200 | + limit: { count: 50 } |
| 201 | + orderBy: { descending: Block_Time } |
| 202 | + where: { |
| 203 | + Management: { |
| 204 | + Prediction: { |
| 205 | + Question: { Title: { includesCaseInsensitive: $marketSlug } } |
| 206 | + Marketplace: { ProtocolName: { is: "polymarket" } } |
| 207 | + } |
| 208 | + } |
| 209 | + } |
| 210 | + ) { |
| 211 | + Block { |
| 212 | + Time |
| 213 | + Number |
| 214 | + } |
| 215 | + Transaction { |
| 216 | + Hash |
| 217 | + Time |
| 218 | + } |
| 219 | + Management { |
| 220 | + EventType |
| 221 | + Prediction { |
| 222 | + Condition { |
| 223 | + Id |
| 224 | + QuestionId |
| 225 | + Outcomes { |
| 226 | + Id |
| 227 | + Index |
| 228 | + Label |
| 229 | + } |
| 230 | + } |
| 231 | + Question { |
| 232 | + MarketId |
| 233 | + Title |
| 234 | + Image |
| 235 | + ResolutionSource |
| 236 | + CreatedAt |
| 237 | + } |
| 238 | + CollateralToken { |
| 239 | + Symbol |
| 240 | + Name |
| 241 | + } |
| 242 | + Outcome { |
| 243 | + Id |
| 244 | + Label |
| 245 | + } |
| 246 | + OutcomeToken { |
| 247 | + AssetId |
| 248 | + SmartContract |
| 249 | + } |
| 250 | + } |
| 251 | + } |
| 252 | + } |
| 253 | + } |
| 254 | +} |
| 255 | +``` |
| 256 | + |
| 257 | +**Variables (example):** |
| 258 | + |
| 259 | +```json |
| 260 | +{ |
| 261 | + "marketSlug": "bitcoin-up-or-down-july-25-8pm-et" |
| 262 | +} |
| 263 | +``` |
| 264 | + |
| 265 | + |
| 266 | + |
| 267 | +### Combined filters (condition_id + time range) |
| 268 | + |
| 269 | +Combine **condition_id** with other filters such as a time window or event type in the same `where` clause. |
| 270 | + |
| 271 | +You can combine **condition_id** with other filters (e.g. time range, event type) in the same `where` clause. |
| 272 | + |
| 273 | +```graphql |
| 274 | +query MarketsByConditionIdRecent($conditionIds: [String!]) { |
| 275 | + EVM(network: matic) { |
| 276 | + PredictionManagements( |
| 277 | + limit: { count: 20 } |
| 278 | + orderBy: { descending: Block_Time } |
| 279 | + where: { |
| 280 | + Block: { Time: { since_relative: { days_ago: 7 } } } |
| 281 | + Management: { |
| 282 | + Prediction: { |
| 283 | + Condition: { Id: { in: $conditionIds } } |
| 284 | + Marketplace: { ProtocolName: { is: "polymarket" } } |
| 285 | + } |
| 286 | + } |
| 287 | + } |
| 288 | + ) { |
| 289 | + Block { |
| 290 | + Time |
| 291 | + } |
| 292 | + Management { |
| 293 | + EventType |
| 294 | + Prediction { |
| 295 | + Condition { |
| 296 | + Id |
| 297 | + } |
| 298 | + Question { |
| 299 | + MarketId |
| 300 | + Title |
| 301 | + } |
| 302 | + Outcome { |
| 303 | + Label |
| 304 | + } |
| 305 | + } |
| 306 | + } |
| 307 | + } |
| 308 | + } |
| 309 | +} |
| 310 | +``` |
| 311 | + |
| 312 | +**Variables (example):** |
| 313 | + |
| 314 | +```json |
| 315 | +{ |
| 316 | + "conditionIds": [ |
| 317 | + "0x4567b275e6b667a6217f5cb4f06a797d3a1eaf1d0281fb5bc8c75e2046ae7e57" |
| 318 | + ] |
| 319 | +} |
| 320 | +``` |
| 321 | + |
| 322 | +--- |
| 323 | + |
| 324 | +## Related APIs |
| 325 | + |
| 326 | +| Need | API | |
| 327 | +| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 328 | +| **Trades & prices** | [Prediction Trades API](https://docs.bitquery.io/docs/examples/prediction-market/prediction-trades-api/) | |
| 329 | +| **Settlements & redemptions** | [Prediction Settlements API](https://docs.bitquery.io/docs/examples/prediction-market/prediction-settlements-api/) | |
| 330 | +| **Market creation & resolution** | [Prediction Market API](https://docs.bitquery.io/docs/examples/prediction-market/prediction-market-api/) / [Prediction Managements API](https://docs.bitquery.io/docs/examples/prediction-market/prediction-managements-api/) | |
| 331 | +| **Polymarket overview** | [Polymarket API](https://docs.bitquery.io/docs/examples/polymarket-api/polymarket-api/) | |
| 332 | +| **On-chain condition & tokens** | [Main Polymarket Contract](https://docs.bitquery.io/docs/examples/polymarket-api/main-polymarket-contract/), [CTF Exchange](https://docs.bitquery.io/docs/examples/polymarket-api/polymarket-ctf-exchange/) | |
0 commit comments