# GET /v1/xrpl/metrics/book-trend

XRPL book trend: the stored spread and depth of a pair's order book per hour over 7 or 30 days or per UTC day over a year, each bucket with its mean, min, max and stored slots, and the median per UTC hour.

## Purpose

Serves how a pair's order book has looked over time, from the figures the service stores every 15 minutes, with no ledger read for the data: per hour over the last 7 days (`window=7d`, the default, 168 hours) or 30 days (`30d`, 720 hours), or per UTC day over the last year (`1y`, 365 days). The pair is ordered: `base` then `quote`, as `/v1/xrpl/metrics/pressure` reads it, and stored series exist for XRP and the XRPL stablecoins of the registry, each paired with XRP and with each other, in either order. The buckets are the hours or UTC days closed at the network's latest written 15-minute slot, oldest first; the hour or day holding that slot is still open and not listed. `figures` is a comma-separated list among `spread_bps`, `depth_bid_10`, `depth_ask_10`, `depth_bid_50`, `depth_ask_50`, `depth_bid_100` and `depth_ask_100` (default `spread_bps`), served in that order whatever the request order and echoed as an array; an unknown, empty or repeated name answers 400 naming `figures`, and a `window` other than `7d`, `30d` or `1y` 400 naming `window`, with no read. The figures are those of the book baseline of `/v1/xrpl/metrics/pressure`: `spread_bps` is the spread over mid in basis points, and `depth_bid_k` and `depth_ask_k` the funded quantity of the bids or asks priced within k bps of mid, bounds included, in units of `base`. `bucket_columns` names the cells of each bucket row, always as asked: `bucket_start` (the bucket's start, ISO 8601 UTC) then, per figure, `<figure>.mean`, `<figure>.min` and `<figure>.max` of its stored 15-minute values in the bucket and `<figure>.points`, how many stored slots they come from (4 for a full hour, 96 for a full day; `null` for a bucket rolled up before the counts were stored); `buckets` holds one row array per bucket in that order, and a figure with no stored value in a bucket gives `null` in its four cells, the bucket still listed. `profile_columns` names the cells of each profile row, always as asked: `hour`, then per figure `<figure>.median`, the median of its hourly means at that hour over the window's buckets holding a value (the mean of the two middle values for an even count), and `<figure>.days`, how many buckets they are (`null` and 0 when none); `hourly_profile` (`7d` and `30d`; `null` for `1y`) holds 24 row arrays in that order, one per UTC hour 0 to 23. `spread_bps` cells and medians are rounded half-up to 2 decimals, as every `spread_bps` of the API; depth cells are the stored values and depth medians decimal strings of at most 18 decimals, rounded half-up. The depth cells of an hour or day holding a slot whose side read a full page of 100 offers are lower bounds, since offers beyond that page are not in that slot's depth; the baseline's `truncated_points` of `/v1/xrpl/metrics/pressure` counts such slots in its 7-day window. For a pair no stored series tracks, `buckets` and `hourly_profile` are `null` with `not_tracked`, with no read of the stored series; before the network's first snapshot run, `buckets` is empty and `hourly_profile` `null` with `warming_up`; `reasons` is empty otherwise. The stored series are read in one request per query, cached until the end of the latest written slot and for at most 900 seconds; when they cannot be read, the last answer within 1800 seconds is served with `meta.stale` true, else the answer fails (503 `upstream-unavailable`). `meta.ledger_index` comes from the latest validated ledger, read through the same cache entry as `/v1/xrpl/ledger/latest`, the route's only upstream read; `meta.as_of`, `age_seconds`, `cache` and `stale` also reflect the read of the stored series the answer is built from (the oldest read, the worst cache state, stale when either is), so the data is as old as that stored read (for a pair no stored series tracks, the latest-ledger read alone). An answer is fresh for 4 seconds, the policy of that latest-ledger read. Size, measured on the route: with the default figure the JSON answer is about 9,785 bytes at `7d`, 39,197 at `30d` and 20,409 at `1y`, under the MCP limits of the reference agent host (25,000 tokens, and 50,000 characters before a tool result is saved to a file) at every window; one depth figure is about 14,010, 56,587 and 31,895 bytes and all seven about 61,614, 250,289 and 145,891, so a depth figure at `30d`, or several figures at any window, can pass them: ask only the figures you need. The buckets and the profile are statistics of the stored book, not advice. The example is illustrative, computed by the route from a seeded store of the XRP/USDC book until a served mainnet answer replaces it, and lists only the last three of its 168 bucket rows.

## When to use

To see how a pair's spread and depth near mid have moved hour by hour or day by day, and at which UTC hours its book is usually tighter or deeper, before choosing when to trade.

## When not to use

To read the book now (use `/v1/xrpl/orderbook`), its live buy pressure against the 7-day baseline (use `/v1/xrpl/metrics/pressure`), or the cost of a trade of a given size (use `/v1/xrpl/slippage`).

## Parameters

| Name | In | Required | Description | Constraints | Example |
|---|---|---|---|---|---|
| `base` | query | yes | Base currency of the pair. `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | `XRP` |
| `quote` | query | yes | Quote currency of the pair. `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | `XRP`, or `CODE.issuer`: `CODE` is a 3-character standard code or 40 hexadecimal digits, and `issuer` is a classic XRPL address. Standard codes are case-sensitive: `usd` and `USD` are different tokens, so send the exact code. A standard code uses letters, digits or `?!@#$%^&*<>(){}[]\|` and is never `XRP`; percent-encode the symbols in a URL (for example `%3F` for `?`). A 40-hex code is read in any case, and the 40-hex form of a standard code means that code. | `5553444300000000000000000000000000000000.rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE` |
| `window` | query | no | 7d or 30d (hourly buckets) or 1y (UTC days), back from the latest written 15-minute slot (default 7d). | One of 7d, 30d or 1y; any other value is rejected with 400 | `7d` |
| `figures` | query | no | Comma-separated figures to serve, each once: spread_bps, depth_bid_10, depth_ask_10, depth_bid_50, depth_ask_50, depth_bid_100 and depth_ask_100; served in that order (default spread_bps). | Names among the seven figures, comma-separated, none empty or repeated; anything else is rejected with 400 | `spread_bps` |

## Request example

```sh
curl -s "https://api.criptonlabs.com/v1/xrpl/metrics/book-trend?base=XRP&quote=5553444300000000000000000000000000000000.rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE&window=7d"
```

## Response example (200)

```json
{
  "base": "XRP",
  "quote": "5553444300000000000000000000000000000000.rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE",
  "quote_currency_ascii": "USDC",
  "window": "7d",
  "figures": [
    "spread_bps"
  ],
  "bucket_columns": [
    "bucket_start",
    "spread_bps.mean",
    "spread_bps.min",
    "spread_bps.max",
    "spread_bps.points"
  ],
  "buckets": [
    [
      "2026-11-11T17:00:00.000Z",
      "9.69",
      "5.23",
      "13.82",
      4
    ],
    [
      "2026-11-11T18:00:00.000Z",
      "8.4",
      "4.25",
      "17.26",
      4
    ],
    [
      "2026-11-11T19:00:00.000Z",
      "15.47",
      "12.83",
      "17.35",
      4
    ]
  ],
  "profile_columns": [
    "hour",
    "spread_bps.median",
    "spread_bps.days"
  ],
  "hourly_profile": [
    [
      0,
      "9.02",
      7
    ],
    [
      1,
      "8.12",
      7
    ],
    [
      2,
      "9.13",
      7
    ],
    [
      3,
      "9.91",
      7
    ],
    [
      4,
      "10.84",
      7
    ],
    [
      5,
      "9.38",
      7
    ],
    [
      6,
      "10.63",
      7
    ],
    [
      7,
      "12.48",
      7
    ],
    [
      8,
      "8.75",
      7
    ],
    [
      9,
      "11.04",
      7
    ],
    [
      10,
      "9.45",
      7
    ],
    [
      11,
      "10.15",
      7
    ],
    [
      12,
      "9.23",
      7
    ],
    [
      13,
      "10.99",
      7
    ],
    [
      14,
      "10.93",
      7
    ],
    [
      15,
      "9.41",
      7
    ],
    [
      16,
      "10.52",
      7
    ],
    [
      17,
      "9.69",
      7
    ],
    [
      18,
      "9.81",
      7
    ],
    [
      19,
      "9.37",
      7
    ],
    [
      20,
      "10.25",
      7
    ],
    [
      21,
      "9.27",
      7
    ],
    [
      22,
      "9.25",
      7
    ],
    [
      23,
      "9.38",
      7
    ]
  ],
  "reasons": [],
  "meta": {
    "ledger_index": 108267510,
    "ledger_state": "validated",
    "as_of": "2026-11-11T20:22:56.994Z",
    "age_seconds": 0,
    "cache": "miss",
    "stale": false
  }
}
```

## Errors

- 400 [invalid-parameters](https://api.criptonlabs.com/errors/invalid-parameters.md)
- 400 [bad-request](https://api.criptonlabs.com/errors/bad-request.md)
- 429 [rate-limited](https://api.criptonlabs.com/errors/rate-limited.md)
- 503 [upstream-unavailable](https://api.criptonlabs.com/errors/upstream-unavailable.md)

## Caching

Fresh for 4 seconds; on upstream failure the last good value is served for up to 60 seconds (`meta.stale` is `true`), then the service answers 503. See the [freshness guide](https://api.criptonlabs.com/docs/guides/freshness.md).

## Rate limit

Tier `expensive`. See the [rate-limits guide](https://api.criptonlabs.com/docs/guides/rate-limits.md).

## MCP tool

The MCP tool `xrpl_metrics_book_trend` returns the same data. See the [MCP quickstart](https://api.criptonlabs.com/docs/guides/mcp-quickstart.md).
