Stellar PHP SDK API Documentation

FederationResponse extends Response

Response from a SEP-0002 federation query.

This class represents the response from a federation server containing the resolved Stellar account ID, optional memo type and value, and the original Stellar address if a reverse lookup was performed.

Error responses (HTTP status codes other than 200 or 3xx) will contain an "error" field with additional details from the federation server.

Note: Federation responses should not be cached. Some organizations may generate random IDs to protect user privacy, and these IDs may change over time.

Tags
see
https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0002.md
see
Federation
see
FederationRequestBuilder

Table of Contents

Properties

$httpClient  : Client|null
$rateLimitLimit  : int|null
$rateLimitRemaining  : int|null
$rateLimitReset  : int|null

Methods

fromJson()  : FederationResponse
Constructs a FederationResponse from JSON data.
getAccountId()  : string|null
Gets the resolved Stellar account ID.
getHttpClient()  : Client|null
Gets the HTTP client used for pagination requests
getMemo()  : string|null
Gets the memo value.
getMemoType()  : string|null
Gets the memo type.
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.
getStellarAddress()  : string|null
Gets the Stellar address.
setAccountId()  : void
Sets the Stellar account ID.
setHeaders()  : void
Extracts and sets rate limiting information from HTTP response headers
setHttpClient()  : void
Sets the HTTP client for making follow-up requests
setMemo()  : void
Sets the memo value.
setMemoType()  : void
Sets the memo type.
setStellarAddress()  : void
Sets the Stellar address.
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()

Constructs a FederationResponse from JSON data.

public static fromJson(array<string|int, mixed> $json) : FederationResponse
Parameters
$json : array<string|int, mixed>

The JSON data to parse.

Return values
FederationResponse

The constructed response.

getAccountId()

Gets the resolved Stellar account ID.

public getAccountId() : string|null
Return values
string|null

The account ID (G-address).

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

getMemo()

Gets the memo value.

public getMemo() : string|null
Return values
string|null

The memo value.

getMemoType()

Gets the memo type.

public getMemoType() : string|null
Return values
string|null

The memo type ("text", "id", or "hash"). For "hash" type, the memo value will be base64-encoded.

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
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getRateLimitRemaining()

Returns X-RateLimit-Remaining header from the response.

public getRateLimitRemaining() : int|null

The number of remaining requests for the current window.

Tags
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getRateLimitReset()

Returns X-RateLimit-Reset header from the response. Seconds until a new window starts.

public getRateLimitReset() : int|null
Tags
see
https://developers.stellar.org

Stellar developer docs Rate limiting documentation

Return values
int|null

getStellarAddress()

Gets the Stellar address.

public getStellarAddress() : string|null
Return values
string|null

The Stellar address in format "user*domain.com".

setAccountId()

Sets the Stellar account ID.

public setAccountId(string|null $accountId) : void
Parameters
$accountId : string|null

The account ID.

setHeaders()

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

setMemo()

Sets the memo value.

public setMemo(string|null $memo) : void
Parameters
$memo : string|null

The memo value.

setMemoType()

Sets the memo type.

public setMemoType(string|null $memoType) : void
Parameters
$memoType : string|null

The memo type.

setStellarAddress()

Sets the Stellar address.

public setStellarAddress(string|null $stellarAddress) : void
Parameters
$stellarAddress : string|null

The Stellar address.

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


        
On this page

Search results