> ## 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.

# Data formats

> How ChainQuery encodes numbers, big integers, percentages, timestamps, booleans and stats windows.

## Numbers and strings

ChainQuery uses two encodings for numeric values.

**JSON numbers (64-bit floats)** for anything that is already human-scaled:

* USD values: `priceUSD`, `liquidityUSD`, `marketCapUSD`, `volume24hUSD`, `tokenAmountUsd`, `balanceUSD`, OHLCV volume `v`
* Prices: `tokenPrice`, `priceToken`, OHLCV `o`, `h`, `l`, `c`
* Decimal-adjusted token amounts: `tokenAmount`, `tokenAmountVs`, `balance`, `approximateReserveToken`
* Percentages and counts: `priceChange24hPercentage`, `trades1h`, `buyers24h`

**Decimal strings** for raw on-chain integers in the token's base units (no decimals applied). These can exceed the range a float represents exactly, so parse them with a big-integer type:

| Field | Where |
| - | - |
| `totalSupply`, `circulatingSupply` | Token details, market `base`/`quote`, search, Pulse tokens |
| `balanceRaw` | Wallet holdings |
| `tokenAmountRaw`, `tokenAmountRawVs` | Trades and WebSocket trade events (absolute value) |
| `approximateReserveTokenRaw` | Market `base`/`quote` |
| `rawAmount0`, `rawAmount1` | Multi-events swaps (signed) |

To get a display value, divide by `10^decimals`:

```javascript theme={null}
const raw = BigInt(token.totalSupply);          // "182345671234567890123456"
const scale = 10n ** BigInt(token.decimals);    // 18 decimals
const whole = raw / scale;
const frac = (raw % scale).toString().padStart(token.decimals, "0");
console.log(`${whole}.${frac.slice(0, 4)}`);   // "182345.6712"
```

**`priceTokenString`** on market details is the pool price (base token in quote-token units) as a fixed-point decimal string with exactly **32 fractional digits**, for example `"3412.57000000000000000000000000000000"`. Use it when the float `priceToken` loses precision on very small or very large ratios. It is `null` when it cannot be computed.

> [!NOTE]
>
> `blockNumber` is a **string** in [wallet holdings](https://sonar-cf3aeac7.mintlify.site/api-reference/wallet/get-wallet-holdings.md) and a **number** everywhere else (trades, WebSocket events, multi-events swaps). WebSocket `gap` messages carry numeric `fromBlock` and `toBlock`.

## Percentages

Not every field named "percentage" uses the same scale.

| Field | Scale | Example |
| - | - | - |
| `priceChange{window}Percentage` | Percent points | `6.42` means +6.42% |
| `bondingPercentage` | Percent points, 0 to 100 | `87.5` means 87.5% of the way to bonding |
| `allocation` (wallet holdings) | Percent points, 0 to 100 | `47.15` |
| `poolFeePercentage` | **Fraction** | `0.003` means a 0.3% pool fee |

`priceChange*Percentage` is `0` when there is no earlier price to compare against. `bondingPercentage` is `null` when the token has no bonding curve; on token details a token that has already bonded reports `0`, so check `bonded` first.

## Timestamps

| Context | Format |
| - | - |
| Request parameters `from` and `to` | Unix epoch **milliseconds** (integer) |
| OHLCV candle `t` | Unix epoch milliseconds, bucket start in UTC |
| Trade `date` and `timestamp` (REST and WebSocket) | Unix epoch milliseconds (both hold the same value) |
| Multi-events swap `timestamp` | Unix epoch milliseconds |
| Every other date (`createdAt`, `bondedAt`, `latestTradeDate`, history `date`, `lastSwapAt`, `dexscreener*Date`) | ISO-8601 string in UTC, e.g. `"2026-12-03T10:14:48.000Z"`, or `null` |

> [!WARNING]
>
> `from` and `to` must be **milliseconds**. A value in seconds such as `1764720000` is accepted without error but read as a date in January 1970, so you get an empty or wrong window. Use `Date.now()` in JavaScript or `int(time.time() * 1000)` in Python.

OHLCV buckets are aligned to UTC. Weekly (`1w`) buckets start on Monday 00:00 UTC, and monthly (`1M`) buckets are UTC calendar months. Note the case: `1m` is one minute, `1M` is one month.

## Booleans in query strings

Boolean query parameters (`fill` on `GET /token/ohlcv` and `GET /market/ohlcv`, `filterSpam` on wallet holdings) accept only the literal lowercase strings `true` and `false`. `1`, `0`, `yes` or `TRUE` return `400 INVALID_PARAMETERS`.

JSON bodies and WebSocket messages use real JSON booleans (`"excludeNoise": true`).

## Optional parameters

Leave an optional parameter out of the query string instead of sending it empty. Numeric parameters convert an empty value to `0`, so:

* `limit=` becomes `0` and fails validation with `Too small: expected number to be >=1`.
* `from=` becomes `0`, which is a valid timestamp (1970-01-01) and silently widens your window.

```javascript theme={null}
// Build query strings without empty values
const params = new URLSearchParams(
  Object.entries({ address, chain, from, to }).filter(([, v]) => v !== undefined && v !== ""),
);
```

Unknown query parameters are ignored.

## Stats windows

Token, market and Pulse objects carry rolling stats for fixed windows. The window name is embedded in the field name.

| Window set | Windows | Fields |
| - | - | - |
| Stats windows | `1min`, `5min`, `15min`, `1h`, `4h`, `6h`, `12h`, `24h` | `volume{W}USD`, `volumeBuy{W}USD`, `volumeSell{W}USD`, `trades{W}`, `buys{W}`, `sells{W}`, `buyers{W}`, `sellers{W}`, `traders{W}`, `feesPaid{W}USD` |
| Price change windows | `1min`, `5min`, `1h`, `4h`, `6h`, `12h`, `24h` (**no `15min`**) | `priceChange{W}Percentage` |

Examples: `volume24hUSD`, `trades1h`, `buyers15min`, `priceChange5minPercentage`. `buyers`, `sellers` and `traders` count distinct wallets. Stats default to `0` when there is no activity.

> [!NOTE]
>
> `feesPaid{W}USD` currently reflects the **network gas fees** traders paid for their swaps, converted to USD. It does not include DEX swap fees or LP fees. Treat this definition as provisional.

## Addresses and chain ids

All addresses in responses are lowercase. Chain ids are usually `"evm:<id>"` strings. See [Chains and identifiers](https://sonar-cf3aeac7.mintlify.site/concepts/chains-and-identifiers.md) for the exceptions.


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