Stellar PHP SDK API Documentation

TradeResponse

Represents a completed trade on the Stellar distributed exchange

This response contains comprehensive trade execution details including the trading parties, assets exchanged, amounts, price, and trade type (orderbook or liquidity pool). Trades occur when offers match or when liquidity pools facilitate exchanges. The response distinguishes between orderbook trades (between two accounts with offers) and liquidity pool trades (between an account and an AMM pool).

Key fields:

  • Trade ID and timestamp
  • Trade type (orderbook or liquidity_pool)
  • Base and counter accounts/offers
  • Assets and amounts exchanged
  • Trade price and direction
  • Liquidity pool details (if applicable)

Returned by Horizon endpoints:

  • GET /trades - All trades
  • GET /accounts/{account_id}/trades - Trades for an account
  • GET /offers/{offer_id}/trades - Trades for a specific offer
  • GET /liquidity_pools/{liquidity_pool_id}/trades - Trades involving a liquidity pool
Tags
see
TradePriceResponse

For trade price representation

see
TradeLinksResponse

For related navigation links

see
https://developers.stellar.org

Stellar developer docs Horizon Trades API

since
1.0.0

Table of Contents

Methods

fromJson()  : TradeResponse
getBaseAccount()  : string|null
Gets the account address on the base side of the trade
getBaseAmount()  : string
Gets the amount of the base asset traded
getBaseAssetCode()  : string|null
Gets the asset code of the base asset
getBaseAssetIssuer()  : string|null
Gets the issuer of the base asset
getBaseAssetType()  : string
Gets the asset type of the base asset
getBaseLiquidityPoolId()  : string|null
Gets the liquidity pool ID if the base side is a liquidity pool
getBaseOfferId()  : string|null
Gets the base offer ID for orderbook trades
getCounterAccount()  : string|null
Gets the account address on the counter side of the trade
getCounterAmount()  : string
Gets the amount of the counter asset traded
getCounterAssetCode()  : string|null
Gets the asset code of the counter asset
getCounterAssetIssuer()  : string|null
Gets the issuer of the counter asset
getCounterAssetType()  : string
Gets the asset type of the counter asset
getCounterLiquidityPoolId()  : string|null
Gets the liquidity pool ID if the counter side is a liquidity pool
getCounterOfferId()  : string|null
Gets the counter offer ID for orderbook trades
getId()  : string
Gets the unique identifier for this trade
getLedgerCloseTime()  : string
Gets the timestamp when the ledger containing this trade was closed
getLinks()  : TradeLinksResponse
Gets the links to related resources for this trade
getLiquidityPoolFeeBp()  : int|null
Gets the liquidity pool fee in basis points
getOfferId()  : string|null
Gets the offer ID for orderbook trades (deprecated, use base/counter offer IDs)
getPagingToken()  : string
Gets the paging token for this trade in list results
getPrice()  : TradePriceResponse
Gets the price of the trade as a rational number
getTradeType()  : string
Gets the type of trade (orderbook or liquidity_pool)
isBaseIsSeller()  : bool
Indicates whether the base account was selling in this trade
loadFromJson()  : void

Methods

getBaseAccount()

Gets the account address on the base side of the trade

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

The base account ID, or null if base is a liquidity pool

getBaseAmount()

Gets the amount of the base asset traded

public getBaseAmount() : string
Return values
string

The base amount

getBaseAssetCode()

Gets the asset code of the base asset

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

The base asset code, or null for native assets

getBaseAssetIssuer()

Gets the issuer of the base asset

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

The base asset issuer, or null for native assets

getBaseAssetType()

Gets the asset type of the base asset

public getBaseAssetType() : string
Return values
string

The base asset type

getBaseLiquidityPoolId()

Gets the liquidity pool ID if the base side is a liquidity pool

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

The base liquidity pool ID, or null if not a pool trade

getBaseOfferId()

Gets the base offer ID for orderbook trades

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

The base offer ID, or null if not an orderbook trade

getCounterAccount()

Gets the account address on the counter side of the trade

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

The counter account ID, or null if counter is a liquidity pool

getCounterAmount()

Gets the amount of the counter asset traded

public getCounterAmount() : string
Return values
string

The counter amount

getCounterAssetCode()

Gets the asset code of the counter asset

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

The counter asset code, or null for native assets

getCounterAssetIssuer()

Gets the issuer of the counter asset

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

The counter asset issuer, or null for native assets

getCounterAssetType()

Gets the asset type of the counter asset

public getCounterAssetType() : string
Return values
string

The counter asset type

getCounterLiquidityPoolId()

Gets the liquidity pool ID if the counter side is a liquidity pool

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

The counter liquidity pool ID, or null if not a pool trade

getCounterOfferId()

Gets the counter offer ID for orderbook trades

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

The counter offer ID, or null if not an orderbook trade

getId()

Gets the unique identifier for this trade

public getId() : string
Return values
string

The trade ID

getLedgerCloseTime()

Gets the timestamp when the ledger containing this trade was closed

public getLedgerCloseTime() : string
Return values
string

The ledger close time in ISO 8601 format

getLiquidityPoolFeeBp()

Gets the liquidity pool fee in basis points

public getLiquidityPoolFeeBp() : int|null
Return values
int|null

The fee in basis points, or null if not a pool trade

getOfferId()

Gets the offer ID for orderbook trades (deprecated, use base/counter offer IDs)

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

The offer ID, or null if not an orderbook trade

getPagingToken()

Gets the paging token for this trade in list results

public getPagingToken() : string
Return values
string

The paging token used for cursor-based pagination

getTradeType()

Gets the type of trade (orderbook or liquidity_pool)

public getTradeType() : string
Return values
string

The trade type

isBaseIsSeller()

Indicates whether the base account was selling in this trade

public isBaseIsSeller() : bool
Return values
bool

True if the base side was selling, false if buying

loadFromJson()

protected loadFromJson(array<string|int, mixed> $json) : void
Parameters
$json : array<string|int, mixed>

        
On this page

Search results