Quote API
Get the best available swap quote for a token pair. The API finds the optimal route across V2 and V3 pools, including multi-hop paths.
GET /api/v1/quote
Parameters
| Parameter | Type | Required | Description |
|---|
tokenIn | string | Yes | Input token address |
tokenOut | string | Yes | Output token address |
amountIn | string | Conditional | Input amount in raw units (required when tradeType=0) |
amountOut | string | Conditional | Output amount in raw units (required when tradeType=1) |
tradeType | string | No | 0 = Exact Input (default), 1 = Exact Output |
For native KAS, use the WKAS address, not the zero address.
Response
{
"tokenIn": "0xb190...",
"tokenOut": "0x3ac3...",
"amountIn": "1000000000000000000",
"amountOut": "1007249042881810956",
"tradeType": 0,
"route": {
"path": ["0xb190...", "0x3ac3..."],
"protocol": "v2",
"hops": 1,
"fees": [0]
},
"priceImpact": 0.3,
"gasCost": "100000",
"executionPrice": 1.007249
}
| Field | Description |
|---|
amountIn | Input amount (user-specified for Exact Input, calculated for Exact Output) |
amountOut | Output amount (calculated for Exact Input, user-specified for Exact Output) |
route.path | Ordered list of token addresses in the swap path |
route.protocol | "v2", "v3", or "mixed" |
route.hops | Number of pools in the path |
route.fees | Fee tier for each hop (0 for V2, 100/500/3000/10000 for V3) |
priceImpact | Estimated price impact as a percentage |
gasCost | Estimated gas cost |
executionPrice | Output per input ratio |
Examples
# I want to sell 1 token — how much do I get?
curl "https://dex.kasplex.org/swap-api/api/v1/quote?\
tokenIn=0xB190a6A7fC2873f1Abf145279eD664348d5Ef630&\
tokenOut=0x3Ac3B30b7f18AEFD4590D7FE4d9C5944aaeB7220&\
amountIn=1000000000000000000&\
tradeType=0"
Multi-Hop Routes
When no direct pool exists or a multi-hop path provides better pricing, the API returns a multi-hop route:
{
"route": {
"path": ["0xb190...", "0x0baf...", "0x3ac3..."],
"protocol": "mixed",
"hops": 2,
"fees": [0, 500]
}
}
This means: token A → (V2 pool) → intermediate token → (V3 0.05% pool) → token B.