# data proxies

The terminal proxies requests to Polymarket's APIs through Vercel rewrites. This solves CORS issues and adds caching.

## Why Proxies

Browser-based applications can't call Polymarket APIs directly due to CORS restrictions. The proxies:

* Forward requests to the correct Polymarket API
* Add CORS headers so the browser can receive responses
* Add caching headers to reduce load and improve performance
* Keep API URLs stable even if Polymarket changes their endpoints

## Proxy Routes

{% stepper %}
{% step %}

#### /gamma/\*

**Rewrites to**: `https://gamma-api.polymarket.com/*`

**Cache**: 60 seconds

**Used for**: Market listings, event data, metadata. This is the primary API for fetching market information.

**Example**:

```
GET /gamma/events?closed=false&order=volume24hr&ascending=false&limit=20
```

{% endstep %}

{% step %}

#### /clob/\*

**Rewrites to**: `https://clob.polymarket.com/*`

**Cache**: 15 seconds

**Used for**: Order book data, price history, trade execution data. The CLOB (Central Limit Order Book) API provides real-time trading data.

**Example**:

```
GET /clob/prices-history?market=TOKEN_ID&interval=1d&fidelity=60
```

{% endstep %}

{% step %}

#### /data/\*

**Rewrites to**: `https://data-api.polymarket.com/*`

**Cache**: 15 seconds

**Used for**: Holder data, trade history, open interest, position data.

**Example**:

```
GET /data/trades?market=CONDITION_ID&limit=200
GET /data/positions?market=CONDITION_ID&limit=20
```

{% endstep %}
{% endstepper %}

## Caching Strategy

| Proxy      | Cache TTL | Rationale                                      |
| ---------- | --------- | ---------------------------------------------- |
| `/gamma/*` | 60s       | Market metadata changes slowly                 |
| `/clob/*`  | 15s       | Order book and prices need near-real-time data |
| `/data/*`  | 15s       | Trade and holder data updates frequently       |
| `/api/*`   | 30s       | Terminal API responses                         |

## CORS Headers

All proxy routes include:

```
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
```

The `/mcp/*` route additionally allows:

```
Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yesno-1.gitbook.io/yesno-docs/api-reference/data-proxies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
