# terminal apis

All API endpoints that power the YESNO terminal. These are Vercel serverless functions.

## POST /api/polymarket-analyze

AI-powered market analysis.

**Request**:

```json
{
  "question": "Will X happen?",
  "yesOdds": 55,
  "volume": 1000000,
  "liquidity": 500000,
  "endDate": "2026-06-01T00:00:00Z",
  "slug": "market-slug",
  "enrichedData": { ... },
  "calibration": { ... },
  "tier": "analyst"
}
```

| Field          | Required | Description                                      |
| -------------- | -------- | ------------------------------------------------ |
| `question`     | Yes      | Market question text                             |
| `yesOdds`      | No       | Current YES price (0-100)                        |
| `volume`       | No       | Total market volume                              |
| `liquidity`    | No       | Current liquidity                                |
| `endDate`      | No       | Market resolution date                           |
| `slug`         | No       | Polymarket slug                                  |
| `enrichedData` | No       | Pre-computed enriched signals                    |
| `calibration`  | No       | Custom calibration parameters                    |
| `tier`         | No       | scout, analyst, or strategist (default: analyst) |

**Response**:

```json
{
  "analysis": { "verdict": "YES", "confidence": 72, "brief": "..." },
  "news": [{ "title": "...", "source": "...", "snippet": "..." }],
  "model": "claude-haiku-4-5",
  "tier": "analyst",
  "enriched": true,
  "timestamp": "2026-02-28T12:00:00Z"
}
```

**Config**: 30s max duration. Uses OpenRouter primary, Groq fallback.

***

## POST /api/polymarket-enriched

Compute 9 enriched signal categories.

**Request**:

```json
{
  "tokenId": "0x1234...",
  "conditionId": "0xabcd...",
  "question": "Will X happen?",
  "currentPrice": 0.55,
  "endDate": "2026-06-01T00:00:00Z",
  "calibration": { ... }
}
```

| Field          | Required | Description         |
| -------------- | -------- | ------------------- |
| `tokenId`      | Yes\*    | YES token ID        |
| `conditionId`  | Yes\*    | Market condition ID |
| `question`     | No       | Market question     |
| `currentPrice` | No       | Current price (0-1) |
| `endDate`      | No       | Resolution date     |
| `calibration`  | No       | Custom thresholds   |

\*At least one required.

**Response**:

```json
{
  "signals": {
    "momentum": { "direction": "BULLISH", "slope7d": 0.02, ... },
    "volumeTrend": { "signal": "SURGING", "ratio7dVs30d": 2.1, ... },
    "whaleSignal": { "sentiment": "ACCUMULATING", "netFlow": 15000, ... },
    "holderConviction": { "concentration": "HIGH", "hhi": 0.32, ... },
    "lifecycle": { "maturity": "MATURE", "urgency": "MODERATE", ... },
    "volumePriceDivergence": { "signal": "BREAKOUT_BUILDING", ... },
    "buyPressure": { "signal": "BUILDING", ... },
    "holderRotation": { "signal": "SMART_YES", ... },
    "smartMoney": { "edge": "ALIGNED BUY", "conviction": 7, ... }
  },
  "briefing": "...",
  "priceSnapshots": { ... },
  "rawPriceHistory": [...],
  "topTrades": [...],
  "topHolders": { "yes": [...], "no": [...] },
  "openInterest": { ... },
  "timestamp": "2026-02-28T12:00:00Z"
}
```

**Config**: 15s max duration. Fetches 4 data sources in parallel.

***

## POST /api/polymarket-depth

Order book depth data.

**Request**:

```json
{
  "tokenId": "0x1234..."
}
```

**Response**: Bids, asks, spread, midpoint.

***

## GET /api/polymarket-whales

Large trades across markets.

**Query params**: `minValue` (default 500), `limit` (default 20)

**Response**: Array of whale trades.

***

## GET /api/polymarket-leaderboard

Top traders by performance.

**Query params**: `timePeriod` (24h/7d/30d/all), `limit` (default 20)

**Response**: Array of traders with PnL, volume, win rate.

***

## POST /api/polymarket-news

News relevant to a market.

**Request**:

```json
{
  "question": "Will X happen?",
  "sector": "politics"
}
```

**Response**: Array of news articles from Brave Search.

***

## GET /api/polymarket-holders

Top holders for a market.

**Query params**: `conditionId`, `limit` (default 10)

**Response**: Top YES and NO holders.


---

# 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/terminal-apis.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.
