# Polymarket

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

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/polymarket.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `polymarket`. Release: [v0.2.1](https://github.com/Query-farm/vgi-polymarket/releases/tag/v0.2.1). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-polymarket) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=polymarket). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

No service credentials are declared by this connector. Individual datasets, input files or deployments may have their own prerequisites.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

## Install the extension

In stock DuckDB:

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

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### uvx

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

```sql
ATTACH 'polymarket' AS polymarket (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-polymarket@v0.2.1 vgi-polymarket'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'polymarket' AS polymarket (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-polymarket:0.2.1'
);
```

## Explore the busiest prediction markets

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
SELECT question, outcomes, volume_24hr FROM polymarket.main.markets(closed => 'false', order_by => 'volume24hr', ascending => 'false') LIMIT 20
```

- [polymarket.main.markets — table_function](https://query.farm/products/orchard/connectors/polymarket/objects/table_function.bWFpbg.bWFya2V0cw.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T06:16:30+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.2.1",
  "sample": {
    "columns": [
      "question",
      "outcomes",
      "volume_24hr"
    ],
    "types": [
      "VARCHAR",
      "STRUCT(outcome_index INTEGER, outcome VARCHAR, token_id VARCHAR, price DECIMAL(18,6))[]",
      "DECIMAL(28,6)"
    ],
    "rows": [
      [
        "Will the Fed increase interest rates by 50+ bps after the December 2026 meeting?",
        "[{\"outcome_index\": 0, \"outcome\": \"Yes\", \"token_id\": \"35090254409399344650860070…",
        1723997.136785
      ],
      [
        "Will Bitcoin dip to $50,000 by December 31, 2026?",
        "[{\"outcome_index\": 0, \"outcome\": \"Yes\", \"token_id\": \"13887983551129862992605123…",
        1591448.851506
      ],
      [
        "Will the Fed increase interest rates by 25 bps after the December 2026 meeting?",
        "[{\"outcome_index\": 0, \"outcome\": \"Yes\", \"token_id\": \"11166212965282826688936037…",
        1306369.493778
      ],
      [
        "Will there be no change in Fed interest rates after the December 2026 meeting?",
        "[{\"outcome_index\": 0, \"outcome\": \"Yes\", \"token_id\": \"42865728742506860386768556…",
        1208574.280673
      ],
      [
        "Will the Fed decrease interest rates by 50+ bps after the December 2026 meeting?",
        "[{\"outcome_index\": 0, \"outcome\": \"Yes\", \"token_id\": \"17640596861394454242836532…",
        815000.795334
      ]
    ],
    "more": true
  }
}
```

## Connector reference

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](https://polymarket.com) — the prediction market this data comes from.
- [Polymarket API documentation](https://docs.polymarket.com/api-reference) — the three public read APIs this worker calls:
  - [Gamma API](https://docs.polymarket.com/api-spec/gamma-openapi.yaml) (`gamma-api.polymarket.com`) — tags, series, events, markets and search.
  - [CLOB API](https://docs.polymarket.com/api-spec/clob-openapi.yaml) (`clob.polymarket.com`) — order books, quotes, midpoints and price history.
  - [Data API v2](https://data-api.polymarket.com/v2/docs) (`data-api.polymarket.com/v2`) — trades, holders, positions and wallet activity.
- [Market data overview](https://docs.polymarket.com/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](https://polymarket.com/tos). This worker is not affiliated with or endorsed by Polymarket.

## Find the exact SQL object

[Browse 18 object declarations](https://query.farm/products/orchard/api/v1/connectors/polymarket/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=polymarket&q=polymarket).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-polymarket",
  "harvest": {
    "status": "ok",
    "method": "subprocess",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 10,
    "passed": 10,
    "failed": 0,
    "needs_credentials": 0,
    "location": "uvx --from git+https://github.com/Query-farm/vgi-polymarket@v0.2.1 vgi-polymarket",
    "transport": "subprocess",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:15:56+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
