HealthRequestBuilder

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

Builds requests for the health endpoint.

The health endpoint provides information about the current operational status of the Horizon server. It returns three key indicators that determine whether the server is functioning properly:

  • Database connectivity

  • Stellar Core availability

  • Stellar Core synchronization status

The server is considered healthy when all three indicators are true.

This endpoint has no parameters - it simply returns the current health status.

Note: The health endpoint returns Content-Type: text/plain instead of application/json, so this builder handles the response parsing differently from other endpoints.

Example usage:

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

// Get current health status
val health = server.health().execute()

if (health.isHealthy) {
println("Server is healthy")
println("Database connected: ${health.databaseConnected}")
println("Core up: ${health.coreUp}")
println("Core synced: ${health.coreSynced}")
} else {
println("Server is experiencing issues")
if (!health.databaseConnected) println("Database is not connected")
if (!health.coreUp) println("Stellar Core is not up")
if (!health.coreSynced) println("Stellar Core is not synced")
}

See also

Constructors

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

Functions

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

Health endpoint doesn't support cursor pagination. This method throws UnsupportedOperationException.

Link copied to clipboard
suspend fun execute(): HealthResponse

Build and execute request to get health status.

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

Health endpoint doesn't support limit parameter. This method throws UnsupportedOperationException.

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

Health endpoint doesn't support order parameter. This method throws UnsupportedOperationException.

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.