Polymarket
Live odds, order books, trades and on-chain holders, read-only
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available Β· $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/polymarket/index.md to help me query Polymarket with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Explore the busiest prediction markets
Example output Β· captured
- Connector release
- v0.2.1
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT question, outcomes, volume_24hr
FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20
| question | outcomes | volume_24hr |
|---|---|---|
| Will the Fed increase interest rates by 50+ bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "35090254409399344650860070β¦ | 1,723,997.1 |
| Will Bitcoin dip to $50,000 by December 31, 2026? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "13887983551129862992605123β¦ | 1,591,448.9 |
| Will the Fed increase interest rates by 25 bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "11166212965282826688936037β¦ | 1,306,369.5 |
| Will there be no change in Fed interest rates after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "42865728742506860386768556β¦ | 1,208,574.3 |
| Will the Fed decrease interest rates by 50+ bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "17640596861394454242836532β¦ | 815,000.8 |
Quick start
Choose where to run Polymarket, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'polymarket' AS polymarket (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-polymarket'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'polymarket' AS polymarket (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-polymarket:0.2.1'
);
3. Run a query
SELECT question, outcomes, volume_24hr
FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connectorβs deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'polymarket' AS polymarket
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT question, outcomes, volume_24hr
FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20
Query Farm operates Polymarket for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use polymarket as the catalog alias for the query below.
4. Run a query
SELECT question, outcomes, volume_24hr
FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20
Technical details
- Verified connector release
- v0.2.1
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until youβre ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'polymarket' AS polymarket (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-polymarket'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'polymarket' AS polymarket (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-polymarket:0.2.1'
);
Overview
What the crowd thinks a future event is worth, priced as a probability β read-only Polymarket data, including who holds each position
Polymarket is a prediction market where each outcome of a question trades as its own token. A token pays $1 if its outcome happens and $0 otherwise, so its price is the market's implied probability of that outcome.
The two identifiers β read this first
Polymarket has two keys and its own URLs call both of them market. They are not interchangeable, and passing one where the other belongs usually returns an empty result rather than an error:
| Key | Looks like | Names | Used by |
|---|---|---|---|
condition_id |
0x + 64 hex |
a whole market | the trade tape, the holder list, the market lookup |
token_id |
a long decimal string | one outcome of it | resting depth, live quotes, price history |
Every market row carries an outcomes list holding each outcome's token_id, so unnesting that column is how you get from one key to the other. Each function's own docs say which it takes.
Getting it wrong fails differently by direction: a market key passed where an outcome key belongs is an HTTP 404 in one place and an empty price series in another, and an outcome key passed to the trade tape is an HTTP 400. The empty price series is indistinguishable from 'nothing traded'.
How the data is shaped
- Tag β a topic such as Crypto or Politics. The filter almost everything accepts, and the only axis that covers the whole site.
- Series β a recurring question that opens a new event each occurrence. Many markets belong to no series.
- Event β the markets that resolve together: one game, or one election.
- Market β one question, named by its
condition_id. - Outcome β one answer to that question, trading as its own token and named by its
token_id.
Reading prices
Every price column is USDC per share between 0 and 1, so a midpoint of 0.62 is a 62% implied probability β provided the spread is tight. Displayed outcome prices are normalised to sum to 1, so a thin market can look like a coherent forecast while nobody would trade at it; the quote and order-book functions document how to check. Prices are DECIMAL, never DOUBLE: however Polymarket encodes money (decimal strings, JSON floats, arrays nested inside strings), it is recovered exactly.
Access
No credentials are needed and none are accepted. The whole market-data surface is public; only order placement requires a wallet signature, and this worker exposes no such endpoint. It is read-only by construction, not by configuration.
Rate limits and cost
The public APIs answer roughly 20 requests a second without throttling, and the worker batches the expensive per-outcome reads, so a correlated LATERAL over many rows stays practical. Origin cache directives are forwarded; live book and quote endpoints declare none and stay uncached.
Sources
- Polymarket β the prediction market this data comes from.
- Polymarket API documentation β the three public read APIs this worker calls:
- Gamma API (
gamma-api.polymarket.com) β tags, series, events, markets and search. - CLOB API (
clob.polymarket.com) β order books, quotes, midpoints and price history. - Data API v2 (
data-api.polymarket.com/v2) β trades, holders, positions and wallet activity.
- Gamma API (
- Market data overview β how Polymarket organizes events, markets and outcome tokens.
No API key or account is needed for any of them.
Terms of use
The market data is Polymarket's, not covered by this worker's MIT license, and is subject to the Polymarket Terms of Use. This worker is not affiliated with or endorsed by Polymarket.
Catalog
Everything polymarket exposes once attached β read straight from the worker's
released build.
main 2 tables Β· 16 functions
Polymarket public market data β no credentials required
Schema examples (20)
Find the topic you want, then its id
SELECT tag_id, label, slug
FROM polymarket.main.tags
WHERE label ILIKE '%crypto%'
ORDER BY label;
The busiest open markets right now, with their implied probabilities
SELECT question, outcomes, volume_24hr
FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20;
| question | outcomes | volume_24hr |
|---|---|---|
| Will the Fed increase interest rates by 50+ bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "35090254409399344650860070β¦ | 1,723,997.1 |
| Will Bitcoin dip to $50,000 by December 31, 2026? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "13887983551129862992605123β¦ | 1,591,448.9 |
| Will the Fed increase interest rates by 25 bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "11166212965282826688936037β¦ | 1,306,369.5 |
| Will there be no change in Fed interest rates after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "42865728742506860386768556β¦ | 1,208,574.3 |
| Will the Fed decrease interest rates by 50+ bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "17640596861394454242836532β¦ | 815,000.8 |
Every outcome of every crypto market, one row per outcome
SELECT m.question, o.outcome, o.price, o.token_id
FROM polymarket.main.markets(tag_id => '21', closed => 'false') m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o
ORDER BY m.volume_24hr DESC
LIMIT 50;
Live top-of-book for every outcome in a topic, via LATERAL
SELECT m.question, o.outcome, q.midpoint, q.spread
FROM polymarket.main.markets(tag_id => '21', closed => 'false', order_by => 'volume24hr', ascending => 'false') m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.quote(o.token_id) q
LIMIT 40;
16 more examples
Total resting size on each side of a topic's books
SELECT b.side, sum(b.size) AS resting
FROM polymarket.main.markets(tag_id => '21', closed => 'false') m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.orderbook(o.token_id) b
GROUP BY b.side;
A week of hourly implied probability for the busiest open market
SELECT h.ts, h.price
FROM (SELECT o.token_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o LIMIT 1) t,
LATERAL polymarket.main.price_history(t.token_id, '1w', 60) h
ORDER BY h.ts;
This week's movers: each outcome of the five busiest open markets, from the first point of its past-week hourly history to its live midpoint
WITH tokens AS (SELECT m.question, o.outcome, o.token_id FROM (SELECT question, outcomes FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 5) m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o), week AS (SELECT t.question, t.outcome, t.token_id, arg_min(h.price, h.ts) AS first_price FROM tokens t, LATERAL polymarket.main.price_history(t.token_id, '1w', 60) h GROUP BY t.question, t.outcome, t.token_id) SELECT w.question, w.outcome, w.first_price, q.midpoint, q.midpoint - w.first_price AS change
FROM week w,
LATERAL polymarket.main.quote(w.token_id) q
ORDER BY abs(change) DESC NULLS LAST, w.question, w.outcome;
The most recent prints on the busiest open market, with who traded
SELECT t.ts, t.side, t.outcome, t.price, t.size, t.trader_name
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.trades(m.condition_id, 100, '') t
ORDER BY t.ts DESC;
Who holds the biggest positions in the busiest open market
SELECT h.outcome_index, h.holder_name, h.amount
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.holders(m.condition_id, 20) h
ORDER BY h.amount DESC;
What the busiest open market's largest holders' stakes are worth at each outcome's live midpoint
SELECT h.outcome_index, h.holder_name, h.amount, q.midpoint,
h.amount * q.midpoint AS marked_value
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.holders(m.condition_id, 20) h,
LATERAL polymarket.main.quote(h.token_id) q
ORDER BY marked_value DESC;
Follow the biggest holder in a busy market to everything else they hold
SELECT p.title, p.outcome, p.size, p.cash_pnl
FROM (SELECT h.proxy_wallet FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m, LATERAL polymarket.main.holders(m.condition_id, 20) h ORDER BY h.amount DESC LIMIT 1) w,
LATERAL polymarket.main.positions(w.proxy_wallet, 100) p
ORDER BY p.current_value DESC;
The biggest open events, and the markets under one of them
SELECT m.question, m.volume_24hr
FROM (SELECT event_id FROM polymarket.main.events(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) e,
LATERAL polymarket.main.event_markets(e.event_id) m
ORDER BY m.volume_24hr DESC NULLS LAST;
Find events by subject, then the markets under the best match
SELECT m.question, m.outcomes
FROM (SELECT event_id FROM polymarket.main.search('bitcoin') LIMIT 1) e,
LATERAL polymarket.main.event_markets(e.event_id) m;
How the biggest holder in a busy market built their position
SELECT a.ts, a.activity_type, a.side, a.price, a.size
FROM (SELECT h.proxy_wallet FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m, LATERAL polymarket.main.holders(m.condition_id, 20) h ORDER BY h.amount DESC LIMIT 1) w,
LATERAL polymarket.main.activity(w.proxy_wallet, 500, '') a
ORDER BY a.ts DESC;
Pre-fee displayed-book cost of 5,000 shares in the ten busiest open markets, against what the touch advertises
SELECT m.question, o.outcome, q.midpoint, f.avg_price, f.slippage,
f.fully_filled
FROM (SELECT question, outcomes, volume_24hr FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 10) m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.quote(o.token_id) q,
LATERAL polymarket.main.fill_price(o.token_id, 'buy', 5000) f
ORDER BY m.volume_24hr DESC, o.outcome_index;
Active recurring series by recent volume
SELECT slug, title, recurrence, volume_24hr
FROM polymarket.main.series
WHERE active AND NOT closed
ORDER BY volume_24hr DESC NULLS LAST
LIMIT 20;
Topics read from the scan function behind the tags table
SELECT tag_id, label
FROM polymarket.main.all_tags()
WHERE label ILIKE '%politics%';
Series read from the scan function behind the series table
SELECT slug, title
FROM polymarket.main.all_series()
WHERE recurrence = 'daily'
LIMIT 20;
The event behind the busiest open market
SELECT e.title, e.volume_24hr, e.end_date
FROM (SELECT event_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.event(m.event_id) e;
The question behind a market, by its on-chain id
SELECT m.question, m.volume_24hr
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) t,
LATERAL polymarket.main.market(t.condition_id) m;
series
Recurring question series, each opening a new event per occurrence
Active recurring series by recent volume
SELECT slug, title, recurrence, volume_24hr
FROM polymarket.main.series
WHERE active AND NOT closed
ORDER BY volume_24hr DESC NULLS LAST
LIMIT 20;
How many series run at each cadence
SELECT recurrence, count(*) AS series_count
FROM polymarket.main.series
GROUP BY recurrence
ORDER BY series_count DESC;
tags
Every topic on Polymarket; the tag_id everything else filters on
Find the tag id for a topic
SELECT tag_id, label, slug
FROM polymarket.main.tags
WHERE label ILIKE '%crypto%'
ORDER BY label;
Topics whose tags were published most recently
SELECT label, slug, published_at
FROM polymarket.main.tags
WHERE published_at IS NOT NULL
ORDER BY published_at DESC
LIMIT 20;
activity (proxy_wallet VARCHAR, max_rows BIGINT, activity_type VARCHAR)
One wallet's history of trades, redemptions, yield and rebates
How the biggest holder in a busy market built their position
SELECT a.ts, a.activity_type, a.side, a.price, a.size
FROM (SELECT h.proxy_wallet FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m, LATERAL polymarket.main.holders(m.condition_id, 20) h ORDER BY h.amount DESC LIMIT 1) w,
LATERAL polymarket.main.activity(w.proxy_wallet, 500, '') a
ORDER BY a.ts DESC;
What kinds of activity a large wallet actually generates
SELECT a.activity_type, count(*) AS entries
FROM (SELECT h.proxy_wallet FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m, LATERAL polymarket.main.holders(m.condition_id, 20) h ORDER BY h.amount DESC LIMIT 1) w,
LATERAL polymarket.main.activity(w.proxy_wallet, 500, '') a
GROUP BY a.activity_type
ORDER BY entries DESC;
all_series ()
Every Polymarket series (the scan backing the series table)
Active recurring series by recent volume, read from the scan function
SELECT slug, title, recurrence, volume_24hr
FROM polymarket.main.all_series()
WHERE active AND NOT closed
ORDER BY volume_24hr DESC NULLS LAST
LIMIT 20;
all_tags ()
Every Polymarket topic tag (the scan backing the tags table)
Find the tag id for a topic, read from the scan function
SELECT tag_id, label, slug
FROM polymarket.main.all_tags()
WHERE label ILIKE '%crypto%'
ORDER BY label;
event (event_id VARCHAR)
Look up one Polymarket event by its Gamma id
-
tag_idVARCHAR
-
labelVARCHAR
-
slugVARCHAR
The event behind the busiest open market
SELECT e.title, e.volume_24hr, e.end_date
FROM (SELECT event_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.event(m.event_id) e;
Open interest of the events behind the busiest markets
SELECT DISTINCT e.title, e.open_interest
FROM (SELECT event_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 5) m,
LATERAL polymarket.main.event(m.event_id) e
ORDER BY e.open_interest DESC NULLS LAST;
event_markets (event_id VARCHAR)
Every tradeable market grouped under one Polymarket event
-
outcome_indexINTEGER
-
outcomeVARCHAR
-
token_idVARCHAR
-
priceDECIMAL(18,6)
Every candidate market under the biggest open event
SELECT m.question, m.outcomes, m.volume_24hr
FROM (SELECT event_id FROM polymarket.main.events(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) e,
LATERAL polymarket.main.event_markets(e.event_id) m
ORDER BY m.volume_24hr DESC NULLS LAST;
How many markets each of the busiest events carries
SELECT e.title, count(*) AS markets
FROM (SELECT event_id, title FROM polymarket.main.events(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 5) e,
LATERAL polymarket.main.event_markets(e.event_id) m
GROUP BY e.title
ORDER BY markets DESC;
events (ascending := VARCHAR, closed := VARCHAR, featured := VARCHAR, order_by := VARCHAR, series_slug := VARCHAR, slug := VARCHAR, tag_id := VARCHAR, title_search := VARCHAR)
Browse the events that group Polymarket's markets by resolution
-
tag_idVARCHAR
-
labelVARCHAR
-
slugVARCHAR
The biggest open events by 24-hour volume
SELECT slug, title, volume_24hr, liquidity
FROM polymarket.main.events(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20;
Which topics an event is filed under, one row per tag
SELECT e.title, (unnest(e.tags)).label AS topic
FROM polymarket.main.events(closed => 'false', order_by => 'volume24hr', ascending => 'false') e
LIMIT 40;
fill_price (token_id VARCHAR, side VARCHAR, size BIGINT)
Displayed-book fill price and slippage for a given order size, before fees
Displayed-book cost of 5,000 shares on the busiest market, before fees
SELECT f.side, f.avg_price, f.touch_price, f.slippage, f.fully_filled
FROM (SELECT o.token_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o LIMIT 1) t,
LATERAL polymarket.main.fill_price(t.token_id, 'buy', 5000) f;
Which outcomes in a topic can absorb real size, and which cannot
SELECT m.question, o.outcome, f.avg_price, f.filled_size, f.fully_filled
FROM polymarket.main.markets(tag_id => '21', closed => 'false', order_by => 'volume24hr', ascending => 'false') m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.fill_price(o.token_id, 'buy', 10000) f
WHERE NOT f.fully_filled
LIMIT 20;
holders (condition_id VARCHAR, max_rows BIGINT)
Who holds the largest positions in one Polymarket market
The biggest positions in the busiest open market
SELECT h.outcome_index, h.holder_name, h.amount
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.holders(m.condition_id, 20) h
ORDER BY h.amount DESC;
How concentrated each side of a market is
SELECT h.token_id, count(*) AS holders, sum(h.amount) AS shares,
max(h.amount) / sum(h.amount) AS top_holder_share
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.holders(m.condition_id, 20) h
GROUP BY h.token_id;
What the busiest open market's largest holders' stakes are worth at each outcome's live midpoint
SELECT h.outcome_index, h.holder_name, h.amount, q.midpoint,
h.amount * q.midpoint AS marked_value
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.holders(m.condition_id, 20) h,
LATERAL polymarket.main.quote(h.token_id) q
ORDER BY marked_value DESC;
market (condition_id VARCHAR)
Look up one Polymarket market by its on-chain condition id
-
outcome_indexINTEGER
-
outcomeVARCHAR
-
token_idVARCHAR
-
priceDECIMAL(18,6)
The question behind the busiest open market
SELECT m.question, m.volume_24hr
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) t,
LATERAL polymarket.main.market(t.condition_id) m;
Join a market's trade tape back to its question
SELECT m.question, count(*) AS prints
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 3) s,
LATERAL polymarket.main.market(s.condition_id) m,
LATERAL polymarket.main.trades(s.condition_id, 100, '') t
GROUP BY m.question;
markets (active := VARCHAR, ascending := VARCHAR, closed := VARCHAR, condition_id := VARCHAR, order_by := VARCHAR, slug := VARCHAR, tag_id := VARCHAR)
Browse Polymarket's tradeable questions with their prices and volume
-
outcome_indexINTEGER
-
outcomeVARCHAR
-
token_idVARCHAR
-
priceDECIMAL(18,6)
The busiest open markets right now, with their implied probabilities
SELECT question, outcomes, volume_24hr
FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20;
| question | outcomes | volume_24hr |
|---|---|---|
| Will the Fed increase interest rates by 50+ bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "35090254409399344650860070β¦ | 1,723,997.1 |
| Will Bitcoin dip to $50,000 by December 31, 2026? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "13887983551129862992605123β¦ | 1,591,448.9 |
| Will the Fed increase interest rates by 25 bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "11166212965282826688936037β¦ | 1,306,369.5 |
| Will there be no change in Fed interest rates after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "42865728742506860386768556β¦ | 1,208,574.3 |
| Will the Fed decrease interest rates by 50+ bps after the December 2026 meeting? | [{"outcome_index": 0, "outcome": "Yes", "token_id": "17640596861394454242836532β¦ | 815,000.8 |
Every outcome of every crypto market, one row per outcome
SELECT m.question, o.outcome, o.price, o.token_id
FROM polymarket.main.markets(tag_id => '21', closed => 'false') m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o
ORDER BY m.volume_24hr DESC
LIMIT 50;
orderbook (token_id VARCHAR)
Resting order-book depth for one outcome, one row per side and price level
Full depth on both sides of one actively traded outcome's book
WITH t AS (SELECT o.token_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o LIMIT 10), books AS (SELECT t.token_id, b.side, b.price, b.size FROM t, LATERAL polymarket.main.orderbook(t.token_id) b) SELECT side, price, size
FROM books
WHERE token_id = (SELECT min(token_id) FROM books)
ORDER BY side, price DESC;
Total resting size per side across a whole topic, in one query
SELECT b.side, sum(b.size) AS resting
FROM polymarket.main.markets(tag_id => '21', closed => 'false') m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.orderbook(o.token_id) b
GROUP BY b.side;
positions (proxy_wallet VARCHAR, max_rows BIGINT)
Every open position one wallet holds, with its profit and loss
What else the biggest holder in a busy market is betting on
SELECT p.title, p.outcome, p.size, p.cash_pnl
FROM (SELECT h.proxy_wallet FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m, LATERAL polymarket.main.holders(m.condition_id, 20) h ORDER BY h.amount DESC LIMIT 1) w,
LATERAL polymarket.main.positions(w.proxy_wallet, 100) p
ORDER BY p.current_value DESC;
How that holder's book is doing overall
SELECT count(*) AS positions, sum(p.current_value) AS value,
sum(p.cash_pnl) AS unrealised
FROM (SELECT h.proxy_wallet FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m, LATERAL polymarket.main.holders(m.condition_id, 20) h ORDER BY h.amount DESC LIMIT 1) w,
LATERAL polymarket.main.positions(w.proxy_wallet, 100) p;
price_history (token_id VARCHAR, period VARCHAR, fidelity BIGINT)
How one outcome's price moved over time, as a sampled series
A week of hourly implied probability for the busiest open market
SELECT h.ts, h.price
FROM (SELECT o.token_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o LIMIT 1) t,
LATERAL polymarket.main.price_history(t.token_id, '1w', 60) h
ORDER BY h.ts;
How far each outcome moved over the last day
SELECT o.outcome, max(h.price) - min(h.price) AS swing
FROM (SELECT outcomes FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 3) m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.price_history(o.token_id, '1d', 60) h
GROUP BY o.outcome
ORDER BY swing DESC;
This week's movers: each outcome of the five busiest open markets, from the first point of its past-week hourly history to its live midpoint
WITH tokens AS (SELECT m.question, o.outcome, o.token_id FROM (SELECT question, outcomes FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 5) m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o), week AS (SELECT t.question, t.outcome, t.token_id, arg_min(h.price, h.ts) AS first_price FROM tokens t, LATERAL polymarket.main.price_history(t.token_id, '1w', 60) h GROUP BY t.question, t.outcome, t.token_id) SELECT w.question, w.outcome, w.first_price, q.midpoint, q.midpoint - w.first_price AS change
FROM week w,
LATERAL polymarket.main.quote(w.token_id) q
ORDER BY abs(change) DESC NULLS LAST, w.question, w.outcome;
quote (token_id VARCHAR)
Current best bid, best ask, midpoint and spread for one outcome
Live implied probability of every outcome in a topic
SELECT m.question, o.outcome, q.midpoint, q.spread
FROM polymarket.main.markets(tag_id => '21', closed => 'false', order_by => 'volume24hr', ascending => 'false') m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.quote(o.token_id) q
LIMIT 40;
The widest spreads among the 50 busiest open markets β where liquidity is thin
SELECT m.question, o.outcome, q.spread
FROM (SELECT question, outcomes FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 50) m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o,
LATERAL polymarket.main.quote(o.token_id) q
WHERE q.spread IS NOT NULL
ORDER BY q.spread DESC
LIMIT 20;
search (query VARCHAR, events_status := VARCHAR)
Find events by searching their text, the way the site's search box does
-
tag_idVARCHAR
-
labelVARCHAR
-
slugVARCHAR
Find the events matching a subject, best matches first
SELECT event_id, title, volume_24hr
FROM polymarket.main.search('bitcoin')
LIMIT 10;
Search for a subject, then the tradeable markets under the best match
SELECT m.question, m.outcomes
FROM (SELECT event_id FROM polymarket.main.search('federal reserve') LIMIT 1) e,
LATERAL polymarket.main.event_markets(e.event_id) m;
trades (condition_id VARCHAR, max_rows BIGINT, side VARCHAR)
Executed trades on one Polymarket market, with the trader behind each
The most recent prints on the busiest open market
SELECT t.ts, t.side, t.outcome, t.price, t.size, t.trader_name
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.trades(m.condition_id, 100, '') t
ORDER BY t.ts DESC;
Volume-weighted average price by outcome, from the tape
SELECT t.outcome, sum(t.price * t.size) / sum(t.size) AS vwap
FROM (SELECT condition_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) m,
LATERAL polymarket.main.trades(m.condition_id, 100, '') t
GROUP BY t.outcome;
Try these queries
tags_catalog_is_populated β The tag catalog streams thousands of topics.
SELECT count(*) > 500
FROM (SELECT tag_id FROM polymarket.main.tags LIMIT 600);
Uses tags
series_and_scan_function_agree β The `series` table and the `all_series` function behind it are the same rows.
SELECT (SELECT count(*) FROM (SELECT series_id FROM polymarket.main.series LIMIT 100)) = (SELECT count(*) FROM (SELECT series_id FROM polymarket.main.all_series() LIMIT 100));
Uses seriesall_series
a_limit_stops_the_scan_early β A paged scan yields its first rows without walking every page β the property that keeps a LIMIT over a large catalog from wedging the client.
SELECT count(*)
FROM (SELECT question FROM polymarket.main.markets() LIMIT 5);
Uses markets
The biggest open events, and the markets under one of them
SELECT m.question, m.volume_24hr
FROM (SELECT event_id FROM polymarket.main.events(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 1) e,
LATERAL polymarket.main.event_markets(e.event_id) m
ORDER BY m.volume_24hr DESC NULLS LAST
Uses eventsevent_markets
Find events by subject, then the markets under the best match
SELECT m.question, m.outcomes
FROM (SELECT event_id FROM polymarket.main.search('bitcoin') LIMIT 1) e,
LATERAL polymarket.main.event_markets(e.event_id) m
Uses searchevent_markets
Topics read from the scan function behind the tags table
SELECT tag_id, label
FROM polymarket.main.all_tags()
WHERE label ILIKE '%politics%'
Uses all_tags
7 more examples Hide 7 more
tags_and_scan_function_agree β The `tags` table and the `all_tags` function behind it are the same rows.
SELECT (SELECT count(*) FROM (SELECT tag_id FROM polymarket.main.tags LIMIT 200)) = (SELECT count(*) FROM (SELECT tag_id FROM polymarket.main.all_tags() LIMIT 200));
prices_are_exact_decimals β Money comes back as DECIMAL, never a float.
SELECT typeof(volume_24hr) FROM polymarket.main.markets() LIMIT 1;
Uses markets
outcomes_carry_their_tokens β Every outcome is zipped with the CLOB token that trades it β the join key the order book needs.
SELECT bool_and(o.token_id IS NOT NULL)
FROM (SELECT outcomes FROM polymarket.main.markets(closed => 'false') LIMIT 20) m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o;
Uses markets
closed_filter_is_applied_by_the_origin β The closed filter reaches Gamma rather than being applied after the fact.
SELECT bool_and(NOT closed)
FROM (SELECT closed FROM polymarket.main.markets(closed => 'false') LIMIT 100);
Uses markets
orderbook_sides_are_bid_or_ask β A book flattens to labelled sides, or to nothing when it is empty.
SELECT bool_and(side IN ('bid', 'ask')) IS NOT FALSE
FROM (SELECT b.side FROM (SELECT o.token_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o LIMIT 5) t, LATERAL polymarket.main.orderbook(t.token_id) b LIMIT 50);
a_quote_is_ordered_bid_then_ask β best_ask is never below best_bid, which pins the BUY/SELL naming.
SELECT bool_and(q.best_ask >= q.best_bid) IS NOT FALSE
FROM (SELECT o.token_id FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') m, LATERAL (SELECT unnest(m.outcomes, recursive := true)) o LIMIT 5) t,
LATERAL polymarket.main.quote(t.token_id) q;
prices_read_as_probabilities β Every outcome price sits between 0 and 1, so it reads as a probability.
SELECT bool_and(o.price BETWEEN 0 AND 1) IS NOT FALSE
FROM (SELECT outcomes FROM polymarket.main.markets(closed => 'false') LIMIT 50) m,
LATERAL (SELECT unnest(m.outcomes, recursive := true)) o
WHERE o.price IS NOT NULL;
Uses markets
37 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- What topics does Polymarket cover for crypto? Give me a tag id I can filter on.
- Which Polymarket markets are busiest right now, and what probability does each outcome imply?
- Show me the resting order book for one outcome of any busy open Polymarket market.
- Chart how the probability of one outcome of a busy Polymarket market moved over the last week.
- What were the last few trades on the busiest open Polymarket market, and who was on the other side?
- Who holds the largest positions in the busiest open Polymarket market?
Polymarket is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Kalshi
Markets & finance
Kalshi prediction markets β markets, order books, candlesticks, trades and events
CCXT
Markets & finance
Candles, quotes, order books, trades and perpetual funding from 100+ crypto exchanges
First Trust ETFs
Markets & finance
Screen First Trust US ETFs and see each fund's facts and current holdings