> ## Documentation Index
> Fetch the complete documentation index at: https://sonar-cf3aeac7.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API overview

> Base URL, request conventions, the full endpoint index and the response envelope of the ChainQuery REST API.

The ChainQuery REST API is a read-only HTTP API for on-chain DEX data: token details and stats, pools (markets), OHLCV candles, price history, trades, wallet holdings, search, and the Pulse token feed. For live updates, use the [WebSocket API](https://sonar-cf3aeac7.mintlify.site/websocket/overview.md) instead of polling.

## Base URL

```text theme={null}
https://api.example.com/api/v1
```

Every path on this page is relative to that base URL, unless stated otherwise.

## Authentication

None. The API currently has no API keys, tokens or other authentication. Send plain HTTPS requests.

## Request conventions

* **Methods.** Almost every endpoint is a `GET` that takes its parameters in the query string. The few `POST` endpoints (batch market details and Pulse) take a JSON body. Send `Content-Type: application/json` with those. They return `200` on success, not `201`.
* **Chains.** Single-chain endpoints take a `chain` parameter as a numeric chain ID (`8453`) or in `evm:<id>` form (`evm:8453`). Chain names such as `base` are rejected. List parameters (`chains`) take a comma-separated list such as `1,8453` or `evm:1,evm:8453`. Data responses return chains as `"evm:<id>"` strings. The one exception is the `/health/last-swaps` status route, which returns numeric `chainId` values. See [Chains and identifiers](https://sonar-cf3aeac7.mintlify.site/concepts/chains-and-identifiers.md).
* **Addresses.** Token and wallet addresses are `0x` followed by 40 hex characters. Case doesn't matter, and every address is lowercased before use and in responses.
* **Timestamps.** `from` and `to` are Unix epoch **milliseconds**. A value in seconds is accepted but is read as a date in 1970. See [Data formats](https://sonar-cf3aeac7.mintlify.site/concepts/data-formats.md).
* **Booleans.** Boolean query parameters (for example `fill`) accept only the literal strings `true` and `false`.
* **Unknown parameters are ignored.** Query keys that an endpoint doesn't define are silently dropped, so a typo in an optional parameter name won't cause an error. Check the parameter names carefully.
* **Leave unused parameters out.** Don't send empty values such as `from=`. An empty number is read as `0` and an empty enum fails validation.

## Endpoint index

### Tokens

| Method | Path | Description |
| - | - | - |
| `GET` | [`/token`](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token) | Token details, metadata and windowed stats |
| `GET` | [`/token/markets`](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token-markets) | Pools that trade a token |
| `GET` | [`/token/ohlcv`](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token-ohlcv) | OHLCV candles for a token, from its most active pool |
| `GET` | [`/token/history`](https://sonar-cf3aeac7.mintlify.site/api-reference/token/get-token-history) | Price history of the token's cross-chain asset |

### Markets

| Method | Path | Description |
| - | - | - |
| `GET` | [`/market/details`](https://sonar-cf3aeac7.mintlify.site/api-reference/market/get-market-details) | Details of one pool |
| `POST` | [`/market/details`](https://sonar-cf3aeac7.mintlify.site/api-reference/market/batch-market-details) | Details of up to 100 pools in one request |
| `GET` | [`/market/ohlcv`](https://sonar-cf3aeac7.mintlify.site/api-reference/market/get-market-ohlcv) | OHLCV candles for a pool |

### Assets

| Method | Path | Description |
| - | - | - |
| `GET` | [`/asset/ohlcv`](https://sonar-cf3aeac7.mintlify.site/api-reference/asset/get-asset-ohlcv) | OHLCV candles for a cross-chain asset |
| `GET` | [`/asset/history`](https://sonar-cf3aeac7.mintlify.site/api-reference/asset/get-asset-history) | Price history for a cross-chain asset |

### Trades and wallets

| Method | Path | Description |
| - | - | - |
| `GET` | [`/trades`](https://sonar-cf3aeac7.mintlify.site/api-reference/trades/get-trades) | Trades of a token or pool, with cursor pagination |
| `GET` | [`/wallet/holdings`](https://sonar-cf3aeac7.mintlify.site/api-reference/wallet/get-wallet-holdings) | Token balances of a wallet |

### Discovery

| Method | Path | Description |
| - | - | - |
| `GET` | [`/search`](https://sonar-cf3aeac7.mintlify.site/api-reference/search/search) | Search tokens, pools and assets |
| `GET` | [`/protocols`](https://sonar-cf3aeac7.mintlify.site/api-reference/protocols/get-protocols) | Supported chains with their DEXes, pool types and launchpads |

### Pulse

These endpoints are documented in the [Pulse](https://sonar-cf3aeac7.mintlify.site/pulse/overview.md) tab.

| Method | Path | Description |
| - | - | - |
| `POST` | [`/pulse`](https://sonar-cf3aeac7.mintlify.site/pulse/native-views) | Pulse views in ChainQuery's native request format |
| `POST` | [`/pulse/views`](https://sonar-cf3aeac7.mintlify.site/pulse/rest-views) | Pulse views. The response is **not** wrapped in the envelope described below. |
| `POST` | [`/pulse/views/pagination`](https://sonar-cf3aeac7.mintlify.site/pulse/rest-views-pagination) | Paginated Pulse views. Also returned without the envelope. |

### Status

| Method | Path | Description |
| - | - | - |
| `GET` | [`/health/last-swaps`](https://sonar-cf3aeac7.mintlify.site/api-reference/health/get-last-swaps) | Time since the last indexed swap on each chain. This route sits at the host root (`https://api.example.com/health/last-swaps`), **not** under `/api/v1`. |

## Response envelope

Successful responses wrap the result in an envelope:

```json theme={null}
{ "status": "success", "data": { } }
```

`data` is an object or an array, depending on the endpoint. The `/pulse/views` endpoints are the only exception: they return their payload without the envelope.

Errors use one shape across the API:

```json theme={null}
{
  "status": "error",
  "statusCode": 400,
  "code": "INVALID_ADDRESS",
  "message": "address: must be a valid token or wallet address",
  "details": [{ "field": "address", "message": "must be a valid token or wallet address" }]
}
```

* `statusCode` matches the HTTP status.
* `code` is a stable, machine-readable error code. Branch on it rather than on `message`.
* `details` appears on validation errors (HTTP 400), where it holds one `{ field, message }` entry per problem. The `/health/last-swaps` status route also includes `details` (the freshness report) when it answers `503 SERVICE_UNAVAILABLE`. Other errors have no `details`.

The codes you can receive, and when, are listed in [Responses and errors](https://sonar-cf3aeac7.mintlify.site/concepts/responses-and-errors.md). Limits and defaults for each endpoint are summarized in [Pagination and limits](https://sonar-cf3aeac7.mintlify.site/concepts/pagination-and-limits.md).

> [!NOTE]
>
> An unsupported but well-formed chain ID (for example `chain=137`) passes validation on most endpoints. Depending on the endpoint, you get a `404` (nothing is indexed for it), empty results, or a `400`. Use [`GET /protocols`](https://sonar-cf3aeac7.mintlify.site/api-reference/protocols/get-protocols) to see which chains are supported.

## Try it in the docs

The API playground on each endpoint page sends requests through Mintlify's proxy, so they work from the docs even though your browser isn't calling the API directly.

> [!WARNING]
>
> **Browser CORS is not guaranteed.** The API doesn't set CORS headers itself, so calls from a web page on another origin may be blocked by the browser. Call the API from your backend, or proxy requests through your own server, if you build a browser app.

## Data freshness

The API reads ChainQuery's indexed data. It doesn't query the blockchain while it answers a request. Swaps are indexed as blocks arrive, and token and pool stats are recomputed in a background loop, so they can trail the latest swaps slightly. Some responses are also cached briefly on the server, as noted on each endpoint page. See [How data flows](https://sonar-cf3aeac7.mintlify.site/concepts/how-data-flows.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.