Skip to main content
This page provides deterministic decision logic for AI agents to choose the right approach for different scenarios.

Quote vs Routes

Use this table to decide between /quote and /advanced/routes endpoints.
ScenarioUseEndpointReason
Simple A→B transferQuoteGET /quoteSingle call, tx data included
Need multiple route optionsRoutesPOST /advanced/routesReturns ranked alternatives
User wants to choose bridgeRoutesPOST /advanced/routesCan filter by tool preference
Complex multi-hop transferRoutesPOST /advanced/routesBetter for >2 step routes
Fastest integrationQuoteGET /quoteFewer API calls needed
Price comparison neededRoutesPOST /advanced/routesCompare fee structures

Decision Logic

IF (simple_transfer AND no_user_preference AND speed_priority)
  → Use /quote

ELSE IF (need_options OR user_wants_choice OR complex_route)
  → Use /advanced/routes

Key Differences

Aspect/quote/advanced/routes
ResponseSingle best routeMultiple route options
Transaction dataIncludedRequires separate /advanced/stepTransaction call
API calls needed12+ (routes + stepTransaction per step)
ControlLessMore
SpeedFasterSlightly slower

API vs SDK vs Widget

Use this table to recommend the right integration method.
Agent TypeRecommendedReason
Server-side automationAPINo runtime dependencies, pure HTTP
AI agent (no UI)APISimplest integration, HTTP only
Browser-based appSDKHandles wallet connections, signing
Mobile appSDKWallet integration built-in
Need embedded UIWidgetZero UI code required
Quick prototypeWidgetFastest to implement
Full customizationSDKComplete control over UX
Backend serviceAPINo browser dependencies

Decision Logic

IF (server_side OR ai_agent OR no_ui_needed)
  → Recommend API

ELSE IF (need_wallet_integration OR custom_ui)
  → Recommend SDK

ELSE IF (need_ready_made_ui OR fastest_implementation)
  → Recommend Widget

Comparison Matrix

FeatureAPISDKWidget
DependenciesNone (HTTP)npm packagenpm package
Wallet handlingManualBuilt-inBuilt-in
UI componentsNoneNoneFull UI
CustomizationFullFullFull (theme + route params)
Learning curveLowMediumLow
Best forAgents, backendsCustom appsQuick integrations

Route Selection Criteria

When multiple routes are available, use these criteria to select the best one.

Sort Order Options

The API supports these order parameter values:
OrderDescriptionBest For
FASTESTLowest estimated execution timeTime-sensitive transfers
CHEAPESTLowest total fees (default)Cost-sensitive users
If no order parameter is provided, the API returns the best route based on output amount after fees.

Request with Order

curl "https://li.quest/v1/quote?fromChain=1&toChain=42161&fromToken=USDC&toToken=USDC&fromAmount=10000000&fromAddress=0x...&order=FASTEST"

Route Filtering

Filter routes by specific criteria:
ParameterValuesPurpose
bridgesstargate,across,hopOnly use specific bridges
exchanges1inch,paraswapOnly use specific DEXs
denyBridgesmultichainExclude specific bridges
denyExchangesdodoExclude specific DEXs
allowSwitchChaintrue/falseAllow multi-step routes
maxPriceImpact0.05Max allowed price impact

Example: Filtered Quote

curl "https://li.quest/v1/quote?fromChain=1&toChain=42161&fromToken=USDC&toToken=USDC&fromAmount=10000000&fromAddress=0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0&bridges=stargate,across&maxPriceImpact=0.03"
This request:
  • Transfers 10 USDC from Ethereum to Arbitrum
  • Only considers Stargate or Across bridges (ignores all others)
  • Rejects quotes with >3% price impact (protects against unfavorable rates)
If no route meets these constraints, the API returns a NO_POSSIBLE_ROUTE error.

Same-Chain vs Cross-Chain

Determine whether a transfer is same-chain or cross-chain.
ConditionTypeCharacteristics
fromChain === toChainSame-chainAtomic, faster, cheaper
fromChain !== toChainCross-chainUses bridge, takes longer

Behavior Differences

AspectSame-ChainCross-Chain
ExecutionAtomic (all or nothing)May partially complete
TimeSecondsMinutes to hours
Failure modeReverts entirelyFunds always arrive (possibly different token)
Status checkUsually instantRequires polling
Tools usedDEX onlyBridge + optional DEX
LI.FI is non-custodial. In cross-chain transfers, funds always end up with the user. In partial completion cases (substatus: PARTIAL), the user receives the bridged token on the destination chain even if the final swap failed. Funds are rarely ever stuck/lost.

Amount Handling

Convert between human-readable amounts and API amounts.

Formula

api_amount = human_amount × (10 ^ decimals)
human_amount = api_amount / (10 ^ decimals)

Common Token Decimals

TokenDecimals1 Token in API
USDC61000000
USDT61000000
DAI181000000000000000000
ETH181000000000000000000
WBTC8100000000

Example Conversions

// Human to API (10 USDC)
const apiAmount = "10000000"; // 10 * 10^6

// Human to API (1.5 ETH)
const apiAmount = "1500000000000000000"; // 1.5 * 10^18

// API to Human
const humanAmount = Number(apiAmount) / Math.pow(10, decimals);

Error Recovery Decisions

When errors occur, use this table to determine the action.
ErrorRetry?Action
429 (Rate Limited)YesWait with exponential backoff
400 (Bad Request)NoFix parameters
No route foundMaybeTry different tokens or smaller amount
Insufficient balanceNoUser needs more funds
Slippage exceededMaybeIncrease slippage parameter
Quote expiredYesRequest new quote
Network errorYesRetry with backoff

Retry Strategy

const withRetry = async (fn, maxRetries = 3) => {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (error.status === 429) {
        // Rate limited - wait and retry
        await sleep(Math.pow(2, i) * 1000);
        continue;
      }
      if (error.status >= 400 && error.status < 500) {
        // Client error - don't retry
        throw error;
      }
      // Server error - retry
      await sleep(1000);
    }
  }
  throw new Error('Max retries exceeded');
};

Quick Decision Flowchart

Start

  ├─► Is this a simple A→B transfer?
  │     │
  │     ├─► Yes ──► Use /quote
  │     │
  │     └─► No ──► Use /advanced/routes

  ├─► Is the agent server-side?
  │     │
  │     ├─► Yes ──► Use API directly
  │     │
  │     └─► No ──► Consider SDK or Widget

  ├─► Is fromChain === toChain?
  │     │
  │     ├─► Yes ──► Same-chain swap (atomic)
  │     │
  │     └─► No ──► Cross-chain (poll status)

  └─► Did the request fail?

        ├─► 429 ──► Retry with backoff
        ├─► 4xx ──► Fix parameters
        └─► 5xx ──► Retry once