# Exchanges

Swapping between different currencies can easily be done using 0xpay Exchange API.&#x20;

{% hint style="info" %}
In order to make an exchange, you'll need to account for several factors:

* **Supported exchange pairs** – some trading pairs might not be available, be sure to check for them. &#x20;
* **Price Volatility** – due to extreme volatility in crypto markets, exchange price estimate is fixed for 10 seconds. If you wait longer than 10 seconds before executing an exchange, it might fail due to price change.&#x20;
* **Liquidity & fees** – while you can always set your own fees for exchange operations, it is necessary to maintain enough liquidity for swap fees on your merchant balance.
  {% endhint %}

### Exchange Flow

> 1. User wants to exchange 100 USDT to ETH on your platform. In order to check if the exchange pair is supported, your system sends a [Get Available Exchange Directions](/public-api/endpoints/exchange.md#get-available-exchange-directions) request to 0xpay API.&#x20;
> 2. In response, 0xpay API will send a list of all trading pairs, along with info about min/max amounts to exchange.
> 3. After confirming the trading pair, user inputs the amount to exchange and presses **"Calculate"** button on your website. At this point your system needs to make a request to [Estimate Exchange](/public-api/endpoints/exchange.md#estimate-exchange) endpoint in order to receive actual price and exchange fee.
> 4. 0xpay calculates exchange parameters and responds with a notification to your platform. You can display these parameters (exchange rate, pair, fees) on the platform for the users to acknowledge.
> 5. When user presses the **Exchange** button, your system will send a request to [Create Exchange operation](/public-api/endpoints/exchange.md#create-exchange-operation) endpoint.  &#x20;
> 6. 0xpay creates an exchange operation and notifies you about status of the exchange.
> 7. After status changes to "Done", you can go ahead and modify user's balances on the platform!


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.0xpay.app/integration-cookbook/exchanges.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
