Skip to content

Build best path

GET /build-best-path

Quote the pair and return both the executable transaction and the winning route object in one call. The data object carries the transaction under the capital-T key "Tx" and the route under "route". Accepts the same query parameters as GET /quote.

Authentication

Send your API key in the api-key header.

Parameters

Name In Type Required Description
fromChain query integer yes Source chain id.
toChain query integer yes Destination chain id.
fromToken query string yes Input token contract address on the source chain.
toToken query string yes Output token contract address on the destination chain.
amount query string yes Input amount as a base-10 integer string in the input token's base units.
sender query string yes Address that will send the swap.
receiver query string no Recipient of the output tokens. Defaults to sender.
slippage query number no Slippage tolerance as a percentage (1.0 means 1%).
feeBps query integer no Integrator fee in basis points, taken from the input amount.
routeMode query string no Ranking mode. One of fastest, max_value, or suggested. Unknown values fall back to max_value.
Integrator query string no Integrator identifier echoed back as integratorId on the route. Note the capitalized parameter name.
acquisitionMode query integer (enum) no Token acquisition mode recorded with the quote. 0 = direct transfer, 1 = native value, 2 = Permit2, 3 = Permit2 witness.

Responses

Status Description
200 The executable transaction plus the winning route.
400 Invalid request or no route available for the pair. Plausible catalog codes behind the numeric status include VALIDATION_001 (invalid input) and VALIDATION_003 (invalid or unsupported chain id).
401 Missing or invalid API key. Plausible catalog codes behind the numeric status are AUTH_001 (unauthorized access) and AUTH_002 (invalid API key).
500 Unexpected server-side failure. Plausible catalog codes behind the numeric status include SYSTEM_002 (internal server error) and SYSTEM_001 (database operation failed).
200 response
{
  "code": 0,
  "message": "success",
  "data": {
    "Tx": {
      "allowanceTarget": "0x2B4c6E9A1d3F5b7C9E0a2C4E6a8B0d2F4A6C8E01",
      "chain": 8453,
      "data": "0x38ed1739000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000003b9aca00",
      "expiry": 1785283500,
      "gasLimit": "250000",
      "simulation": false,
      "to": "0x2B4c6E9A1d3F5b7C9E0a2C4E6a8B0d2F4A6C8E01",
      "value": "0"
    },
    "route": {
      "amount": "1000000000",
      "amountOut": "398400000000000000",
      "amountOutUsd": 998.74,
      "amountUsd": 1000.0,
      "expiry": 1785283500,
      "fees": {
        "integratorFee": "0",
        "integratorFeeUsd": 0.0,
        "routeFee": "0",
        "routeFeeUsd": 0.0
      },
      "fromToken": {
        "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "chain": 8453,
        "decimals": 6,
        "name": "USD Coin",
        "priceUsd": 1.0,
        "symbol": "USDC"
      },
      "gasFee": {
        "gasFee": "210000000000000",
        "gasFeeUsd": 0.53,
        "gasLimit": "210000",
        "gasToken": {
          "address": "0x0000000000000000000000000000000000000000",
          "chain": 8453,
          "decimals": 18,
          "name": "Ether",
          "priceUsd": 2510.4,
          "symbol": "ETH"
        },
        "gasPrice": "1000000000"
      },
      "minAmountOut": "396408000000000000",
      "minAmountOutUsd": 993.75,
      "path": [
        {
          "amount": "1000000000",
          "amountOut": "398400000000000000",
          "fromToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "provider": {
            "name": "AMM Pool",
            "type": "dex"
          },
          "toToken": "0x4200000000000000000000000000000000000006",
          "type": "swap"
        }
      ],
      "providers": [
        {
          "name": "AMM Pool",
          "type": "dex"
        }
      ],
      "quoteId": "8c6f1d0b8a9e4f2c5d3b7a1908e6c4f2d0b8a6e4c2f0d8b6a4e2c0f8d6b4a2e0",
      "receiver": "0x1a2B3c4D5e6F7a8B9c0D1e2F3a4B5c6D7e8F9a0B",
      "sender": "0x1a2B3c4D5e6F7a8B9c0D1e2F3a4B5c6D7e8F9a0B",
      "slippage": 0.5,
      "toToken": {
        "address": "0x4200000000000000000000000000000000000006",
        "chain": 8453,
        "decimals": 18,
        "name": "Wrapped Ether",
        "priceUsd": 2510.4,
        "symbol": "WETH"
      },
      "estimatedTimeMs": 4000,
      "routeKind": "sameChainSwap"
    }
  }
}
400 response
{
  "code": 400,
  "data": null,
  "message": "no route for pair"
}
401 response
{
  "code": 401,
  "data": null,
  "message": "missing api-key header"
}
500 response
{
  "code": 500,
  "data": null,
  "message": "internal server error"
}