> For the complete documentation index, see [llms.txt](https://docs.slingdata.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.slingdata.io/connections/api-connections/polymarket.md).

# Polymarket

Connect & Ingest data from Polymarket

Polymarket is a prediction market platform built on Ethereum. The Sling Polymarket connector extracts data from Polymarket's three public REST APIs (Gamma, CLOB, and Data API v2) — markets, events, series, tags, on-chain trades, positions, holders, activity, and historical price data.

{% hint style="success" %}
**CLI Pro Required**: APIs require a [CLI Pro token](/sling-cli/cli-pro.md) or [Platform Plan](/sling-platform/platform.md).
{% endhint %}

## Setup

Polymarket's public REST APIs require **no authentication** — no API keys, no OAuth, no wallet. The connector accepts only optional inputs to control sync behavior and to scope user/token-specific endpoints.

**Secrets:** *(none required)*

**Inputs (optional):**

* `anchor_date` -> The starting date for the first incremental sync (ISO 8601 or `YYYY-MM-DD`). Defaults to 1 year ago. Used as the lower bound for time-range-filtered endpoints.
* `user_addresses` -> Comma-separated list of Polymarket proxy wallet addresses (`0x...`) to pull `positions`, `activity`, and `value` for. Required to enable these user-scoped endpoints.
* `token_ids` -> Comma-separated list of CLOB token IDs (the long numeric strings from `clob_markets.tokens[*].token_id` or `markets.clobTokenIds`). Required to enable `price_history`.
* `condition_ids` -> Comma-separated list of market condition IDs (`0x...` hex strings). Required to enable `holders`.

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set POLYMARKET type=api spec=polymarket inputs='{ anchor_date: "2026-01-01" }'
```

{% endcode %}

### Environment Variable

See [here](https://docs.slingdata.io/connections/api-connections/pages/eAdVs2BHCgdr6RS8GoJC#dot-env-file-.env.sling) to learn more about the `.env.sling` file.

{% code overflow="wrap" %}

```bash
export POLYMARKET='{ type: api, spec: polymarket, inputs: { anchor_date: "2026-01-01" } }'
```

{% endcode %}

### Sling Env File YAML

See [here](https://docs.slingdata.io/connections/api-connections/pages/eAdVs2BHCgdr6RS8GoJC#sling-env-file-env.yaml) to learn more about the sling `env.yaml` file.

```yaml
connections:
  POLYMARKET:
    type: api
    spec: polymarket
    inputs:
      anchor_date: "2026-01-01"
      user_addresses: "0x9d84cea69eba9b2c5c44a4cb9e26ae5e2dc56fbc"
      condition_ids: "0x9c1a953fe92c8357f1b646ba25d983aa83e90c525992db14fb726fa895cb5763"
      token_ids: "8501497159083948713316135768103773293754490207922884688769443031624417212426"
```

## Replication

Here's an example replication configuration to sync Polymarket data to a PostgreSQL database:

```yaml
source: POLYMARKET
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: polymarket.{stream_name}

streams:
  # market metadata (incremental on startDate)
  markets:
    mode: incremental
    primary_key: [id]
    update_key: startDate
  events:
    mode: incremental
    primary_key: [id]
    update_key: startDate

  # reference data
  series:
  tags:
  clob_markets:
  rewards_markets_current:

  # global trades feed (incremental on timestamp)
  trades:
    mode: incremental
    primary_key: [transactionHash, asset]
    update_key: timestamp
```

## Endpoints

### Gamma API — Market Discovery & Metadata

| Endpoint  | Description                                                  | Incremental          |
| --------- | ------------------------------------------------------------ | -------------------- |
| `markets` | Open prediction markets (Yes/No outcomes)                    | Yes (by `startDate`) |
| `events`  | Open event groupings of related markets                      | Yes (by `startDate`) |
| `series`  | Recurring event groupings (NBA, hourly crypto strikes, etc.) | No                   |
| `tags`    | Category tags for markets and events                         | No                   |

### CLOB API — Trading Layer

| Endpoint                  | Description                                                                                 | Incremental |
| ------------------------- | ------------------------------------------------------------------------------------------- | ----------- |
| `clob_markets`            | CLOB-tradeable markets with token IDs and rewards config                                    | No          |
| `clob_sampling_markets`   | CLOB markets with active liquidity rewards (disabled by default)                            | No          |
| `clob_simplified_markets` | Stripped-down CLOB market list (disabled by default)                                        | No          |
| `rewards_markets_current` | Current liquidity-rewards configuration per market                                          | No          |
| `price_history`           | Historical price time-series per outcome token, 12-hour grain (requires `inputs.token_ids`) | No          |

### Data API v2 — On-Chain Activity

| Endpoint    | Description                                                                                    | Incremental          |
| ----------- | ---------------------------------------------------------------------------------------------- | -------------------- |
| `trades`    | Global on-chain trades feed (all users, all markets)                                           | Yes (by `timestamp`) |
| `positions` | Open positions per user (requires `inputs.user_addresses`)                                     | No                   |
| `activity`  | Per-user activity feed: TRADE, REDEEM, SPLIT, MERGE, REWARD (requires `inputs.user_addresses`) | Yes (by `timestamp`) |
| `value`     | Total USD portfolio value per user (requires `inputs.user_addresses`)                          | No                   |
| `holders`   | Top token holders per market condition (requires `inputs.condition_ids`)                       | No                   |

To discover available endpoints:

```bash
sling conns discover POLYMARKET
```

## Incremental Sync

The connector supports time-based incremental sync for several endpoints:

* **`markets`, `events`** — filter by `start_date_min` (Gamma keyset API). Watermark: max `startDate` from prior run. The Gamma API returns only open markets and events by default.
* **`trades`** — client-side watermark on `timestamp` (Unix seconds). The `/v2/trades` global feed has no server-side `start` filter. The connector pages from newest to oldest with a cursor and stops at the watermark. The feed covers the current and previous month.
* **`activity`** — server-side `start`/`end` Unix-second filters. Watermark: max `timestamp` from prior run.

For the first run, the watermark falls back to `inputs.anchor_date` (default: 1 year ago). For backfill of a specific date range, use the `source_options.range` field in your replication config:

```yaml
source: POLYMARKET
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: polymarket.{stream_name}
  source_options:
    range: "2026-01-01,2026-03-31"

streams:
  activity:
```

## User & Token-Scoped Endpoints

Several endpoints are user- or token-specific and need the matching `inputs`. Set the input to enable them:

| Endpoint                         | Required Input                                                 |
| -------------------------------- | -------------------------------------------------------------- |
| `positions`, `activity`, `value` | `inputs.user_addresses` (comma-separated `0x...` addresses)    |
| `price_history`                  | `inputs.token_ids` (comma-separated CLOB token IDs)            |
| `holders`                        | `inputs.condition_ids` (comma-separated `0x...` condition IDs) |

You can pass multiple comma-separated values; the connector iterates per-value and combines results.

## Price History

The `price_history` endpoint reads `/v2/prices-history` of the Data API with `interval=max`. It returns the whole life of each token at 12-hour grain. The 12-hour series is permanent, so the history of a token is always complete.

## Rate Limiting

Polymarket publishes rate limits for each API family. The connector uses conservative defaults (8 requests/second, concurrency 3). It retries on `429` and `5xx` responses with exponential backoff.

## Common Use Cases

### Track Market Metadata Over Time

```yaml
source: POLYMARKET
target: MY_POSTGRES

defaults:
  mode: incremental
  object: polymarket.{stream_name}

streams:
  markets:
    primary_key: [id]
    update_key: startDate
  events:
    primary_key: [id]
    update_key: startDate
```

### Ingest Global Trades Feed

```yaml
source: POLYMARKET
target: MY_POSTGRES

defaults:
  mode: incremental
  object: polymarket.{stream_name}

streams:
  trades:
    primary_key: [transactionHash, asset]
    update_key: timestamp
```

### Track Specific Wallets

```yaml
# In your env.yaml or .env.sling, set:
# inputs.user_addresses = "0xabc...,0xdef..."

source: POLYMARKET
target: MY_POSTGRES

defaults:
  object: polymarket.{stream_name}

streams:
  positions:
    mode: full-refresh
  activity:
    mode: incremental
    primary_key: [transactionHash, asset, type]
    update_key: timestamp
  value:
    mode: full-refresh
```

If you are facing issues connecting, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.slingdata.io/connections/api-connections/polymarket.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
