Skip to main content
The getLedgers method returns a detailed list of ledgers starting from the user specified starting point that you can paginate as long as the pages fall within the history retention of their corresponding RPC provider.

Params (3)

Please note that parameter structure within the request must contain named parameters as a by-name object, and not as positional arguments in a by-position array
number
Ledger sequence number to start fetching responses from (inclusive). This method will return an error if startLedger is less than the oldest ledger stored in this node, or greater than the latest ledger seen by this node. If a cursor is included in the request, startLedger must be omitted.Sequence number of the ledger.
object
Pagination in stellar-rpc is similar to pagination in Horizon. See Pagination.
string
Lets the user choose the format in which the response should be returned - either as unpacked JSON or as base64-encoded XDR strings. Note that you should not rely on any schema for the JSON, as it will change when the underlying XDR changes.Specifies whether XDR should be encoded as Base64 (default or ‘base64’) or JSON (‘json’).

Result

(getLedgersResult)
object[]
number
The sequence number of the latest ledger known to Stellar RPC at the time it handled the request.
number
The unix timestamp of the close time of the latest ledger known to Stellar RPC at the time it handled the request.
number
The sequence number of the oldest ledger ingested by Stellar RPC at the time it handled the request.
number
The unix timestamp of the close time of the oldest ledger ingested by Stellar RPC at the time it handled the request.
string
A token which can be included in a subsequent request to obtain the next page of results.

Example

Query a list of ledgers starting from the given startLedger. Request
Result

Using the Lab

You can retrieve a list of past ledgers using the getLedgers method in the Stellar Laboratory. This endpoint returns detailed ledger data starting from a specified point, with support for pagination—as long as the requested range falls within the history retention of the RPC provider. The method also supports an optional XDR format parameter, which allows developers to choose between unpacked JSON or base64-encoded XDR strings for the response format. 👉 View getLedgers on the Lab Lab: getLedgers