# Pool-wide fee history

`GET /dex/fees/history` · Lithos client API · Lithos Dex

Source: https://lithosprotocol.org/docs/api/get-ld-fee-history

Accumulator-derived pool fees from a background snapshot, bucketed by height. Defaults to the cached last 21600 blocks (approximately 30 days), with 720-block buckets. Cumulative values start at the requested window, not pool genesis, and retain accumulator integer rounding. Check `partial` and `stats` for coverage and freshness. Stale data remains available with `partial: true`; requests never perform node reads.

## Parameters

| Name | In | Type | Required | Description |

|---|---|---|---|---|

| `from` | query | integer · int32 | no | First block height to include; defaults to stats.windowStartHeight and cannot precede it. |

| `to` | query | integer · int32 | no | Last block height to include; defaults to stats.sourceHeight and cannot exceed it. |

| `bucket` | query | integer · int32 | no | Positive bucket size in blocks, limited to at most 500 points. |

## Responses

### 200: Bucketed fee history for the pool

`LDFeeHistory`

- `history` (LDFeeHistoryPoint[], required)
  - `height` (integer · int32, required): Block height at the end of this bucket
  - `timestamp` (integer · int64): Unix milliseconds at the end of this bucket. Absent if unresolved.
  - `periodX` (string, required): nanoERG fees taken during this bucket. Decimal string.
  - `periodY` (string, required)
  - `cumulativeX` (string, required): nanoERG fees taken from the start of the range to here. Decimal string.
  - `cumulativeY` (string, required)
- `partial` (boolean, required): True when the history scan could not cover the requested window or the snapshot is stale. Values are derived from accumulator differences with integer rounding, not payment receipts. 
- `stats` (DexStatsView)
  - `status` (string, required, one of disabled, loading, ready, stale, unavailable): Freshness only. Coverage is a separate question — read `historyComplete` and a graph's `partial`.
  - `updatedAt` (integer · int64): When the last successful refresh began, in Unix milliseconds, before it read the node.
  - `sourceHeight` (integer · int32)
  - `sourceBlockId` (string): The chain tip checked before and after the read. Current price and activity can also include the mempool.
  - `windowStartHeight` (integer · int32): Earliest height you can ask for, max(0, `sourceHeight` - 21600).
  - `coverageStartHeight` (integer · int32): Oldest retained pool snapshot, including a predecessor where one exists.
  - `historyComplete` (boolean): Whether the history read reached the start of the index, or a predecessor, before the requested window.
  - `refreshing` (boolean, required)
  - `restored` (boolean, required): Loaded from disk. Stale until a node read succeeds, and never overwrites newer live data.
  - `error` (string): Short refresh failure message. Details stay in the client log.
  - `collectedFrom` (integer · int32): The height a verified pool other than ERG:LIT joined the verified list. Nothing before it is collected, so a graph covering earlier heights shows that range as not collected. Absent for ERG:LIT, whose whole life is collected. 

### 400: Invalid range or bucket size, or a range outside the cached height window.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

### 503: No cached snapshot; statistics are loading, unavailable, or disabled. Retry-After is 5 seconds.

`DexStatsUnavailable`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description
- `stats` (DexStatsView, required)
  - `status` (string, required, one of disabled, loading, ready, stale, unavailable): Freshness only. Coverage is a separate question — read `historyComplete` and a graph's `partial`.
  - `updatedAt` (integer · int64): When the last successful refresh began, in Unix milliseconds, before it read the node.
  - `sourceHeight` (integer · int32)
  - `sourceBlockId` (string): The chain tip checked before and after the read. Current price and activity can also include the mempool.
  - `windowStartHeight` (integer · int32): Earliest height you can ask for, max(0, `sourceHeight` - 21600).
  - `coverageStartHeight` (integer · int32): Oldest retained pool snapshot, including a predecessor where one exists.
  - `historyComplete` (boolean): Whether the history read reached the start of the index, or a predecessor, before the requested window.
  - `refreshing` (boolean, required)
  - `restored` (boolean, required): Loaded from disk. Stale until a node read succeeds, and never overwrites newer live data.
  - `error` (string): Short refresh failure message. Details stay in the client log.
  - `collectedFrom` (integer · int32): The height a verified pool other than ERG:LIT joined the verified list. Nothing before it is collected, so a graph covering earlier heights shows that range as not collected. Absent for ERG:LIT, whose whole life is collected. 

### default: Error

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

## Example request

```bash
curl -X GET "http://localhost:9000/dex/fees/history"
```

## Example response

```json
{
  "history": [
    {
      "height": 1312460,
      "timestamp": 1765432100000,
      "periodX": "210000000",
      "periodY": "6350000",
      "cumulativeX": "8420000000",
      "cumulativeY": "254300000"
    }
  ],
  "partial": false,
  "stats": {
    "status": "disabled",
    "updatedAt": 0,
    "sourceHeight": 0,
    "sourceBlockId": "string",
    "windowStartHeight": 0,
    "coverageStartHeight": 0,
    "historyComplete": true,
    "refreshing": true,
    "restored": true,
    "error": "string",
    "collectedFrom": 0
  }
}
```
