Skip to content

Polymarket

Live odds, order books, trades and on-chain holders, read-only

Connector software
Free and open source
Service credentials
Not needed
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
Result Β· first 5 rows
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.

setup.sql
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;

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'
);

3. Run a query

query.sql
SELECT question, outcomes, volume_24hr
FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false')
LIMIT 20
More example queries β†’
Technical details
Verified connector release
v0.2.1
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
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'
);

Overview

What the crowd thinks a future event is worth, priced as a probability β€” read-only Polymarket data, including who holds each position

Catalog

Everything polymarket exposes once attached β€” read straight from the worker's released build.

polymarket 1 schema
main 2 tables Β· 16 functions

Polymarket public market data β€” no credentials required

Schema examples (20)
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;
Result Β· first 5 rows
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;
Tables
series 2 examples16 cols

Recurring question series, each opening a new event per occurrence

Columns
series_idnot null VARCHAR
Gamma's numeric id for the series, as a string.
slug VARCHAR
URL slug; the value events() accepts as its series_slug filter.
ticker VARCHAR
Short label Polymarket uses for the series, e.g. 'nfl'.
title VARCHAR
Human-readable name of the series, e.g. 'NFL'.
description VARCHAR
What the series covers.
series_type VARCHAR
How the series is structured, e.g. 'single'.
recurrence VARCHAR
How often a new event opens, e.g. 'daily' or 'weekly'.
active BOOLEAN
Whether the series is live on the site.
closed BOOLEAN
Whether the series has ended.
archived BOOLEAN
Whether Polymarket has archived the series.
featured BOOLEAN
Whether Polymarket is featuring the series.
volume_24hr DECIMAL(28,6)
Traded volume across the series over the last 24 hours, in USDC.
comment_count INTEGER
Count of comments left across the series' event pages.
start_date TIMESTAMP WITH TIME ZONE
When the series began.
created_at TIMESTAMP WITH TIME ZONE
When the series was created in Gamma.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified this series' record.
ConstraintsPRIMARY KEY (series_id)
Examples (2)

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;
Link
tags 2 examples6 cols

Every topic on Polymarket; the tag_id everything else filters on

Columns
tag_idnot null VARCHAR
Gamma's numeric id for the tag, as a string; the key markets() filters on.
label VARCHAR
Display name of the tag, e.g. 'Crypto' or 'Politics'.
slug VARCHAR
URL slug for the tag.
created_at TIMESTAMP WITH TIME ZONE
When the tag was created.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified the tag.
published_at TIMESTAMP WITH TIME ZONE
When the tag was published, when it has been.
ConstraintsPRIMARY KEY (tag_id)
Examples (2)

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;
Link
Table functions
activity (proxy_wallet VARCHAR, max_rows BIGINT, activity_type VARCHAR) 2 examples

One wallet's history of trades, redemptions, yield and rebates

Arguments
proxy_wallet VARCHAR
Wallet address whose history to read
max_rows BIGINT
Stop after this many entries (1-5000)
activity_type VARCHAR
Keep only entries of this kind; empty for all of them
Returns columns
proxy_wallet VARCHAR
Address of the wallet this activity belongs to.
ts TIMESTAMP WITH TIME ZONE
When it happened; the column to order and poll on.
activity_type VARCHAR
What happened: TRADE, REDEEM, YIELD, MERGE, SPLIT, CONVERSION, or one of the MAKER_REBATE / TAKER_REBATE / REWARD / REFERRAL_REWARD incentive payments. Only TRADE rows carry a price and a side; the rest leave them NULL.
condition_id VARCHAR
Market involved; NULL for activity not tied to one.
token_id VARCHAR
Outcome token involved; NULL for activity not tied to one.
outcome VARCHAR
Name of that outcome, when there is one.
outcome_index INTEGER
Position of that outcome in the market's outcome list.
side VARCHAR
Direction for a TRADE: 'BUY' or 'SELL'; NULL otherwise.
price DECIMAL(18,6)
Price per share, 0 to 1, for a TRADE; NULL otherwise.
size DECIMAL(28,6)
Shares involved.
usdc_size DECIMAL(28,6)
USDC value of the activity.
transaction_hash VARCHAR
On-chain transaction that recorded it.
title VARCHAR
Question the market asks, when the activity names one.
event_slug VARCHAR
Slug of the event the market belongs to.
trader_name VARCHAR
Display name the wallet has set, when it has one.
pseudonym VARCHAR
Polymarket's generated pseudonym for the wallet.
Examples (2)

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;
Link
all_series () 1 example

Every Polymarket series (the scan backing the series table)

No arguments
Returns columns
series_id VARCHAR
Gamma's numeric id for the series, as a string.
slug VARCHAR
URL slug; the value events() accepts as its series_slug filter.
ticker VARCHAR
Short label Polymarket uses for the series, e.g. 'nfl'.
title VARCHAR
Human-readable name of the series, e.g. 'NFL'.
description VARCHAR
What the series covers.
series_type VARCHAR
How the series is structured, e.g. 'single'.
recurrence VARCHAR
How often a new event opens, e.g. 'daily' or 'weekly'.
active BOOLEAN
Whether the series is live on the site.
closed BOOLEAN
Whether the series has ended.
archived BOOLEAN
Whether Polymarket has archived the series.
featured BOOLEAN
Whether Polymarket is featuring the series.
volume_24hr DECIMAL(28,6)
Traded volume across the series over the last 24 hours, in USDC.
comment_count INTEGER
Count of comments left across the series' event pages.
start_date TIMESTAMP WITH TIME ZONE
When the series began.
created_at TIMESTAMP WITH TIME ZONE
When the series was created in Gamma.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified this series' record.
Example

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;
Link
all_tags () 1 example

Every Polymarket topic tag (the scan backing the tags table)

No arguments
Returns columns
tag_id VARCHAR
Gamma's numeric id for the tag, as a string; the key markets() filters on.
label VARCHAR
Display name of the tag, e.g. 'Crypto' or 'Politics'.
slug VARCHAR
URL slug for the tag.
created_at TIMESTAMP WITH TIME ZONE
When the tag was created.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified the tag.
published_at TIMESTAMP WITH TIME ZONE
When the tag was published, when it has been.
Example

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;
Link
event (event_id VARCHAR) 2 examples

Look up one Polymarket event by its Gamma id

Arguments
event_id VARCHAR
Gamma id of the event to look up
Returns columns
event_id VARCHAR
Gamma's numeric id for the event, as a string; the key event() takes.
slug VARCHAR
URL slug on polymarket.com; also a filter argument on markets().
ticker VARCHAR
Short label Polymarket uses for the event.
title VARCHAR
Question or headline the event asks.
description VARCHAR
Longer description of what the event covers.
active BOOLEAN
Whether the event is live on the site.
closed BOOLEAN
Whether every market under the event has stopped trading.
archived BOOLEAN
Whether Polymarket has archived the event out of its listings.
featured BOOLEAN
Whether Polymarket is featuring the event on its front page.
neg_risk BOOLEAN
Whether the markets under this event are mutually exclusive.
market_count INTEGER
How many markets sit under this event.
start_date TIMESTAMP WITH TIME ZONE
When the event opened.
end_date TIMESTAMP WITH TIME ZONE
When the event is scheduled to resolve.
creation_date TIMESTAMP WITH TIME ZONE
When the event was created.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified this event's record.
volume DECIMAL(28,6)
Lifetime traded volume across every market under the event, in USDC.
volume_24hr DECIMAL(28,6)
Traded volume across the event over the last 24 hours.
liquidity DECIMAL(28,6)
USDC resting in the books of every market under the event.
open_interest DECIMAL(28,6)
USDC value of positions currently outstanding under the event.
comment_count INTEGER
Count of comments left on the event page.
competitive DECIMAL(18,6)
Polymarket's own 0-to-1 score for how contested the event is.
tags STRUCT of 3 fields[]
Topic tags on the event, each a {tag_id, label, slug} struct. Kept nested β€” flattening would fan every event out into one row per tag.
STRUCT[] 3 fields
  • tag_idVARCHAR
  • labelVARCHAR
  • slugVARCHAR
Examples (2)

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;
Link
event_markets (event_id VARCHAR) 2 examples

Every tradeable market grouped under one Polymarket event

Arguments
event_id VARCHAR
Gamma id of the event to look up
Returns columns
condition_id VARCHAR
On-chain id of this market (0x + 64 hex). The key trades() and holders() take β€” but NOT the key the order book takes, which is a token_id from `outcomes`.
market_id VARCHAR
Gamma's own numeric id for the market, as a string.
slug VARCHAR
URL slug on polymarket.com; also a filter argument on markets().
question VARCHAR
The question this market settles, e.g. 'Xi Jinping out before 2027?'.
event_slug VARCHAR
Slug of the event grouping this market with the others resolving alongside it.
event_id VARCHAR
Gamma id of that event; the key event() takes.
outcomes STRUCT of 4 fields[]
One entry per tradeable outcome: its name, its CLOB token_id, and its current price. Unnest this to reach orderbook(), which keys on token_id.
STRUCT[] 4 fields
  • outcome_indexINTEGER
  • outcomeVARCHAR
  • token_idVARCHAR
  • priceDECIMAL(18,6)
active BOOLEAN
Whether the market is live on the site. An inactive market is not necessarily closed.
closed BOOLEAN
Whether trading has ended. A closed market may not yet be resolved.
archived BOOLEAN
Whether Polymarket has archived the market out of its listings.
accepting_orders BOOLEAN
Whether the book is currently accepting orders; the closest thing to 'is it tradeable now'.
enable_order_book BOOLEAN
Whether this market trades on the CLOB at all.
start_date TIMESTAMP WITH TIME ZONE
When the market opened for trading.
end_date TIMESTAMP WITH TIME ZONE
When the market is scheduled to resolve.
created_at TIMESTAMP WITH TIME ZONE
When the market was created in Gamma.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified this market's record.
last_trade_price DECIMAL(18,6)
Price of the most recent trade, 0 to 1.
best_bid DECIMAL(18,6)
Best resting bid on the first outcome's token.
best_ask DECIMAL(18,6)
Best resting ask on the first outcome's token.
spread DECIMAL(18,6)
Difference between best ask and best bid.
volume DECIMAL(28,6)
Lifetime traded volume in USDC.
volume_24hr DECIMAL(28,6)
Traded volume over the last 24 hours; the liquidity signal to filter on.
volume_1wk DECIMAL(28,6)
Traded volume over the last week.
volume_1mo DECIMAL(28,6)
Traded volume over the last month.
liquidity DECIMAL(28,6)
USDC resting in the order book on both sides.
one_day_price_change DECIMAL(18,6)
Change in price over the last day, in dollars per share; negative when the price fell.
one_week_price_change DECIMAL(18,6)
Change in price over the last week.
order_price_min_tick_size DECIMAL(18,6)
Smallest price increment the book accepts, e.g. 0.001. Prices are exact multiples of this.
order_min_size DECIMAL(28,6)
Smallest order the book accepts, in shares.
neg_risk BOOLEAN
Whether this market is part of a negative-risk (mutually exclusive) group.
resolution_source VARCHAR
What Polymarket settles the market against, when stated.
description VARCHAR
The full resolution criteria β€” how the question is decided.
competitive DECIMAL(18,6)
Polymarket's own 0-to-1 score for how contested the market is.
Examples (2)

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;
Link
events (ascending := VARCHAR, closed := VARCHAR, featured := VARCHAR, order_by := VARCHAR, series_slug := VARCHAR, slug := VARCHAR, tag_id := VARCHAR, title_search := VARCHAR) 2 examples

Browse the events that group Polymarket's markets by resolution

Named arguments
ascending := VARCHAR
Sort direction to pair with order_by Β· default ""
closed := VARCHAR
'true' for events that have finished, 'false' for those still running; omitted, both are returned Β· default ""
featured := VARCHAR
Restrict to events Polymarket promotes on its front page Β· default ""
order_by := VARCHAR
Field to sort by before paging Β· default ""
series_slug := VARCHAR
Restrict to the events of one recurring series Β· default ""
slug := VARCHAR
Look up one event by its polymarket.com slug Β· default ""
tag_id := VARCHAR
Restrict to one topic, by the id from the tags table Β· default ""
title_search := VARCHAR
Case-insensitive substring to match against the title Β· default ""
Returns columns
event_id VARCHAR
Gamma's numeric id for the event, as a string; the key event() takes.
slug VARCHAR
URL slug on polymarket.com; also a filter argument on markets().
ticker VARCHAR
Short label Polymarket uses for the event.
title VARCHAR
Question or headline the event asks.
description VARCHAR
Longer description of what the event covers.
active BOOLEAN
Whether the event is live on the site.
closed BOOLEAN
Whether every market under the event has stopped trading.
archived BOOLEAN
Whether Polymarket has archived the event out of its listings.
featured BOOLEAN
Whether Polymarket is featuring the event on its front page.
neg_risk BOOLEAN
Whether the markets under this event are mutually exclusive.
market_count INTEGER
How many markets sit under this event.
start_date TIMESTAMP WITH TIME ZONE
When the event opened.
end_date TIMESTAMP WITH TIME ZONE
When the event is scheduled to resolve.
creation_date TIMESTAMP WITH TIME ZONE
When the event was created.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified this event's record.
volume DECIMAL(28,6)
Lifetime traded volume across every market under the event, in USDC.
volume_24hr DECIMAL(28,6)
Traded volume across the event over the last 24 hours.
liquidity DECIMAL(28,6)
USDC resting in the books of every market under the event.
open_interest DECIMAL(28,6)
USDC value of positions currently outstanding under the event.
comment_count INTEGER
Count of comments left on the event page.
competitive DECIMAL(18,6)
Polymarket's own 0-to-1 score for how contested the event is.
tags STRUCT of 3 fields[]
Topic tags on the event, each a {tag_id, label, slug} struct. Kept nested β€” flattening would fan every event out into one row per tag.
STRUCT[] 3 fields
  • tag_idVARCHAR
  • labelVARCHAR
  • slugVARCHAR
Examples (2)

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;
Link
fill_price (token_id VARCHAR, side VARCHAR, size BIGINT) 2 examples

Displayed-book fill price and slippage for a given order size, before fees

Arguments
token_id VARCHAR
Outcome token the order would trade
side VARCHAR
Direction of the order: buy consumes asks, sell consumes bids
size BIGINT
Shares the order is for
Returns columns
token_id VARCHAR
Outcome token the order would trade.
side VARCHAR
Direction priced: 'buy' consumes asks, 'sell' consumes bids.
requested_size DECIMAL(28,6)
Shares asked for.
filled_size DECIMAL(28,6)
Shares the resting book could actually supply.
fully_filled BOOLEAN
Whether the book covered the whole request. False means the rest of the order would move the price further than this row reports.
avg_price DECIMAL(18,6)
Size-weighted average price across every level consumed, before any applicable venue fees β€” the displayed-book fill price rather than the touch.
worst_price DECIMAL(18,6)
Price of the last level consumed; the far edge of the fill.
touch_price DECIMAL(18,6)
Best price on that side, for comparison with avg_price.
slippage DECIMAL(18,6)
avg_price minus touch_price for a buy, reversed for a sell. Always the cost of size, so never negative.
levels_consumed INTEGER
How many price levels the order would clear.
notional DECIMAL(28,6)
Pre-fee USDC notional of the filled portion.
Examples (2)

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;
Link
holders (condition_id VARCHAR, max_rows BIGINT) 3 examples

Who holds the largest positions in one Polymarket market

Arguments
condition_id VARCHAR
On-chain market id whose holders to list
max_rows BIGINT
How many holders to return per outcome
Returns columns
condition_id VARCHAR
Market these positions are in.
token_id VARCHAR
Outcome token held.
outcome_index INTEGER
Position of that outcome in the market's outcome list.
proxy_wallet VARCHAR
Address of the holder's Polymarket proxy wallet.
amount DECIMAL(28,6)
Shares of this outcome held.
holder_name VARCHAR
Display name the holder has set, when they have one.
pseudonym VARCHAR
Polymarket's generated pseudonym for the holder.
bio VARCHAR
Profile text the holder has written.
verified BOOLEAN
Whether Polymarket has verified this account.
Examples (3)

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;
Link
market (condition_id VARCHAR) 2 examples

Look up one Polymarket market by its on-chain condition id

Arguments
condition_id VARCHAR
On-chain market id to look up
Returns columns
condition_id VARCHAR
On-chain id of this market (0x + 64 hex). The key trades() and holders() take β€” but NOT the key the order book takes, which is a token_id from `outcomes`.
market_id VARCHAR
Gamma's own numeric id for the market, as a string.
slug VARCHAR
URL slug on polymarket.com; also a filter argument on markets().
question VARCHAR
The question this market settles, e.g. 'Xi Jinping out before 2027?'.
event_slug VARCHAR
Slug of the event grouping this market with the others resolving alongside it.
event_id VARCHAR
Gamma id of that event; the key event() takes.
outcomes STRUCT of 4 fields[]
One entry per tradeable outcome: its name, its CLOB token_id, and its current price. Unnest this to reach orderbook(), which keys on token_id.
STRUCT[] 4 fields
  • outcome_indexINTEGER
  • outcomeVARCHAR
  • token_idVARCHAR
  • priceDECIMAL(18,6)
active BOOLEAN
Whether the market is live on the site. An inactive market is not necessarily closed.
closed BOOLEAN
Whether trading has ended. A closed market may not yet be resolved.
archived BOOLEAN
Whether Polymarket has archived the market out of its listings.
accepting_orders BOOLEAN
Whether the book is currently accepting orders; the closest thing to 'is it tradeable now'.
enable_order_book BOOLEAN
Whether this market trades on the CLOB at all.
start_date TIMESTAMP WITH TIME ZONE
When the market opened for trading.
end_date TIMESTAMP WITH TIME ZONE
When the market is scheduled to resolve.
created_at TIMESTAMP WITH TIME ZONE
When the market was created in Gamma.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified this market's record.
last_trade_price DECIMAL(18,6)
Price of the most recent trade, 0 to 1.
best_bid DECIMAL(18,6)
Best resting bid on the first outcome's token.
best_ask DECIMAL(18,6)
Best resting ask on the first outcome's token.
spread DECIMAL(18,6)
Difference between best ask and best bid.
volume DECIMAL(28,6)
Lifetime traded volume in USDC.
volume_24hr DECIMAL(28,6)
Traded volume over the last 24 hours; the liquidity signal to filter on.
volume_1wk DECIMAL(28,6)
Traded volume over the last week.
volume_1mo DECIMAL(28,6)
Traded volume over the last month.
liquidity DECIMAL(28,6)
USDC resting in the order book on both sides.
one_day_price_change DECIMAL(18,6)
Change in price over the last day, in dollars per share; negative when the price fell.
one_week_price_change DECIMAL(18,6)
Change in price over the last week.
order_price_min_tick_size DECIMAL(18,6)
Smallest price increment the book accepts, e.g. 0.001. Prices are exact multiples of this.
order_min_size DECIMAL(28,6)
Smallest order the book accepts, in shares.
neg_risk BOOLEAN
Whether this market is part of a negative-risk (mutually exclusive) group.
resolution_source VARCHAR
What Polymarket settles the market against, when stated.
description VARCHAR
The full resolution criteria β€” how the question is decided.
competitive DECIMAL(18,6)
Polymarket's own 0-to-1 score for how contested the market is.
Examples (2)

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;
Link
markets (active := VARCHAR, ascending := VARCHAR, closed := VARCHAR, condition_id := VARCHAR, order_by := VARCHAR, slug := VARCHAR, tag_id := VARCHAR) 2 examples

Browse Polymarket's tradeable questions with their prices and volume

Named arguments
active := VARCHAR
Restrict to markets live on the site, or to those that are not Β· default ""
ascending := VARCHAR
Sort direction to pair with order_by Β· default ""
closed := VARCHAR
'true' for markets that have stopped trading, 'false' for open ones; omitted, Gamma returns open markets only Β· default ""
condition_id := VARCHAR
Look up one market by its on-chain id Β· default ""
order_by := VARCHAR
Field to sort by before paging Β· default ""
slug := VARCHAR
Look up one market by its polymarket.com slug Β· default ""
tag_id := VARCHAR
Restrict to one topic, by the id from the tags table Β· default ""
Returns columns
condition_id VARCHAR
On-chain id of this market (0x + 64 hex). The key trades() and holders() take β€” but NOT the key the order book takes, which is a token_id from `outcomes`.
market_id VARCHAR
Gamma's own numeric id for the market, as a string.
slug VARCHAR
URL slug on polymarket.com; also a filter argument on markets().
question VARCHAR
The question this market settles, e.g. 'Xi Jinping out before 2027?'.
event_slug VARCHAR
Slug of the event grouping this market with the others resolving alongside it.
event_id VARCHAR
Gamma id of that event; the key event() takes.
outcomes STRUCT of 4 fields[]
One entry per tradeable outcome: its name, its CLOB token_id, and its current price. Unnest this to reach orderbook(), which keys on token_id.
STRUCT[] 4 fields
  • outcome_indexINTEGER
  • outcomeVARCHAR
  • token_idVARCHAR
  • priceDECIMAL(18,6)
active BOOLEAN
Whether the market is live on the site. An inactive market is not necessarily closed.
closed BOOLEAN
Whether trading has ended. A closed market may not yet be resolved.
archived BOOLEAN
Whether Polymarket has archived the market out of its listings.
accepting_orders BOOLEAN
Whether the book is currently accepting orders; the closest thing to 'is it tradeable now'.
enable_order_book BOOLEAN
Whether this market trades on the CLOB at all.
start_date TIMESTAMP WITH TIME ZONE
When the market opened for trading.
end_date TIMESTAMP WITH TIME ZONE
When the market is scheduled to resolve.
created_at TIMESTAMP WITH TIME ZONE
When the market was created in Gamma.
updated_at TIMESTAMP WITH TIME ZONE
When Gamma last modified this market's record.
last_trade_price DECIMAL(18,6)
Price of the most recent trade, 0 to 1.
best_bid DECIMAL(18,6)
Best resting bid on the first outcome's token.
best_ask DECIMAL(18,6)
Best resting ask on the first outcome's token.
spread DECIMAL(18,6)
Difference between best ask and best bid.
volume DECIMAL(28,6)
Lifetime traded volume in USDC.
volume_24hr DECIMAL(28,6)
Traded volume over the last 24 hours; the liquidity signal to filter on.
volume_1wk DECIMAL(28,6)
Traded volume over the last week.
volume_1mo DECIMAL(28,6)
Traded volume over the last month.
liquidity DECIMAL(28,6)
USDC resting in the order book on both sides.
one_day_price_change DECIMAL(18,6)
Change in price over the last day, in dollars per share; negative when the price fell.
one_week_price_change DECIMAL(18,6)
Change in price over the last week.
order_price_min_tick_size DECIMAL(18,6)
Smallest price increment the book accepts, e.g. 0.001. Prices are exact multiples of this.
order_min_size DECIMAL(28,6)
Smallest order the book accepts, in shares.
neg_risk BOOLEAN
Whether this market is part of a negative-risk (mutually exclusive) group.
resolution_source VARCHAR
What Polymarket settles the market against, when stated.
description VARCHAR
The full resolution criteria β€” how the question is decided.
competitive DECIMAL(18,6)
Polymarket's own 0-to-1 score for how contested the market is.
Examples (2)

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;
Result Β· first 5 rows
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;
Link
orderbook (token_id VARCHAR) 2 examples

Resting order-book depth for one outcome, one row per side and price level

Arguments
token_id VARCHAR
Outcome token to read, from a market's outcomes list
Returns columns
token_id VARCHAR
Outcome token this price level belongs to.
condition_id VARCHAR
Market that token belongs to, as the CLOB reports it.
side VARCHAR
Which side rests here: 'bid' (buyers) or 'ask' (sellers).
price DECIMAL(18,6)
Price of this level, 0 to 1, in USDC per share.
size DECIMAL(28,6)
Shares resting at this price level.
book_timestamp TIMESTAMP WITH TIME ZONE
When the CLOB produced this snapshot of the book.
Examples (2)

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;
Link
positions (proxy_wallet VARCHAR, max_rows BIGINT) 2 examples

Every open position one wallet holds, with its profit and loss

Arguments
proxy_wallet VARCHAR
Wallet address whose open positions to list
max_rows BIGINT
Stop after this many positions; 0 fetches all of them
Returns columns
proxy_wallet VARCHAR
Address of the wallet holding this position.
condition_id VARCHAR
Market the position is in; the key trades() takes.
token_id VARCHAR
Outcome token held; the key orderbook() and quote() take.
outcome VARCHAR
Name of the outcome held, e.g. 'Yes'.
outcome_index INTEGER
Position of that outcome in the market's outcome list.
title VARCHAR
Question the market asks, denormalised onto each position.
event_slug VARCHAR
Slug of the event the market belongs to.
size DECIMAL(28,6)
Shares of this outcome currently held.
avg_price DECIMAL(18,6)
Average price paid per share, 0 to 1, in USDC.
cur_price DECIMAL(18,6)
Current price per share, 0 to 1; compare with avg_price for direction.
initial_value DECIMAL(28,6)
USDC paid to open the position, net of fees.
current_value DECIMAL(28,6)
USDC the position is worth at the current price.
cash_pnl DECIMAL(28,6)
Unrealised profit or loss in USDC; negative means a loss.
percent_pnl DECIMAL(18,6)
Unrealised profit or loss as a percentage of what was paid.
realized_pnl DECIMAL(28,6)
Profit or loss in USDC already taken by selling.
total_bought DECIMAL(28,6)
Shares bought over the life of the position, before any sales.
redeemable BOOLEAN
Whether the market has resolved and the position can be cashed out.
end_date TIMESTAMP WITH TIME ZONE
When the market is scheduled to resolve.
Examples (2)

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;
Link
price_history (token_id VARCHAR, period VARCHAR, fidelity BIGINT) 3 examples

How one outcome's price moved over time, as a sampled series

Arguments
token_id VARCHAR
Outcome token to chart, from a market's outcomes list
period VARCHAR
How far back to look, ending now
fidelity BIGINT
Minutes between sampled points
Returns columns
token_id VARCHAR
Outcome token this series covers.
ts TIMESTAMP WITH TIME ZONE
Instant this price was sampled at; the column to order and join on.
price DECIMAL(18,6)
Price at that instant, 0 to 1, readable directly as the market's implied probability.
Examples (3)

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;
Link
quote (token_id VARCHAR) 2 examples

Current best bid, best ask, midpoint and spread for one outcome

Arguments
token_id VARCHAR
Outcome token to read, from a market's outcomes list
Returns columns
token_id VARCHAR
Outcome token quoted.
best_bid DECIMAL(18,6)
Highest price a buyer is currently resting at.
best_ask DECIMAL(18,6)
Lowest price a seller is currently resting at.
midpoint DECIMAL(18,6)
Halfway between best bid and best ask; the usual 'the price' of an outcome.
spread DECIMAL(18,6)
best_ask minus best_bid; the cost of crossing the book.
last_trade_price DECIMAL(18,6)
Price of the most recent execution on this token.
min_order_size DECIMAL(28,6)
Smallest order this token's book accepts, in shares.
tick_size DECIMAL(18,6)
Smallest price increment this token's book accepts.
Examples (2)

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;
Link
trades (condition_id VARCHAR, max_rows BIGINT, side VARCHAR) 2 examples

Executed trades on one Polymarket market, with the trader behind each

Arguments
condition_id VARCHAR
On-chain market id whose tape to read
max_rows BIGINT
Stop after this many trades (1-10000)
side VARCHAR
Keep only trades the taker went this way on; empty for both
Returns columns
transaction_hash VARCHAR
On-chain transaction that settled this trade.
condition_id VARCHAR
Market the trade executed on.
token_id VARCHAR
Outcome token that changed hands.
outcome VARCHAR
Name of that outcome, e.g. 'Yes'.
outcome_index INTEGER
Position of that outcome in the market's outcome list.
side VARCHAR
Direction the taker went: 'BUY' or 'SELL'.
price DECIMAL(18,6)
Execution price, 0 to 1, in USDC per share.
size DECIMAL(28,6)
Shares exchanged.
ts TIMESTAMP WITH TIME ZONE
When the trade executed; the cursor to poll on.
proxy_wallet VARCHAR
Address of the trader's Polymarket proxy wallet.
trader_name VARCHAR
Display name the trader has set, when they have one.
pseudonym VARCHAR
Polymarket's generated pseudonym for the trader.
title VARCHAR
Question the market asks, denormalised onto each trade by the API.
event_slug VARCHAR
Slug of the event the market belongs to.
Examples (2)

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;
Link

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

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));

Uses tagsall_tags

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);

Uses marketsorderbook

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;

Uses marketsquote

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.