# Exchange API

### Fiat to Crypto Estimation

This method estimates the amount of cryptocurrency you'll receive for a specific fiat payment, based on current market rates and fully accounting for commissions and all associated fees. In other words, if you pay exactly X in fiat, you'll receive the precise crypto amount displayed, with all costs already factored in.

For instance, if you convert 1,000 EUR, the method could return an approximation of 0.3 ETH.

To call the API, it is essential to include the `x-api-key` header.

If the `paymentMethod` parameter is specified, the method returns the `cryptoAmount` that you will receive after applying all fees, including those specific to the selected payment method.\
Otherwise, it returns `cryptoAmounts` for all available payment methods, each reflecting the net amount of crypto you would receive after all applicable fees.

## GET /payment/estimate-fiat-to-crypto-exchange

>

```json
{"openapi":"3.0.0","info":{"title":"ahoracrypto-middleware","version":"0.0.1"},"servers":[{"url":"https://api.ahoracrypto.com"}],"security":[{"jwt":[]}],"paths":{"/payment/estimate-fiat-to-crypto-exchange":{"get":{"tags":["PaymentController"],"responses":{"200":{"description":"Estimate crypto amount based on fiat amount","content":{"application/json":{"schema":{"type":"object","properties":{"fiatAmount":{"type":"number","format":"double","description":"Amount in fiat currency"},"currencyIsoCode":{"type":"string","description":"Fiat currency ISO code (e.g., USD, EUR)"},"cryptoAmount":{"type":"number","format":"double","description":"Estimated amount in cryptocurrency (if a payment method is specified)"},"cryptoAmounts":{"type":"array","description":"Estimated amounts in cryptocurrency for each payment method  (if no payment method is specified)"},"cryptoSymbol":{"type":"string","description":"Cryptocurrency symbol (e.g., USDT, BTC)"}},"required":["fiatAmount","currencyIsoCode","cryptoAmount","cryptoSymbol"]}}}},"400":{"description":"Bad request - Missing required fields or invalid values"},"401":{"description":"Unauthorized - Missing or invalid API key"},"500":{"description":"Internal Server Error"}},"parameters":[{"name":"x-api-key","in":"header","required":true,"schema":{"type":"string"},"description":"API key for authentication"},{"name":"fiatAmount","in":"query","schema":{"type":"number"},"required":true},{"name":"currencyIsoCode","in":"query","schema":{"type":"string"},"required":true},{"name":"cryptoSymbol","in":"query","schema":{"type":"string"},"required":true},{"name":"paymentMethod","in":"query","schema":{"type":"string"},"required":false}],"operationId":"PaymentController.estimateCryptoAmount"}}}}
```

Example response when a payment method is specified:

```json
{
    "cryptoSymbol": "BTC",
    "cryptoAmount": 0.00090935,
    "fiatAmount": 100,
    "currencyIsoCode": "EUR"
}
```

Example response when no payment method is specified:

```json
{
    "cryptoSymbol": "BTC",
    "cryptoAmounts": {
        "bank-transfer": 0.00091621,
        "apple-pay": 0.0009066,
        "google-pay": 0.0009066,
        "card": 0.0009066
    },
    "fiatAmount": 100,
    "currencyIsoCode": "EUR"
}
```

### Crypto to Fiat Estimation

This method calculates the precise fiat amount required to receive the exact specified amount of cryptocurrency, fully accounting for all fees and commissions. In other words, the fiat amount you see is the total payment needed to cover the exact crypto amount you want, with all costs already included.

For example, if you input a crypto amount such as 0.5 BTC, the method might return an estimate of around 25,000 USD.

{% hint style="success" %}
It is important to note that the exchange rate already includes any fees that AhoraCrypto may apply, so it reflects the final rate the user will receive.
{% endhint %}

To call the API, it is essential to include the `x-api-key` header.

If the `paymentMethod` parameter is specified, the method returns the `fiatAmount` you need to pay, including all fees—also those specific to the selected payment method.\
Otherwise, it returns `fiatAmounts` for all available payment methods, each reflecting the total amount you'd need to pay with all applicable fees included.

## GET /payment/estimate-crypto-to-fiat-exchange

>

```json
{"openapi":"3.0.0","info":{"title":"ahoracrypto-middleware","version":"0.0.1"},"servers":[{"url":"https://api.ahoracrypto.com"}],"security":[{"jwt":[]}],"paths":{"/payment/estimate-crypto-to-fiat-exchange":{"get":{"tags":["PaymentController"],"responses":{"200":{"description":"Estimate fiat amount based on crypto amount","content":{"application/json":{"schema":{"type":"object","properties":{"cryptoAmount":{"type":"number","format":"double","description":"Amount in cryptocurrency"},"cryptoSymbol":{"type":"string","description":"Cryptocurrency code (e.g., USDT, BTC)"},"fiatAmount":{"type":"number","format":"double","description":"Estimated amount in fiat currency (if a payment method is specified)"},"fiatAmounts":{"type":"array","description":"Estimated amounts in fiat currency for each payment method (if no payment method is specified)"},"currencyIsoCode":{"type":"string","description":"Fiat currency ISO code (e.g., USD, EUR)"}},"required":["cryptoAmount","cryptoSymbol","fiatAmount","currencyIsoCode"]}}}},"400":{"description":"Bad request - Missing required fields or invalid values"},"401":{"description":"Unauthorized - Missing or invalid API key"},"500":{"description":"Internal Server Error"}},"parameters":[{"name":"x-api-key","in":"header","required":true,"schema":{"type":"string"},"description":"API key for authentication"},{"name":"cryptoAmount","in":"query","schema":{"type":"number"},"required":true},{"name":"cryptoSymbol","in":"query","schema":{"type":"string"},"required":true},{"name":"currencyIsoCode","in":"query","schema":{"type":"string"},"required":true},{"name":"paymentMethod","in":"query","schema":{"type":"string"},"required":false}],"operationId":"PaymentController.estimateFiatAmount"}}}}
```

Example response when a payment method is specified:

```json
{
    "cryptoSymbol": "BTC",
    "cryptoAmount": 0.00091734,
    "fiatAmount": 100,
    "currencyIsoCode": "EUR"
}
```

Example response when no payment method is specified:

```json
{
    "cryptoSymbol": "BTC",
    "cryptoAmount": 0.00091734,
    "fiatAmounts": {
        "bank-transfer": 100,
        "apple-pay": 100.95,
        "google-pay": 100.95,
        "card": 100.95
    },
    "currencyIsoCode": "EUR"
}
```


---

# 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://ahoracrypto.gitbook.io/ahoracrypto/api/exchange-api.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.
