---
title: "Retrieve Rates"
method: GET
path: "/rate"
tags: ["Rates"]
---

# Retrieve Rates

`GET /rate`

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](https://www.investopedia.com/terms/i/indicativequote.asp) or
[firm](https://www.investopedia.com/terms/f/firmquote.asp). 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.


Upon receiving the response, the Anchor Platform will validate the amount and price of the response.

If the validation fails, the Platform will respond to the client application's request with a HTTP status
code of `502 Bad Gateway`.

The `sell_amount`, `buy_amount`, `price`, and `fee` are validated as follows:

- if `rate.fee` exists,
  - `rate.fee.asset` must have a positive value of `significant_decimals` defined in the asset configuration.
  - `rate.fee.total` must equal to the sum of `rate.fee.details.amount`.
  - if the `rate.fee.asset == rate.sell_asset`, `sell_amount ~= price * buy_amount + fee` must hold true.
  - if the `rate.fee.asset == rate.buy_asset`,  `sell_amount ~= price * (buy_amount + fee)` must hold true.
- if `rate.fee` does not exist, `sell_amount ~= price * buy_amount` must hold true.

The `~=` is defined as equality within rounding error.
    The rounding error is defined as `10^(-significant_decimals)`

## Query parameters

- `type` 'indicative' | 'firm', required
- `client_id` string
- `sell_asset` string, required
- `buy_asset` string, required
- `sell_amount` string
- `buy_amount` string
- `country_code` string
- `expire_after` string
- `sell_delivery_method` string
- `buy_delivery_method` string

## Response `200`

Success.

- RateResponse — unresolved $ref

## Other responses

- `422` — 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.
- `500` — Error. The Platform will respond to the client application with the same response code and body.

---

[API](https://skmtc.dev/stellar/apis/callbacks-server.md) · [All operations](https://skmtc.dev/stellar/apis/callbacks-server/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/stellar/callbacks-server/revisions/0d52fa0042d8/schema)
