> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gammaflip.io/llms.txt
> Use this file to discover all available pages before exploring further.

# GEX Term Structure

> Open Interest and Gamma Exposure per expiration, broken down by exchange

## What it returns

For each non-expired expiration, this endpoint returns:

* **Open Interest** in USD (calls, puts, and total) per exchange
* **Gamma Exposure** (total, upside, downside, absolute) per exchange
* **Contract count** per exchange
* **Aggregated totals** across all requested exchanges
* **Per-expiration metadata** — date, days to expiry, timestamp

Use this to understand how gamma and OI are distributed across the term
structure, and to spot the expirations where dealer positioning is heaviest.

## Path parameters

<ParamField path="exchange" type="string" required>
  Exchange name: `bybit`, `deribit`, `okx`, or `all` (cross-exchange aggregation).
</ParamField>

<ParamField path="coin" type="string" required>
  Base coin symbol (uppercase).
</ParamField>

## Response shape

```json theme={null}
{
  "data": {
    "expirations": [
      {
        "date": "15APR26",
        "days_to_expiry": 0,
        "timestamp": "2026-04-15T00:00:00+00:00",
        "exchanges": {
          "deribit": {
            "oi_usd": 252323000.06,
            "call_oi_usd": 115940056.62,
            "put_oi_usd": 136382943.44,
            "contracts": 104,
            "total_gex": -2481405.91,
            "abs_gex": 23314299.33,
            "upside_gex": 8007918.34,
            "downside_gex": 15306380.99
          }
        },
        "total": {
          "oi_usd": 252323000.06,
          "call_oi_usd": 115940056.62,
          "put_oi_usd": 136382943.44,
          "contracts": 104,
          "total_gex": -2481405.91,
          "abs_gex": 23314299.33,
          "upside_gex": 8007918.34,
          "downside_gex": 15306380.99
        }
      }
    ],
    "metadata": {
      "basecoin": "BTC",
      "exchanges_used": ["deribit"],
      "current_price": 74037.30,
      "expiration_count": 11,
      "timestamp": "2026-04-14T22:43:30.035178+00:00",
      "timestamp_ms": 1776206610035
    }
  }
}
```

### Per-expiration field guide

Each entry in `exchanges.*` and `total` contains the same metric set:

| Field          | Meaning                                                   |           |   |          |    |
| -------------- | --------------------------------------------------------- | --------- | - | -------- | -- |
| `oi_usd`       | Total open interest, USD notional                         |           |   |          |    |
| `call_oi_usd`  | Open interest contributed by call options, USD            |           |   |          |    |
| `put_oi_usd`   | Open interest contributed by put options, USD             |           |   |          |    |
| `contracts`    | Number of option contracts (not USD)                      |           |   |          |    |
| `total_gex`    | Net dealer gamma exposure (calls – puts), USD per 1% move |           |   |          |    |
| `abs_gex`      | Absolute GEX magnitude — \`                               | call\_gex | + | put\_gex | \` |
| `upside_gex`   | GEX concentrated above spot                               |           |   |          |    |
| `downside_gex` | GEX concentrated below spot                               |           |   |          |    |

`total` holds the aggregate across all exchanges included in the response.
When querying a single exchange (e.g. `deribit`), `exchanges.deribit` and
`total` are identical.

## Errors

<ResponseField name="400 invalid_exchange" type="error">
  Exchange name not recognized.
</ResponseField>

<ResponseField name="404 no_data" type="error">
  No data available for this coin/exchange combination.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.gammaflip.io/api/v1/gex/term-oi/all/BTC \
    -H "X-API-Key: gex_sk_your_key_here"
  ```

  ```python Python theme={null}
  import requests

  resp = requests.get(
      "https://api.gammaflip.io/api/v1/gex/term-oi/all/BTC",
      headers={"X-API-Key": "gex_sk_your_key_here"},
  )
  data = resp.json()["data"]

  for exp in data["expirations"]:
      t = exp["total"]
      print(
          f"{exp['date']} (d={exp['days_to_expiry']:>3}): "
          f"OI=${t['oi_usd']:>14,.0f}  "
          f"net GEX={t['total_gex']:+14,.0f}"
      )
  ```

  ```javascript Node.js theme={null}
  const resp = await fetch(
    "https://api.gammaflip.io/api/v1/gex/term-oi/all/BTC",
    { headers: { "X-API-Key": "gex_sk_your_key_here" } }
  );
  const { data } = await resp.json();

  for (const exp of data.expirations) {
    const t = exp.total;
    console.log(
      `${exp.date} (d=${exp.days_to_expiry}): ` +
      `OI=$${t.oi_usd.toFixed(0)}, net GEX=${t.total_gex.toFixed(0)}`
    );
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "expirations": [
        {
          "date": "15APR26",
          "days_to_expiry": 0,
          "timestamp": "2026-04-15T00:00:00+00:00",
          "exchanges": {
            "deribit": {
              "oi_usd": 252323000,
              "call_oi_usd": 115940056,
              "put_oi_usd": 136382943,
              "contracts": 104,
              "total_gex": -2481405,
              "abs_gex": 23314299,
              "upside_gex": 8007918,
              "downside_gex": 15306380
            }
          },
          "total": {
            "oi_usd": 252323000,
            "call_oi_usd": 115940056,
            "put_oi_usd": 136382943,
            "contracts": 104,
            "total_gex": -2481405,
            "abs_gex": 23314299,
            "upside_gex": 8007918,
            "downside_gex": 15306380
          }
        }
      ],
      "metadata": {
        "basecoin": "BTC",
        "exchanges_used": ["deribit"],
        "current_price": 74037.30,
        "expiration_count": 11
      }
    },
    "meta": {
      "timestamp": "2026-04-14T10:00:00+00:00",
      "exchange": "all",
      "coin": "BTC",
      "rate_limit": {
        "limit": 500,
        "remaining": 494,
        "reset": "2026-04-15T00:00:00+00:00"
      }
    }
  }
  ```
</ResponseExample>
