Stellar PHP SDK API Documentation

OfferResponse extends Response

Represents an offer on the Stellar distributed exchange (DEX)

This response contains comprehensive offer details including the seller account, assets being traded, amount available, price information, and optional sponsorship details. Offers represent standing orders in the order book where an account commits to exchange one asset for another at a specified price ratio.

Key fields:

  • Offer ID and seller account
  • Selling and buying asset details
  • Amount available for trading
  • Price (both decimal and rational representation)
  • Optional sponsor account for reserve requirements

Returned by Horizon endpoints:

  • GET /offers - All offers
  • GET /offers/{offer_id} - Specific offer details
  • GET /accounts/{account_id}/offers - Offers created by an account
Tags
see
OfferPriceResponse

For price ratio representation

see
OfferLinksResponse

For related navigation links

see
https://developers.stellar.org

Stellar developer docs Horizon Offers API

since
1.0.0

Table of Contents

Properties

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

Methods

fromJson()  : OfferResponse
getAmount()  : string
Gets the amount of the selling asset available in this offer
getBuying()  : Asset
Gets the asset being bought in this offer
getHttpClient()  : Client|null
Gets the HTTP client used for pagination requests
getLinks()  : OfferLinksResponse
Gets the links to related resources for this offer
getOfferId()  : string
Gets the unique identifier for this offer
getPagingToken()  : string
Gets the paging token for this offer in list results
getPrice()  : string
Gets the decimal representation of the offer price
getPriceR()  : OfferPriceResponse
Gets the rational representation of the offer price
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.
getSeller()  : string
Gets the account address of the seller who created this offer
getSelling()  : Asset
Gets the asset being sold in this offer
getSponsor()  : string|null
Gets the account sponsoring the reserves for this offer
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

getAmount()

Gets the amount of the selling asset available in this offer

public getAmount() : string
Return values
string

The amount available for trading

getBuying()

Gets the asset being bought in this offer

public getBuying() : Asset
Return values
Asset

The buying asset

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

getOfferId()

Gets the unique identifier for this offer

public getOfferId() : string
Return values
string

The offer ID

getPagingToken()

Gets the paging token for this offer in list results

public getPagingToken() : string
Return values
string

The paging token used for cursor-based pagination

getPrice()

Gets the decimal representation of the offer price

public getPrice() : string
Return values
string

The price as a decimal string (buying units per selling unit)

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

getSeller()

Gets the account address of the seller who created this offer

public getSeller() : string
Return values
string

The seller account ID

getSelling()

Gets the asset being sold in this offer

public getSelling() : Asset
Return values
Asset

The selling asset

getSponsor()

Gets the account sponsoring the reserves for this offer

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

The sponsor account ID, or null if not sponsored

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

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