LedgersRequestBuilder

class LedgersRequestBuilder(httpClient: HttpClient, serverUri: Url) : RequestBuilder

Builds requests connected to ledgers.

Ledgers are the foundation of the Stellar network. They represent the state of the network at a particular point in time and contain all the changes (transactions) that have occurred since the previous ledger.

Example usage:

val server = HorizonServer("https://horizon.stellar.org")

// Get a specific ledger by sequence
val ledger = server.ledgers().ledger(12345)

// Get a page of ledgers
val ledgers = server.ledgers()
.limit(10)
.order(Order.DESC)
.execute()

See also

Constructors

Link copied to clipboard
constructor(httpClient: HttpClient, serverUri: Url)

Functions

Link copied to clipboard
open override fun cursor(cursor: String): LedgersRequestBuilder

Sets the cursor parameter for pagination.

Link copied to clipboard
suspend fun execute(): Page<LedgerResponse>

Build and execute request to get a page of ledgers.

Link copied to clipboard
suspend fun ledger(sequence: Long): LedgerResponse

Requests a specific ledger by sequence number.

Link copied to clipboard
open override fun limit(number: Int): LedgersRequestBuilder

Sets the limit parameter defining maximum number of ledgers to return.

Link copied to clipboard
open override fun order(direction: RequestBuilder.Order): LedgersRequestBuilder

Sets the order parameter defining the order in which to return ledgers.

Link copied to clipboard
fun <T : Response> stream(serializer: KSerializer<T>, listener: EventListener<T>, reconnectTimeout: Duration = SSEStream.DEFAULT_RECONNECT_TIMEOUT): SSEStream<T>

Creates a Server-Sent Events (SSE) stream for this request. The stream will automatically reconnect on connection loss and resume from the last received event.