The ledger_data method retrieves contents of the specified ledger. You can iterate through several calls to retrieve the entire contents of a single ledger version.
A 20-byte hex string identifying the ledger version to use.
ledger_index
[Ledger Index][]
No
The [ledger index][] of the ledger to use, or a shortcut string to choose a ledger automatically. (See [Specifying Ledgers][])
binary
Boolean
No
If true, return ledger entries as hexadecimal strings instead of JSON. The default is false.
limit
Number
No
Limit the number of ledger entries to retrieve. The server may return fewer than this number of entries. Cannot be more than 2048 (when requesting binary) or 256 (when requesting JSON). Positive values outside this range are replaced with the closest valid option. The default is the maximum.
marker
[Marker][]
No
Value from a previous paginated response. Resume retrieving data where that response left off.
type
String
No
Filter results to a specific type of ledger entry. The valid types are: account, amendments, amm, check, deposit_preauth, directory, escrow, fee, hashes, nft_offer, offer, payment_channel, signer_list, state (trust line), and ticket.
The ledger field is deprecated and may be removed without further notice.
The response follows the [standard format][], with a successful result containing the following fields:
Field
Type
Description
ledger_index
Unsigned Integer - [Ledger Index][]
The ledger index of this ledger version.
ledger_hash
String - [Hash][]
Unique identifying hash of this ledger version.
state
Array
Array of JSON objects containing data from the ledger's state tree, as defined below.
marker
[Marker][]
Server-defined value indicating the response is paginated. Pass this to the next call to resume where this call left off.
If a type field is mentioned in the request, the state array will be empty if the first set of array objects does not match the type requested. In such cases, you can use the marker from this response to paginate and retrieve further data.
The format of each object in the state array depends on whether binary was set to true or not in the request. Each state object may include the following fields:
Field
Type
Description
data
String
(Only included if "binary":true) Hex representation of the requested data
LedgerEntryType
String
(Only included if "binary":false) String indicating what type of ledger object this object represents. See ledger object types for the full list.
(Additional fields)
(Various)
(Only included if "binary":false) Additional fields describing this object, depending on which ledger object type it is.
index
String
Unique identifier for this ledger entry, as hex.
Possible Errors
Any of the [universal error types][]
invalidParams - One or more fields are specified incorrectly, or one or more required fields are missing.
lgrNotFound - The ledger specified by the ledger_hash or ledger_index does not exist, or it does exist but the server does not have it.