> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cucu.bo/llms.txt
> Use this file to discover all available pages before exploring further.

# GET /exchange-rate — Tipo de Cambio

> Endpoint público. Snapshot SELL + BUY del mercado P2P para un par fiat/crypto. Sin autenticación.

Endpoint **público** — no requiere API Key. Devuelve el snapshot SELL + BUY del mercado P2P para un par fiat/crypto. Cache de 60 segundos.

## Query Params

| Parámetro | Tipo   | Default | Descripción                                                                        |
| --------- | ------ | ------- | ---------------------------------------------------------------------------------- |
| `fiat`    | string | `BOB`   | Código ISO de moneda fiat: `BOB`, `USD`, `ARS`, `PEN`, `BRL`, `CLP`, `MXN`, `COP`. |
| `crypto`  | string | `USDT`  | Símbolo del activo crypto: `USDT`, `USDC`, etc.                                    |

## Response

| Campo             | Tipo   | Descripción                                                                |
| ----------------- | ------ | -------------------------------------------------------------------------- |
| `fiat`            | string | Moneda fiat consultada.                                                    |
| `crypto`          | string | Activo crypto consultado.                                                  |
| `sell.median`     | float  | Precio mediano de venta. **Usar este valor para conversiones de display.** |
| `sell.top`        | float  | Mejor precio de venta listado en el mercado.                               |
| `sell.min`        | float  | Precio mínimo de venta.                                                    |
| `sell.max`        | float  | Precio máximo de venta.                                                    |
| `sell.ads_count`  | int    | Número de anuncios activos.                                                |
| `sell.fetched_at` | int    | UNIX timestamp de la consulta al mercado.                                  |
| `buy.median`      | float  | Precio mediano de compra.                                                  |
| `spread`          | float  | `median(sell) − median(buy)`. Positivo en condiciones normales.            |
| `source`          | string | Fuente de datos. Actualmente `binance_p2p`.                                |

<Warning>
  **Anti-stale guarantee:** si el upstream no está disponible, el endpoint devuelve `503 Service Unavailable`. Nunca devuelve un valor desactualizado en silencio.
</Warning>

<RequestExample>
  ```bash cURL theme={"system"}
  curl "https://crypto.cucu.ai/api/v1/exchange-rate?fiat=BOB&crypto=USDT"
  ```

  ```javascript JavaScript theme={"system"}
  const response = await fetch(
    'https://crypto.cucu.ai/api/v1/exchange-rate?fiat=BOB&crypto=USDT'
  );
  const data = await response.json();
  ```

  ```python Python theme={"system"}
  import requests

  response = requests.get(
      'https://crypto.cucu.ai/api/v1/exchange-rate',
      params={'fiat': 'BOB', 'crypto': 'USDT'}
  )
  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={"system"}
  {
    "fiat": "BOB",
    "crypto": "USDT",
    "sell": {
      "median": 6.97,
      "top": 6.98,
      "min": 6.95,
      "max": 7.01,
      "ads_count": 12,
      "fetched_at": 1737815400,
      "source": "binance_p2p"
    },
    "buy": {
      "median": 6.94,
      "top": 6.93,
      "min": 6.90,
      "max": 6.96,
      "ads_count": 9,
      "fetched_at": 1737815400,
      "source": "binance_p2p"
    },
    "spread": 0.03,
    "source": "binance_p2p"
  }
  ```

  ```json 503 Service Unavailable theme={"system"}
  {
    "detail": "Upstream market data unavailable"
  }
  ```
</ResponseExample>
