Insights

XRPL OHLC & Historical Price Data API

One request returns the price history of any XRP Ledger token as candles: for each period, the price it opened at, its high, its low, the price it closed at, and the volume. From 1-minute to 1-week candles, in XRP or a fiat currency, back to the token’s first trade.

What a candle is

XRP in US dollars, one candle a day, last 30 days23 Sep: open $1.5727 · high $1.6581 · low $1.4791 · close $1.5010
The thin line runs from the day’s low to its high; the thick body from its open to its close, green when it closed higher, red when it closed lower, as this one did. Hover or tap any day to take it apart.

The request

XRP’s last month of daily candles in US dollars. Each candle is [time, open, high, low, close, volume]:

Request
curl "https://api.xrpl.to/v1/ohlc/84e5efeb89c4eae8f68188982dc290d8?range=1M&interval=1d&vs_currency=USD"
Response
{
  "success": true,
  "interval": "1d",
  "vs_currency": "USD",
  "length": 30,
  "ohlc": [
    [
      1792195200000,
      1.3115,
      1.3126,
      1.2701,
      1.2941,
      41064361.7
    ],
    [
      1792281600000,
      1.2941,
      1.3101,
      1.2562,
      1.3071,
      67755153.7
    ],
    [
      1792368000000,
      1.3071,
      1.3168,
      1.3016,
      1.31076638,
      16242759.3
    ]
  ]
}
The last three of 30 candles. Any token works the same way with its md5 or slug; the token API guide shows how to find it.

Parameters

range1D|5D|7D|1M|3M|1Y|5Y|ALL
interval1m|5m|15m|30m|1h|2h|4h|1d|1w
vs_currencyXRP|USD|EUR|JPY|CNH (default: XRP). EUR, JPY and CNH candles are converted at the ECB reference rate of their own day (the last business day before a weekend or holiday; CNH uses the ECB's CNY); a candle with no rate in the week before it is left out
resolutionint (minutes), or D|W
cbint (candle bar count, max 5000)
tounix ms (with resolution): a page of history, the cb candles that open before it. Page back by passing the first candle's time; an empty ohlc means the history ends there. Absent, or inside the current candle: the live window ending now
invertbool
As the API documents them, read from its docs when this page was built.

Paging back through years

For a long history, ask for a fixed number of candles and walk backwards: set resolution (minutes, or D for a day) and cb (up to 5,000), then pass to as the time of the first candle you have. An empty list means you reached the token’s first trade.

// every daily candle a token has, oldest first
async function allDays(md5) {
  const out = [];
  let to;
  for (;;) {
    const url = `https://api.xrpl.to/v1/ohlc/${md5}?resolution=D&cb=5000${to ? `&to=${to}` : ''}`;
    const { ohlc } = await (await fetch(url)).json();
    if (!ohlc || !ohlc.length) return out;
    out.unshift(...ohlc);            // [time, open, high, low, close, volume]
    to = ohlc[0][0];                 // page back from the first candle
  }
}

What people build with it

  • Charts: the arrays drop straight into charting libraries such as TradingView’s Lightweight Charts.
  • Indicators and bots: moving averages, RSI and the like are computed from closes; the API also serves RSI directly at /v1/rsi.
  • Backtests: years of candles in a few requests, with the to-paging above.

Any app that shows the data must credit xrpl.to visibly beside it; the API guide has the limits and plans.

Questions

How do I get historical prices for an XRP Ledger token?
GET /v1/ohlc/{id} with the token’s md5 or slug. range picks the window (1D to ALL), interval the candle size (1m to 1w), and vs_currency the unit (XRP or a fiat currency).
How far back does the price history go?
To the token’s first trade. Pass resolution and cb (up to 5,000 candles) and page back with to, set to the first candle’s time, until the API returns an empty list.
What is in each candle?
An array: time in Unix milliseconds, then open, high, low and close prices, then volume.