Skip to content

GET /route

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

Returns an array of quotes, one per DEX that found a route, best first. If no DEX found a route, the array is empty.

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
Parameter Type Description
token_in token ID Token to swap from
token_out token ID 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
slippage_type Fixed | Auto See Slippage
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
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 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
referrer_id account ID Your account, for 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
key string API key, to lift the rate limit. 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: 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

200 OK with Content-Type: application/json, an array of quote objects:

[
{
"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.

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, is the one the aggregator last read, up to a minute old.