The ledger method returns information about a specific ledger by index or hash, or the latest validated ledger. See:
Request the latest validated ledger header:
Bashcurl -s https://honeycluster.dev \ -H 'Content-Type: application/json' \ -d '{ "method": "ledger", "params": [ { "ledger_index": "validated", "transactions": false, "expand": false } ] }'
Bashecho '{ "command": "ledger", "ledger_index": "validated", "transactions": false, "expand": false }' | websocat wss://honeycluster.dev
TypeScript// npm i xrpl import { Client } from 'xrpl'; async function getValidatedLedger(): Promise<void> { const client = new Client('wss://honeycluster.dev'); await client.connect(); const res = await client.request({ command: 'ledger', ledger_index: 'validated', transactions: false, expand: false, }); console.log(res); await client.disconnect(); } getValidatedLedger().catch(console.error);
Use ledger_index: validated in production for consistent results.
Set transactions: true and expand: true to include full transaction objects.