DEV Community

Nyx Lesende
Nyx Lesende

Posted on

Query Every Token on the XRP Ledger With One Endpoint

The XRP Ledger currently has 20,396 issued tokens, and 1,675 of them traded in the last 24 hours. Getting at that data usually means running your own rippled node or stitching together several exchange APIs.

There is a simpler path. Here is the whole thing in one fetch.

The endpoint

const res = await fetch(
  'https://api.xrpl.to/v1/tokens?limit=5&sortBy=vol24hxrp&sortType=desc'
);
const { tokens, total } = await res.json();

console.log(total);                    // 20,396
for (const t of tokens) {
  console.log(t.name, t.vol24hxrp, t.holders);
}
Enter fullscreen mode Exit fullscreen mode

No API key, no signup. Output right now looks like this:

Token 24h volume (XRP) Holders
RLUSD 5.57M 67,318
USDC 846.6K 10,359
ARMY 88.0K 21,995
BCHAMP 66.8K 942
BTC 46.6K 4,392

Useful query parameters

  • sortBy — vol24hxrp, marketcap, holders, trustlines
  • sortType — asc or desc
  • start and limit — pagination over all 20,396 tokens
  • tagName — filter to a category such as stablecoins or memes

Ledger-wide stats

A second endpoint gives you the 24-hour aggregates:

const { H24, exch, total } = await (
  await fetch('https://api.xrpl.to/v1/stats')
).json();

console.log('tokens traded:', H24.tradedTokens24H);   // 1,675
console.log('trades:', H24.transactions24H);          // 114,096
console.log('unique traders:', H24.uniqueTraders24H); // 7,251
console.log('XRP per USD:', exch.USD);
Enter fullscreen mode Exit fullscreen mode

Note that exch.USD is XRP per USD, not the other way round. To get the XRP price in dollars, invert it:

const xrpUsd = 1 / exch.USD;   // ≈ 1.5009
Enter fullscreen mode Exit fullscreen mode

That inversion catches almost everyone the first time.

Fields worth knowing

  • vol24hxrp — 24h volume denominated in XRP, not USD
  • marketcap — also denominated in XRP
  • holders vs trustlines — the gap tells you how many accounts opened a line and then emptied it
  • uniqueTraders24h — the cheapest wash-trading filter you will find
  • pro24h — 24h percentage change

One gotcha

Token names are not unique. Multiple issuers can publish under the same ticker — there are two different tokens called USDC on the ledger right now. Always key on the issuer field, or on md5, rather than on name:

const byIssuer = new Map(tokens.map(t => [`${t.issuer}:${t.currency}`, t]));
Enter fullscreen mode Exit fullscreen mode

Rate limits are real but generous. Back off on a 429 and you will be fine:

async function get(url, attempt = 1) {
  const r = await fetch(url);
  if (r.ok) return r.json();
  if (r.status === 429 && attempt < 4) {
    await new Promise(s => setTimeout(s, attempt * 4000));
    return get(url, attempt + 1);
  }
  throw new Error(`HTTP ${r.status}`);
}
Enter fullscreen mode Exit fullscreen mode

Live prices, holder counts, trustlines and order-book depth for every XRPL token are at xrpl.to.

Top comments (0)