Retrieve Rates
Transactions that involve two non-equivalent on & off-chain assets (such as USDC on Stellar and fiat EUR) must use exchange rates that are communicated to the client application requesting the transaction. When clients make requests to the Platform for these exchange rates, the Platform sends this request to the anchor to fetch it.
Rates can be indicative or firm. The anchor must provide an ID and expiration if the client requests a firm rate.
Anchors can provide discounted rates specific client applications. The Platform includes the client_id
parameter
for this reason.
Either sell_amount
or buy_amount
will be included in requests as parameters, but never both. In the same way,
either sell_delivery_method
and buy_delivery_method
may be included in requests, but never both, since either
sell_asset
or buy_asset
is a Stellar asset.
Query Parameters
- type string required
Possible values: [
indicative
,firm
]The type of rate requested. If
firm
, the response must includerate.id
andrate.expires_at
. - client_id string
An identifier for the client application making the request. This ID can be used to offer different fees to different clients.
Client IDs will be the Stellar public key the public key used to authenticate via SEP-10. Anchors must ensure that the public key specified in the request matches a public key known to belong to the sending anchor.
This parameter will only be specified if the client is authenticated via SEP-10. Anchors can define whether or not authentication is required for fetching indicative rates. Firm rates always require authentication.
- sell_asset string required
The asset the client application will send to the anchor in exchange for
buy_asset
in Asset Identification Format. - buy_asset string required
The asset the that the anchor will send in exchange for
sell_asset
in Asset Identification Format. - sell_amount string
The amount of
sell_asset
the client application will send in exchange forbuy_asset
. Will not be used in conjuction withbuy_amount
. - buy_amount string
The amount of
buy_asset
the anchor will send in exchange forsell_asset
. Will not be used in conjuction withsell_amount
. - country_code string
The ISO 3166-1 alpha-3 code of the user's current address. Anchors should expect this parameter to be provided if one of the assets of the buy/sell pair is fiat and it is available in two or more countries.
- expire_after string
The client's desired
expires_at
date and time for the quote that can be used if this is a firm quote. This should be a UTC ISO 8601 string. Anchors should return400 Bad Request
if an expiration date on or after the requested value cannot be provided. - sell_delivery_method string
The method the client or user will use to deliver
sell_asset
to the Anchor. This value may affect the expiration and price provided. The values used for this parameter is defined in the application's configuration. Will not be used in conjuction withbuy_delivery_method
. - buy_delivery_method string
The method the client or user wants used to receive
buy_asset
from the Anchor. This value may affect the expiration and price provided. The values used for this parameter is defined in the application's configuration. Will not be used in conjuction withsell_delivery_method
.
- 200
- 422
- 500
Success.
- application/json
- Schema
- Example (from schema)
Schema
rate object
id stringID of the firm quote. NOT USED when
type=indicative
.expires_at date-timeExpiration for the quote. NOT USED when
type=indicative
.price string requiredThe conversion price offered by the anchor for one unit of
buy_asset
in terms ofsell_asset
, without including fees. In traditional finance,buy_asset
would be referred to as the base asset andsell_asset
as the counter asset. The formulasell_amount - fee = price * buy_amount
must hold true (ref).sell_amount string requiredThe amount of
sell_asset
the anchor will exchange forbuy_asset
. It could be different from thesell_amount
provided in the request, depending on how fees are applied by the Anchor.buy_amount string requiredThe amount of
buy_asset
the anchor will provide withsell_asset
. It could be different from thebuy_amount
provided in the request, depending on how fees are applied by the Anchor.fee object
An object describing the fees added on top of the rate provided via the
price
attribute.total string requiredThe total fee to be applied.
asset string requiredThe asset the fee will be charged in. Must be represented in Asset Identification Format.
details object[]
Array [name string requiredThe name of the fee, for example
ACH fee
,Brazilian conciliation fee
,Service fee
, etc.description stringA text describing the fee.
amount string requiredThe amount of asset applied. If
fee.details
is provided,sum(fee.details.amount)
should be equalsfee.total
.]
{
"rate": {
"id": "string",
"expires_at": "2023-06-02T22:28:25.293Z",
"price": "string",
"sell_amount": "string",
"buy_amount": "string",
"fee": {
"total": "string",
"asset": "string",
"details": [
{
"name": "string",
"description": "string",
"amount": "string"
}
]
}
}
}
Unprocessable Entity. This status should be returned when the anchor understood the request but cannot
return a success response.
In these cases, the Platform will respond to the client application's request with a 400 Bad Request
and include the error message provided by the anchor in the response body.
- application/json
- Schema
- Example (from schema)
Schema
- error string required
- id string
{
"error": "string",
"id": "string"
}
Error. The Platform will respond to the client application with the same response code and body.
- application/json
- Schema
- Example (from schema)
Schema
- error string required
- id string
{
"error": "string",
"id": "string"
}