For the complete documentation index, see llms.txt. This page is also available as Markdown.

ledger_data - XRPL

Example code for the ledger_data JSON RPC method. Complete guide to using ledger_data JSON-RPC in the GetBlock Web3 documentation.

This method retrieves contents of the specified ledger. You can iterate through several calls to retrieve the entire contents of a single ledger version.

Parameters

Parameter
Type
Required
Description

ledger_hash

string

No

Ledger hash

ledger_index

string/number

No

Ledger index or shortcut

binary

boolean

No

Return binary format

limit

number

No

Maximum results (10-400)

marker

object

No

Pagination marker

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS_TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ledger_data",
    "params": [{
        "ledger_index": "validated",
        "limit": 10
    }],
    "id": "getblock.io"
}'
ledger_data.js
const axios = require('axios');

const url = 'https://go.getblock.io/<ACCESS_TOKEN>/';
const headers = {
    'Content-Type': 'application/json'
};

const payload = {
    jsonrpc: '2.0',
    method: 'ledger_data',
    params: [{
        ledger_index: 'validated',
        limit: 10
    }],
    id: 'getblock.io'
};

axios.post(url, payload, { headers })
    .then(response => console.log(response.data))
    .catch(error => console.error(error));

Response Example

Response Parameters

Parameter
Type
Description

state

array

Ledger entries

marker

object

Continue pagination

Field
Type
Description

ledger_index

number

Ledger index

ledger_hash

string

Ledger hash

state

array

Ledger entries

marker

object

Pagination marker

Use Cases

  • Iterate ledger contents

  • Full ledger analysis

  • State snapshots

Error Handling

Error Code
Description

lgrNotFound

Ledger not found

invalidParams

Invalid parameters

SDK Integration

Last updated

Was this helpful?