price
Fetches an indicative price for a specific asset pair and amount.
Returns a non-binding price quote for exchanging one asset for another. Either sellAmount or buyAmount must be provided, but not both.
This price is indicative and non-binding. The actual price will be calculated at conversion time once the anchor receives funds. For binding commitments, use postQuote to request a firm quote.
Return
Sep38PriceResponse containing price details and fees
Parameters
Context for quote usage ("sep6", "sep24", or "sep31")
Asset to sell (e.g., "stellar:USDC:G...", "iso4217:USD")
Asset to buy
Optional amount of sellAsset to exchange (mutually exclusive with buyAmount)
Optional amount of buyAsset to receive (mutually exclusive with sellAmount)
Optional delivery method name from info endpoint
Optional delivery method name from info endpoint
Optional ISO 3166-1 alpha-2 or ISO 3166-2 country code
Optional JWT token from SEP-10 authentication
Throws
If both or neither amount parameters are provided
If request parameters are invalid (400)
For unexpected HTTP status codes
Example:
val priceResponse = quoteService.price(
context = "sep6",
sellAsset = "iso4217:BRL",
buyAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
sellAmount = "542",
sellDeliveryMethod = "PIX",
countryCode = "BR"
)
println("Exchange rate: ${priceResponse.price} BRL per USDC")
println("Effective rate (with fees): ${priceResponse.totalPrice} BRL per USDC")
println("You'll receive: ${priceResponse.buyAmount} USDC")
println("Total cost: ${priceResponse.sellAmount} BRL")
println("Fee: ${priceResponse.fee.total} ${priceResponse.fee.asset}")