RootResponse
extends Response
in package
Represents the Horizon API root endpoint response
This response contains metadata about the Horizon server and the connected Stellar network. The root endpoint provides essential information for clients including version numbers, network identification, protocol versions, and ledger synchronization status.
Key fields:
- Horizon and Stellar Core version information
- Network passphrase for network identification
- Current protocol version supported by the network
- Latest ledger numbers and timestamps for history and ingestion
- Elder ledger indicating oldest available historical data
This endpoint is typically the first API call made by clients to verify connectivity, determine network type (mainnet, testnet, etc.), check version compatibility, and assess synchronization status before making other requests.
Returned by Horizon endpoint:
- GET / - Root endpoint with server and network metadata
Tags
Table of Contents
Properties
- $httpClient : Client|null
- $rateLimitLimit : int|null
- $rateLimitRemaining : int|null
- $rateLimitReset : int|null
Methods
- fromJson() : RootResponse
- Creates a RootResponse from JSON data
- getCoreLatestLedger() : int
- Gets the latest ledger sequence known to Stellar Core
- getCoreSupportedProtocolVersion() : int
- Gets the maximum protocol version supported by Stellar Core
- getCoreVersion() : string
- Gets the version of the connected Stellar Core
- getCurrentProtocolVersion() : int
- Gets the current protocol version of the network
- getHistoryElderLedger() : int
- Gets the oldest ledger sequence available in Horizon's history
- getHistoryLatestLedger() : int
- Gets the latest ledger sequence stored in Horizon's history database
- getHistoryLatestLedgerClosedAt() : string
- Gets the timestamp when the history latest ledger closed
- getHorizonVersion() : string
- Gets the version of the Horizon API server
- getHttpClient() : Client|null
- Gets the HTTP client used for pagination requests
- getIngestLatestLedger() : int
- Gets the latest ledger sequence ingested by Horizon
- getNetworkPassphrase() : string
- Gets the network passphrase identifying the Stellar network
- getProtocolVersion() : int
- Gets the protocol version supported by the network
- getRateLimitLimit() : int|null
- Returns X-RateLimit-Limit header from the response.
- getRateLimitRemaining() : int|null
- Returns X-RateLimit-Remaining header from the response.
- getRateLimitReset() : int|null
- Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.
- setHeaders() : void
- Extracts and sets rate limiting information from HTTP response headers
- setHttpClient() : void
- Sets the HTTP client for making follow-up requests
- loadFromJson() : void
- Loads response data from a JSON array
Properties
$httpClient
protected
Client|null
$httpClient
= null
$rateLimitLimit
protected
int|null
$rateLimitLimit
= null
$rateLimitRemaining
protected
int|null
$rateLimitRemaining
= null
$rateLimitReset
protected
int|null
$rateLimitReset
= null
Methods
fromJson()
Creates a RootResponse from JSON data
public
static fromJson(array<string|int, mixed> $json) : RootResponse
Parameters
- $json : array<string|int, mixed>
-
Associative array of parsed JSON response
Return values
RootResponse —The populated root response
getCoreLatestLedger()
Gets the latest ledger sequence known to Stellar Core
public
getCoreLatestLedger() : int
Return values
int —The core latest ledger sequence
getCoreSupportedProtocolVersion()
Gets the maximum protocol version supported by Stellar Core
public
getCoreSupportedProtocolVersion() : int
Return values
int —The core supported protocol version number
getCoreVersion()
Gets the version of the connected Stellar Core
public
getCoreVersion() : string
Return values
string —The Stellar Core version string
getCurrentProtocolVersion()
Gets the current protocol version of the network
public
getCurrentProtocolVersion() : int
Return values
int —The current protocol version number
getHistoryElderLedger()
Gets the oldest ledger sequence available in Horizon's history
public
getHistoryElderLedger() : int
Return values
int —The history elder ledger sequence
getHistoryLatestLedger()
Gets the latest ledger sequence stored in Horizon's history database
public
getHistoryLatestLedger() : int
Return values
int —The history latest ledger sequence
getHistoryLatestLedgerClosedAt()
Gets the timestamp when the history latest ledger closed
public
getHistoryLatestLedgerClosedAt() : string
Return values
string —The close time in ISO 8601 format
getHorizonVersion()
Gets the version of the Horizon API server
public
getHorizonVersion() : string
Return values
string —The Horizon version string
getHttpClient()
Gets the HTTP client used for pagination requests
public
getHttpClient() : Client|null
Return values
Client|null —The HTTP client instance, or null if not set
getIngestLatestLedger()
Gets the latest ledger sequence ingested by Horizon
public
getIngestLatestLedger() : int
Return values
int —The ingest latest ledger sequence
getNetworkPassphrase()
Gets the network passphrase identifying the Stellar network
public
getNetworkPassphrase() : string
Return values
string —The network passphrase (e.g., "Public Global Stellar Network ; September 2015")
getProtocolVersion()
Gets the protocol version supported by the network
public
getProtocolVersion() : int
Return values
int —The protocol version number
getRateLimitLimit()
Returns X-RateLimit-Limit header from the response.
public
getRateLimitLimit() : int|null
This number represents the he maximum number of requests that the current client can make in one hour.
Tags
Return values
int|nullgetRateLimitRemaining()
Returns X-RateLimit-Remaining header from the response.
public
getRateLimitRemaining() : int|null
The number of remaining requests for the current window.
Tags
Return values
int|nullgetRateLimitReset()
Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.
public
getRateLimitReset() : int|null
Tags
Return values
int|nullsetHeaders()
Extracts and sets rate limiting information from HTTP response headers
public
setHeaders(array<string|int, mixed> $headers) : void
This method processes the X-Ratelimit-* headers from the HTTP response and stores them for client access.
Parameters
- $headers : array<string|int, mixed>
-
Associative array of HTTP headers from the response
setHttpClient()
Sets the HTTP client for making follow-up requests
public
setHttpClient([Client|null $httpClient = null ]) : void
Paginated responses contain links to next/previous pages. This HTTP client is used when following those links to fetch additional pages.
Parameters
- $httpClient : Client|null = null
-
The Guzzle HTTP client to use for pagination
loadFromJson()
Loads response data from a JSON array
protected
loadFromJson(array<string|int, mixed> $json) : void
This method is used internally to populate response objects from parsed JSON. Subclasses override this to extract their specific data fields.
Parameters
- $json : array<string|int, mixed>
-
Associative array of parsed JSON data