Tutorials
Fetch a Historical Ledger
Use Honeycluster's full-history Clio cluster to fetch any ledger by index, even ones from years ago.

Honeycluster's edge routes historical queries to Clio, which indexes the entire ledger into a column store. This tutorial walks through fetching an arbitrary historical ledger and inspecting the transactions it contained.

Before writing any code, try the JSON-RPC version of the request interactively. The public endpoint is keyless, so this button works without any setup:

Fetch ledger 30,000,000
curl -X POST 'https://honeycluster.io'
1. Install xrpl.js
##
Bash
pnpm add xrpl
2. Connect and request the ledger
##
TypeScript
import { Client } from 'xrpl'

const client = new Client('wss://honeycluster.io')

await client.connect()

const response = await client.request({
  command: 'ledger',
  ledger_index: 30_000_000,
  transactions: true,
  expand: true,
})

const ledger = response.result.ledger
console.log('close time:', ledger.close_time_human)
console.log('tx count:', ledger.transactions?.length ?? 0)

transactions: true asks rippled for the list of transaction hashes; expand: true tells Clio to return full transaction objects instead of just their hashes. Combining the two is only efficient against Clio — against rippled it would be rejected for ancient ledgers.

3. Iterate transactions
##
TypeScript
for (const tx of ledger.transactions ?? []) {
  if (typeof tx === 'string') continue // shouldn't happen with expand:true
  console.log(
    tx.TransactionType,
    tx.hash,
    tx.Account,
    '→',
    'Destination' in tx ? tx.Destination : '—'
  )
}
4. Close the connection
##
TypeScript
await client.disconnect()
What about huge ledgers?
##

Ledgers during network peaks can contain 1,000+ transactions. If you only need a subset, use ledger_data with binary: false, limit: 200 and paginate through via the returned marker field:

TypeScript
let marker: unknown = undefined
do {
  const page = await client.request({
    command: 'ledger_data',
    ledger_index: 30_000_000,
    limit: 200,
    marker,
  })
  // ...handle page.result.state...
  marker = page.result.marker
} while (marker)

Paginating keeps individual responses small and predictable, which is friendlier on slow networks and easier to checkpoint if your worker crashes mid-scan.

Credit cost
##

A single historical ledger call with expand:true is charged against your Clio quota. Watch the X-Credits-Remaining header on the response — or see Rate Limits for the full cost model.