> For the complete documentation index, see [llms.txt](https://docs.txn.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.txn.io/exchange/reading-exchange-rates.md).

# Reading exchange rates

<mark style="color:green;">`GET`</mark> `/api/public/v1/exchange/rate`

Returns the **indicative mid-market** exchange rate for a currency pair. The rate includes no spread and no fees, so use it to display or estimate amounts. For a firm price for a specific amount, use [Creating quote](https://docs.txn.io/exchange/creating-quote.md) instead.

**Headers**

| Name          | Value                      |
| ------------- | -------------------------- |
| Content-Type  | `application/vnd.api+json` |
| Authorization | `Bearer <api_token>`       |

**Query parameters**

<table><thead><tr><th>Name</th><th width="105">Type</th><th>Description</th></tr></thead><tbody><tr><td>sell_currency_code</td><td>string</td><td>Currency code to sell. E.g. EUR. Refer to <a href="https://docs.txn.io/exchange/supported-currency-pairs.md">Supported currency pairs</a>.</td></tr><tr><td>buy_currency_code</td><td>string</td><td>Currency code to buy. E.g. USDT. Refer to <a href="https://docs.txn.io/exchange/supported-currency-pairs.md">Supported currency pairs</a>.</td></tr></tbody></table>

**Reading the rate**

`sell_currency_code` and `buy_currency_code` select the currency pair. They don't set the direction of the result: the rate is returned in the orientation of the pair as it is configured for your account, so both orders return the same response. For example, in Sandbox, `sell_currency_code=USDT` with `buy_currency_code=BTC` and `sell_currency_code=BTC` with `buy_currency_code=USDT` both return `baseCurrencyCode` `BTC` and `quoteCurrencyCode` `USDT`. Always read the direction from `baseCurrencyCode` and `quoteCurrencyCode`.

`price` is the amount of `quoteCurrencyCode` for 1 unit of `baseCurrencyCode`. To convert an amount:

* from the base currency to the quote currency, multiply by `price`;
* from the quote currency to the base currency, divide by `price`.

For example, if the response has `baseCurrencyCode` `BTC`, `quoteCurrencyCode` `USDT` and `price` `74192.4`, then 500 USDT is 500 / 74192.4, about 0.00673923 BTC.

`quantity` is returned for information. You can't set it, and it doesn't change how `price` is read.

If your account has the pair in neither order, the endpoint returns `422` with `currency_pair_not_supported`.

**cURL**

```bash
curl -G "https://api.sandbox.txn.io/api/public/v1/exchange/rate" \
     -H 'Content-Type: application/vnd.api+json' \
     -H 'Authorization: Bearer <api_key>' \
     --data-urlencode 'sell_currency_code=EUR' \
     --data-urlencode 'buy_currency_code=USDT'
```

**Response**

{% tabs %}
{% tab title="HTTP 200" %}

```json
{
  "data": {
    "id": "USDTEUR/10.0USDT",
    "type": "exchangeRates",
    "attributes": {
      "baseCurrencyCode": "USDT",
      "quoteCurrencyCode": "EUR",
      "direction": "mid_market_rate",
      "price": "0.8716",
      "quantity": "10.0"
    }
  },
  "meta": {},
  "jsonapi": {
    "version": "1.0"
  }
}
```

{% endtab %}

{% tab title="HTTP 422" %}

```json
{
  "errors": [
    {
      "status": 422,
      "title": "Currency pair not supported",
      "code": "currency_pair_not_supported"
    }
  ]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.txn.io/exchange/reading-exchange-rates.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
