DEV Community

Nyx Lesende
Nyx Lesende

Posted on

Query Every Token on the XRP Ledger With One Endpoint

The XRP Ledger currently has 20,365 issued tokens, and 1,369 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,365
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 2.00M 67,174
USDC 281.5K 10,334
FUZZY 102.8K 10,979
ARMY 35.6K 22,020
Opulence 21.4K 3,796

Useful query parameters

  • sortByvol24hxrp, marketcap, holders, trustlines
  • sortTypeasc or desc
  • start and limit — pagination over all 20,365 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,369
console.log('trades:', H24.transactions24H);          // 107,671
console.log('unique traders:', H24.uniqueTraders24H); // 5,442
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.4013
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)