# GET /route

> GET /route of the Intear DEX Aggregator: every query parameter, the response, and how quotes from NEAR DEXs are ranked.

This page is part of the DEX Aggregator docs. The aggregator is at `https://router.intear.tech`, with live quotes at `wss://router.intear.tech/route/subscribe`, on NEAR mainnet only. https://docs.intear.tech/dex-aggregator/llms-full.txt has all of its pages in one file, and https://docs.intear.tech/llms.txt lists every page of the Intear docs.

```
GET https://router.intear.tech/route
```

Returns an array of [quotes](https://docs.intear.tech/dex-aggregator/reference/quote.md), one per DEX that found a route, best first. If no DEX found a route, the array is empty.

## Example

```
https://router.intear.tech/route?token_in=near&token_out=nep141:usdt.tether-token.near&amount_in=1000000000000000000000000&slippage_type=Fixed&slippage=0.01&trader_account_id=alice.near&referrer_id=alice.near
```

## Query parameters

### Required

| Parameter | Type | Description |
| --- | --- | --- |
| `token_in` | [token ID](https://docs.intear.tech/dex-aggregator/guides/tokens.md#token-id-format) | Token to swap from |
| `token_out` | [token ID](https://docs.intear.tech/dex-aggregator/guides/tokens.md#token-id-format) | Token to swap to. Must be different from `token_in` |
| `amount_in` **or** `amount_out` | integer string | Exact amount to pay, or exact amount to receive, in the token's smallest unit. Pass exactly one. If both are given, the first one in the query string is used. See [Exact input and exact output](https://docs.intear.tech/dex-aggregator/guides/amounts.md) |
| `slippage_type` | `Fixed` \| `Auto` | See [Slippage](https://docs.intear.tech/dex-aggregator/guides/slippage.md) |
| `slippage` | decimal | With `Fixed`: slippage from `0` to `1`. `0.01` is 1% |
| `min_slippage`, `max_slippage` | decimal | With `Auto`: the range to choose slippage from, each `0` to `1` |

### Optional

| Parameter | Type | Description |
| --- | --- | --- |
| `trader_account_id` | account ID | The account that will sign the transactions. Lets the route include missing storage deposits and registrations, and a TEAR [fee discount](https://docs.intear.tech/dex-aggregator/guides/amounts.md#fee-discounts) on Plach. **Strongly recommended** |
| `fees` | JSON object | Your own fee: accounts and the fee each charges, as a fraction of the swap, like `{"alice.near":0.005}` for 0.5%, URL-encoded. Up to 4 accounts and 5% in total, each in steps of 0.000001. Charged once, on the input. Each account gets 80% of its fee and 20% goes to the aggregator. See [referral fees](https://docs.intear.tech/dex-aggregator/guides/referral-fees.md) |
| `referrer_id` | account ID | Your account, for [referral tracking](https://docs.intear.tech/dex-aggregator/guides/referral-fees.md#referral-tracking) on DEXs that support it |
| `dexes` | comma-separated list | Only use these DEXs, for example `Rhea,RheaDcl,IntearDex`. Defaults to all. Must not be empty. IDs are case-sensitive, see [DEXs](https://docs.intear.tech/dex-aggregator/reference/dexs.md) |
| `key` | string | API key, to lift the [rate limit](https://docs.intear.tech/dex-aggregator/reference/errors.md#rate-limits). A wrong key gets `401 Unauthorized`. For `/route/subscribe`, put it in the WebSocket URL: in a message's `query` it's ignored |
| `signing_public_key` | public key | The key the trader signs with, like `ed25519:...`. With `trader_account_id`, each quote carries [`signing`](https://docs.intear.tech/dex-aggregator/reference/quote.md#signing): the key's nonce and a recent block hash, so the transactions can be signed without asking an RPC first. An invalid key fails the request with `400` |

## Response

`200 OK` with `Content-Type: application/json`, an array of [quote objects](https://docs.intear.tech/dex-aggregator/reference/quote.md):

```json
[
  {
    "estimated_amount": { "amount_out": "4880007" },
    "worst_case_amount": { "amount_out": "4831206" },
    "dex_id": "RheaDcl",
    "execution_instructions": [
      {
        "NearTransaction": {
          "receiver_id": "usdt.tether-token.near",
          "actions": [
            {
              "FunctionCall": {
                "method_name": "storage_deposit",
                "args": "eyJyZWdpc3RyYXRpb25fb25seSI6dHJ1ZX0=",
                "gas": 10000000000000,
                "deposit": "1250000000000000000000"
              }
            }
          ],
          "is_fee_transaction": false
        }
      },
      {
        "NearTransaction": {
          "receiver_id": "wrap.near",
          "actions": [
            {
              "FunctionCall": {
                "method_name": "near_deposit",
                "args": "e30=",
                "gas": 5000000000000,
                "deposit": "1000000000000000000000000"
              }
            },
            {
              "FunctionCall": {
                "method_name": "ft_transfer_call",
                "args": "eyJyZWNlaXZlcl9pZCI6ImRjbHYyLnJlZi1sYWJzLm5lYXIiLC...",
                "gas": 106814800000000,
                "deposit": "1"
              }
            }
          ],
          "is_fee_transaction": false
        }
      }
    ],
    "needs_unwrap": false,
    "token_output": "nep141:usdt.tether-token.near",
    "estimated_max_gas_cost": "12521020071713600000000",
    "estimated_gas_usage": "8231794617168100000000",
    "storage_deposits": "1250000000000000000000",
    "fee_amount": "0"
  }
]
```

Errors are plain text, see [Errors](https://docs.intear.tech/dex-aggregator/reference/errors.md).

## How quotes are ranked

Each quote's value is its output (for `amount_in`) or minus its input (for `amount_out`), minus its `estimated_gas_usage` and `storage_deposits`, converted to the quoted token at current USD prices. Quotes are sorted by that value, highest first. Rhea, Rhea DCL and IntearDex only quote when the Intear API has a USD price for NEAR and for the quoted token (`token_out` for `amount_in`, `token_in` for `amount_out`), so buying a token that has no price yet gives no quote from them.

Routing is deterministic: the same request against the same pool state, token prices and trader account state always gives the same quotes. The trader's TEAR, for the [fee discount](https://docs.intear.tech/dex-aggregator/guides/amounts.md#fee-discounts), is the one the aggregator last read, up to a minute old.
