Skip to main content

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

ParameterTypeRequiredDescription
tokenInstringYesInput token address
tokenOutstringYesOutput token address
amountInstringConditionalInput amount in raw units (required when tradeType=0)
amountOutstringConditionalOutput amount in raw units (required when tradeType=1)
tradeTypestringNo0 = 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
}
FieldDescription
amountInInput amount (user-specified for Exact Input, calculated for Exact Output)
amountOutOutput amount (calculated for Exact Input, user-specified for Exact Output)
route.pathOrdered list of token addresses in the swap path
route.protocol"v2", "v3", or "mixed"
route.hopsNumber of pools in the path
route.feesFee tier for each hop (0 for V2, 100/500/3000/10000 for V3)
priceImpactEstimated price impact as a percentage
gasCostEstimated gas cost
executionPriceOutput 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.