# Pair Configuration

The pair configuration endpoint checks whether a trading pair is supported and returns token metadata including decimal precision. Use it to validate tokens and amounts before calling the quote endpoint.

## Endpoint

```
GET /api/v1/pair-config
```

## Request Parameters

| Parameter | Type   | Required | Description                                   |
| --------- | ------ | -------- | --------------------------------------------- |
| `from`    | string | Yes      | Input token identifier (e.g., `WEGLD-bd4d79`) |
| `to`      | string | Yes      | Output token identifier (e.g., `USDC-c76f1f`) |

## Response Format

### Supported Pair

```json
{
  "from": "WEGLD-bd4d79",
  "to": "USDC-c76f1f",
  "supported": true,
  "decimalsIn": 18,
  "decimalsOut": 6,
  "minAmountIn": "1000000000",
  "minAmountInShort": 0.000000001
}
```

### Unsupported Pair — Unknown Token

```json
{
  "from": "WEGLD-bd4d79",
  "to": "UNKNOWN-123456",
  "supported": false,
  "error": "unknown tokenOut"
}
```

### Unsupported Pair — No Route

```json
{
  "from": "TOKEN-a1b2c3",
  "to": "TOKEN-d4e5f6",
  "supported": false,
  "error": "no path between tokens"
}
```

## Response Fields

| Field              | Type    | Description                                                                    |
| ------------------ | ------- | ------------------------------------------------------------------------------ |
| `from`             | string  | Input token identifier                                                         |
| `to`               | string  | Output token identifier                                                        |
| `supported`        | boolean | `true` if the pair can be traded; `false` otherwise                            |
| `decimalsIn`       | number  | Decimal precision of the input token. Present when `supported: true`.          |
| `decimalsOut`      | number  | Decimal precision of the output token. Present when `supported: true`.         |
| `minAmountIn`      | string  | Minimum viable input amount in smallest units. Present when `supported: true`. |
| `minAmountInShort` | number  | Human-readable minimum input amount. Present when `supported: true`.           |
| `error`            | string  | Error description. Present when `supported: false`.                            |

## Validate Before Quote

{% hint style="info" %}
Call `pair-config` before requesting a quote to catch invalid tokens and provide accurate error messages to your users. It is a lightweight check that does not run the full routing algorithm.
{% endhint %}

```bash
curl "https://swap.xoxno.com/api/v1/pair-config?\
from=WEGLD-bd4d79&\
to=USDC-c76f1f"
```

```javascript
async function checkPairSupport(tokenIn, tokenOut) {
  const response = await fetch(
    `https://swap.xoxno.com/api/v1/pair-config?from=${tokenIn}&to=${tokenOut}`
  );
  const config = await response.json();

  if (!config.supported) {
    throw new Error(`Pair not supported: ${config.error}`);
  }

  return {
    decimalsIn: config.decimalsIn,
    decimalsOut: config.decimalsOut,
    minAmountIn: BigInt(config.minAmountIn)
  };
}
```

### Validate Amount Before Quoting

```javascript
async function getQuoteWithValidation(from, to, amount) {
  const config = await checkPairSupport(from, to);

  if (BigInt(amount) < BigInt(config.minAmountIn)) {
    throw new Error(
      `Amount ${amount} is below the minimum of ${config.minAmountInShort} ${from}`
    );
  }

  return fetchQuote({ from, to, amountIn: amount });
}
```

### Build a Token Selector

Use `pair-config` to determine which output tokens are available for a given input token:

```javascript
async function getAvailableOutputTokens(inputToken, allTokens) {
  const results = await Promise.all(
    allTokens
      .filter(token => token !== inputToken)
      .map(async token => {
        const config = await checkPairSupport(inputToken, token);
        return config.supported ? { token, decimals: config.decimalsOut } : null;
      })
  );

  return results.filter(Boolean);
}
```

## Token Decimals Reference

Common token decimal values on MultiversX:

| Token        | Decimals | Smallest unit example           |
| ------------ | -------- | ------------------------------- |
| EGLD / WEGLD | 18       | `1000000000000000000` = 1 WEGLD |
| USDC         | 6        | `1000000` = 1 USDC              |
| USDT         | 6        | `1000000` = 1 USDT              |
| UTK          | 18       | `1000000000000000000` = 1 UTK   |
| MEX          | 18       | `1000000000000000000` = 1 MEX   |

{% hint style="warning" %}
Always use the `decimalsIn` / `decimalsOut` values from the API response rather than hardcoded constants. Some tokens have non-standard decimal configurations.
{% endhint %}

## Related Topics

* [Quote Endpoint](/developers/aggregator-api/quote.md) — Full quote API reference
* [Integration Guide](/developers/aggregator-api/integration-guide.md) — Step-by-step integration walkthrough
* [Error Reference](https://github.com/XOXNO/docs/blob/main/developers/aggregator-api/error-reference.md) — Full error code reference


---

# 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.xoxno.com/developers/aggregator-api/pair-config.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.
