# Errors

> DEX Aggregator errors: the HTTP status and message of an invalid /route request, what causes each one, and the rate limits.

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.

An invalid request returns `400 Bad Request`, and a request over the [rate limit](#rate-limits) `429 Too Many Requests`. Both come with a plain text (`text/plain`) message, not JSON. Show the text to developers, not end users: it's meant for debugging.

"No route found" is not an error: it's `200 OK` with an empty array.

[`/route/outcome`](https://docs.intear.tech/dex-aggregator/reference/outcome.md#errors) has messages of its own.

## Messages

| Message | Cause |
| --- | --- |
| ``Failed to deserialize query string: missing field `token_in` `` | A required parameter is missing, probably DEX Aggregator's fault |
| `Failed to deserialize query string: no variant of enum Amount found in flattened data` | Neither `amount_in` nor `amount_out` is given |
| `Failed to deserialize query string: ...` | A parameter has the wrong format, for example an invalid token ID or account ID |
| `Failed to deserialize query string: dexes: Empty dex id` | Empty ID in `dexes`, like `dexes=` or `dexes=Rhea,` |
| `Failed to deserialize query string: fees: Invalid referral fees: ...` | `fees` isn't a JSON object of account IDs to numbers |
| `Failed to deserialize query string: fees: Referral fee of alice.near must be between 0 and 0.05` | A fee is negative or over 5% |
| `Failed to deserialize query string: fees: Referral fee of alice.near must be a whole number of millionths` | A fee has more than 6 decimal places |
| `Failed to deserialize query string: fees: At most 4 accounts can be paid` | More than 4 accounts in `fees` |
| `Failed to deserialize query string: fees: Referral fees must add up to at most 0.05` | The fees add up to more than 5% |
| `Amount must be greater than 0` | `amount_in` or `amount_out` is `0` |
| `Token in and token out must be different` | `token_in` equals `token_out` |
| `Slippage must be between 0.00 and 1.00` | `Fixed` slippage out of range |
| `Min slippage must be between 0.00 and 1.00` | `Auto` `min_slippage` out of range |
| `Max slippage must be between 0.00 and 1.00` | `Auto` `max_slippage` out of range |
| `Max slippage must be greater than min slippage` | `max_slippage` < `min_slippage` |
| `Invalid dex id: Foo` | Unknown ID in `dexes`. IDs are case-sensitive. IDs of [removed DEXs](https://docs.intear.tech/dex-aggregator/reference/dexs.md) are accepted and give no quotes |

Over the [WebSocket](https://docs.intear.tech/dex-aggregator/reference/subscribe.md), the same messages come as `{ "id": ..., "error": "..." }`, except that parsing errors lose the `Failed to deserialize query string: ` and `<parameter>: ` prefixes: `Failed to deserialize query string: dexes: Empty dex id` comes as `Empty dex id`.

## Rate limits

Requests without an API key in [`key`](https://docs.intear.tech/dex-aggregator/reference/route.md#optional) are rate limited per IP address (per /64 for IPv6). Over the limit, `GET /route` and `GET /route/outcome` return `429 Too Many Requests` with a `Retry-After` header in seconds and the text `Rate limit exceeded, retry in <n>s or use an API key`.

On the WebSocket, the connection request counts, and so does every message with a `query`. Over the limit, the connection fails, or the message gets `{ "id": ..., "error": "Rate limit exceeded, retry in <n>s or use an API key" }`.

A wrong `key` gets `401 Unauthorized` with `Invalid API key`, and on the WebSocket the connection fails.
