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

# compare swap quotes

> Show the selected route, alternatives and estimated output for a swap.

Use this recipe for the quote section of a swap form. One request compares enabled sources. You don't need to send a separate request to each provider.

## Request a quote

This Node.js 20+ example quotes `0.001 ETH` into ROUTE on Robinhood Chain. It only reads a quote; it does not build or submit a transaction.

```javascript theme={null}
const url = new URL('https://api.route.fun/api/v2/quote');
url.search = new URLSearchParams({
  chainId: '4663',
  tokenIn: 'ETH',
  tokenOut: '0x4a72b9702f991b790788f8afa9e7112541f4e8f8',
  amountIn: '1000000000000000',
}).toString();

const response = await fetch(url, {
  signal: AbortSignal.timeout(30000),
  redirect: 'error',
});
const quote = await response.json();
if (!response.ok) {
  const retryAfter = response.headers.get('Retry-After');
  throw new Error([
    quote.error?.code ?? `HTTP ${response.status}`,
    quote.error?.message,
    retryAfter ? `Retry after ${retryAfter} seconds` : '',
  ].filter(Boolean).join(': '));
}
if (quote.expiresAt <= Math.floor(Date.now() / 1000)) {
  throw new Error('Quote expired. Request another before displaying it.');
}

console.log({
  provider: quote.provider,
  status: quote.execution.status,
  expectedOutput: quote.execution.status === 'simulated'
    ? quote.execution.amountOut
    : quote.amountOut,
  expiresAt: quote.expiresAt,
  warnings: quote.warnings,
});
console.table(quote.comparison.candidates.map(candidate => ({
  provider: candidate.provider,
  variant: candidate.variant ?? '',
  selected: candidate.selected,
  status: candidate.status,
  rank: candidate.rank ?? null,
  output: candidate.simulatedAmountOut ?? candidate.quotedAmountOut,
})));
```

The output amounts above are base-unit strings. Get the output token's decimals from the [token endpoint](/api-reference/v2-tokens) before formatting them for a user.

## Read the result

| Field                   | Use it for                                                              |
| ----------------------- | ----------------------------------------------------------------------- |
| `provider`              | The selected source                                                     |
| `execution.status`      | Whether the full candidate was simulated or the check was unavailable   |
| `execution.amountOut`   | The assessed token output when simulation succeeded                     |
| `comparison.candidates` | Alternatives that reached final assessment, including unsuccessful ones |
| `comparison.basis`      | Whether selection used gas-adjusted output or output alone              |
| `expiresAt`             | The quote's expiry in Unix seconds                                      |
| `warnings`              | Coverage, gas and execution caveats to show with the quote              |

A failed or unverified candidate should not look like a ready-to-sign alternative. Use `selected` to identify Route's choice instead of sorting only by the original output estimate. The comparison does not enumerate every pool or every possible route.

`netAmountOut` subtracts a modeled gas cost in output-token units. It is useful for comparison, but it is not the number of tokens the contract must pay the user. Use the token output and the user's slippage choice when setting a minimum.

## Refresh as inputs change

Debounce amount edits, cancel superseded requests and ignore late responses for a previous token pair or amount. Clear the displayed quote when it expires. A later request must get a fresh quote even if the inputs are unchanged.

To restrict a request to one source, add `provider=route`, `provider=kyber` or `provider=zerox`. Read `enabledProviders` from [configuration](/api-reference/v2-config) first. Omitting `provider` compares the enabled sources.

Honor `Retry-After` when the API is busy. Do not retry on every keystroke or silently increase the user's slippage after an error.

**Next:** [Prepare a native-ETH swap](/cookbook/prepare-swap) demonstrates the direct provider. The [wallet flow](/cookbook/wallet-lifecycle) covers the checks required before signing.
