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
The request
XRP’s last month of daily candles in US dollars. Each candle is [time, open, high, low, close, volume]:
curl "https://api.xrpl.to/v1/ohlc/84e5efeb89c4eae8f68188982dc290d8?range=1M&interval=1d&vs_currency=USD"
{
"success": true,
"interval": "1d",
"vs_currency": "USD",
"length": 30,
"ohlc": [
[
1794787200000,
0.9742,
0.9769,
0.9424,
0.9553,
119306024
],
[
1794873600000,
0.9553,
0.9918,
0.9456,
0.9837,
98771676.2
],
[
1794960000000,
0.9837,
1.0078,
0.9702,
0.9874,
59562035.7
]
]
}Parameters
| range | 1D|5D|7D|1M|3M|1Y|5Y|ALL |
| interval | 1m|5m|15m|30m|1h|2h|4h|1d|1w |
| vs_currency | XRP|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. In USD a candle closes at the XRP/USD rate of its end, and its high and low go only as far as a trade certainly reached (each 5-minute high at the lowest XRP/USD rate of those 5 minutes, each low at the highest), so XRP moving inside a candle draws no wick. In every currency a wick more than 5% past a 5-minute candle's body reaches only as far as real volume traded (2% of the candle's XRP, at least 10 and at most 1000), so a lone off-market trade draws no spike and a real one still shows |
| resolution | int (minutes), or D|W|M (also 1D|1W|1M; a week starts Monday 00:00 UTC, a month on the 1st; 1m is a minute) |
| cb | int (candle bar count, max 5000) |
| to | unix 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 |
| invert | bool |
| ind | indicators instead of candles (with resolution, not to): up to 10 studies, comma-separated, each its id from /ohlc/indicators (id@md5: read off that token's candles instead of this one's, at the same bars) then its inputs after colons in that order, empty = the default (relative-strength-index:14,macd,bollinger-bands:20:2). Computed on these candles with TradingView's formulas, each warmed up on the bars before the first one returned |
| from | unix ms (with ind): the first bar wanted; default the last cb |
| tail | int (with ind): only the last N bars (a chart's live update) |
| ha | bool (with resolution): Heikin Ashi candles (TradingView's), warmed up on the bars before the window; with ind the studies are computed on them |
| chg | bool: each row also carries the bar's change against the bar before's close and the change in % (format "ohlc_change") |
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.