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

# Indexer API

The JSON API behind the website, endpoint by endpoint.

{% hint style="success" %}
**In short.** A read-only JSON API over SQLite, rebuilt from chain events: GET only, validated queries and per-IP rate limits. Amounts come back in human units, with raw base-unit strings alongside.
{% endhint %}

## How it works

* Polls the chain every `POLL_MS`, **re-scans the last 8 blocks** on every poll, and uses the latest block's timestamp as "now" (never the wall clock).
* Events only mark a position as *touched*. The row is then re-read from the market (`getPosition`) and the NFT (`ownerOf`), so a reorg or a missed log can't leave a stale row.
* Watches v1 and v2 markets, registries, FeeVault, StakingPool, BuybackBurner, and Uniswap v4 `Swap` events for every pool in the deployments file.
* **Prices**, in ETH per token:
  * `uniswap-v4`: decoded from `Swap` events of configured pools (with a one-time 30-day backfill per pool);
  * `robinhood`: Robinhood Stock Token mid quotes (USD) ÷ ETH/USD (Coinbase, Kraken fallback), every 30 s; Ondo tokens (`…on`) follow their underlying ticker;
  * `dexscreener`: other crypto tokens, from their deepest pair.
* Storage: SQLite through `node:sqlite` (WAL). Tables: `meta`, `assets`, `offers`, `splits`, `burns`, `stake_events`, `events`, `prices`.
* Hardening: GET/OPTIONS only, URL ≤ 2 KB, every query parameter validated (400), per-IP rate limit, short caches on RPC-backed routes, generic 500 bodies, request timeouts, and it refuses to start if the RPC's chain id differs from `CHAIN_ID`.

## Routes

Amounts come back in human units (`amount`, `strike`, `premium`) alongside raw base-unit strings (`*Raw`): wei for WETH, the token's smallest unit for tokens.

| Route                     | Query                                                                                                                                            | Returns                                                                                                            |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| `GET /health`             |                                                                                                                                                  | `chainId`, `chainTime`, `lastBlock`, `latestBlock`, `offers`, `contracts`                                          |
| `GET /assets`             |                                                                                                                                                  | Listed tokens: `address`, `symbol`, `name`, `decimals`, `enabled`, `putsEnabled`, `cap`, `minStrike`               |
| `GET /offers`             | `status` = `open` (default, fillable only) / `filled` / `exercised` / `expired` / `cancelled` / `all`; `kind` = `call` / `put`; `token` = symbol | Positions sorted by expiry                                                                                         |
| `GET /offers/:id`         |                                                                                                                                                  | One position (404 if unknown)                                                                                      |
| `GET /positions/:address` |                                                                                                                                                  | `{ holding, selling, history }`: options held (filled), the address's open and filled offers, last 50 closed       |
| `GET /stake/:address`     |                                                                                                                                                  | `myActive`, `myPending`, `claimable` (WETH), `epoch`, `epochEndsAt`, `minClaim`, `totalStaked`, `lastEpochRewards` |
| `GET /activity`           | `limit` 1–100 (default 30)                                                                                                                       | Recent protocol events, human-readable                                                                             |
| `GET /prices`             |                                                                                                                                                  | `{ SYMBOL: { price, at, change1h, source } }`                                                                      |
| `GET /candles`            | `token` (symbol), `interval` 10–86400 s (default 60), `limit` 1–2000 (default 300)                                                               | OHLC + volume (ETH) buckets                                                                                        |
| `GET /markers`            | `token`                                                                                                                                          | Offer events for the chart: `time`, `name`, `kind`, `tx`, `strikePerToken`                                         |
| `GET /proof`              |                                                                                                                                                  | `{ splits, burns, totals }`                                                                                        |
| `GET /stats`              |                                                                                                                                                  | Volume, fees, open interest, burned, staked tokens, stakers, active offers                                         |
| `GET /expirable`          |                                                                                                                                                  | Filled positions past expiry: `{ id, market }`                                                                     |


---

# 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.kyte.sh/developers/indexer-api.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.
