prices
Fetches indicative prices for available assets given a base asset and amount.
Returns non-binding price information for multiple asset pairs. Either sellAsset or buyAsset must be provided, but not both. The corresponding amount parameter (sellAmount or buyAmount) is also required.
When sellAsset is provided, the response contains Sep38PricesResponse.buyAssets. When buyAsset is provided, the response contains Sep38PricesResponse.sellAssets.
These prices are indicative and non-binding. For binding commitments, use postQuote.
Return
Sep38PricesResponse containing prices for available assets
Parameters
Asset to sell using Asset Identification Format (mutually exclusive with buyAsset)
Asset to buy using Asset Identification Format (mutually exclusive with sellAsset)
Amount of sellAsset to exchange (required when sellAsset is provided)
Amount of buyAsset to receive (required when buyAsset is provided)
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 neither or both sellAsset and buyAsset are provided
If request parameters are invalid (400)
For unexpected HTTP status codes
Example - Get buy options (selling USDC):
val pricesResponse = quoteService.prices(
sellAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
sellAmount = "100",
sellDeliveryMethod = null,
buyDeliveryMethod = "PIX",
countryCode = "BR"
)
pricesResponse.buyAssets?.forEach { buyAsset ->
println("Buy ${buyAsset.asset} at price ${buyAsset.price}")
}Example - Get sell options (buying USDC):
val pricesResponse = quoteService.prices(
buyAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
buyAmount = "100",
sellDeliveryMethod = "PIX",
countryCode = "BR"
)
pricesResponse.sellAssets?.forEach { sellAsset ->
println("Sell ${sellAsset.asset} at price ${sellAsset.price}")
}