Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.leokit.dev/llms.txt

Use this file to discover all available pages before exploring further.

GET /leokit/quote

Get swap quotes from multiple protocols in a single request.

Request Parameters

ParameterTypeRequiredDescription
from_assetstringYesSource asset in format CHAIN.SYMBOL-ADDRESS
to_assetstringYesDestination asset in format CHAIN.SYMBOL-ADDRESS
amountstringYesAmount to swap in base units (e.g., “1000000” for 1 USDC)
destinationstringYesRecipient address for the output asset
originstringNoSource address (optional, some protocols use for validation)
affiliatestringNoAffiliate address for revenue sharing
slippage_bpsnumberNoSlippage tolerance in basis points (default: 150 = 1.5%)
streaming_intervalnumberNoStreaming swap interval for THORChain/MAYA (default: 3)
streaming_quantitynumberNoNumber of streaming swap chunks (default: 1)

Response Format

Status Code: 200 OK
{
  "quotes": [
    {
      "protocol": "thorchain",
      "data": {
        "expected_amount_out": "1985000000",
        "total_swap_seconds": 180,
        "fees": [
          {
            "type": "Affiliate Fee",
            "asset": "BTC.BTC",
            "amount": 0.00003,
            "usd": 1.2
          },
          {
            "type": "Outbound Fee",
            "asset": "ETH.ETH",
            "amount": 0.001,
            "usd": 3.5
          },
          {
            "type": "Network Fee",
            "asset": "THOR.RUNE",
            "amount": 0.02,
            "usd": 0.08
          }
        ],
        "route": [
          "BTC.BTC",
          "THOR.RUNE",
          "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
        ],
        "in_asset_decimal": "8",
        "out_asset_decimal": "6",
        "out_asset_price": "1.00000",
        "from_asset_price": "98500.00000",
        "recommended_slippage": 150
      },
      "expectedAmountOutNum": 1985.0,
      "totalFeesUsd": 4.78,
      "totalSwapSeconds": 180,
      "flags": ["OPTIMAL", "CHEAPEST"]
    },
    {
      "protocol": "chainflip",
      "data": {
        "expected_amount_out": "1983500000",
        "total_swap_seconds": 60,
        "fees": [
          {
            "type": "Deposit Fee",
            "asset": "BTC.BTC",
            "amount": 0.00001,
            "usd": 0.98
          },
          {
            "type": "Network Fee",
            "asset": "BTC.BTC",
            "amount": 0.000015,
            "usd": 1.47
          },
          {
            "type": "Broadcast Fee",
            "asset": "ETH.USDC",
            "amount": 2.5,
            "usd": 2.5
          }
        ],
        "route": ["BTC", "USDC"],
        "in_asset_decimal": "8",
        "out_asset_decimal": "6",
        "out_asset_price": "1.00000",
        "from_asset_price": "98500.00000"
      },
      "expectedAmountOutNum": 1983.5,
      "totalFeesUsd": 4.95,
      "totalSwapSeconds": 60,
      "flags": ["FASTEST"]
    }
  ],
  "timestamp": "2026-01-15T12:34:56.789Z",
  "quote_id": "01936b4a-7c8e-7890-abcd-ef1234567890"
}

Helper Fields (top-level on each quote)

The server adds these fields to every quote to simplify client-side sorting and filtering. They are computed once per response by the optimal-route ranker.
FieldTypeDescription
expectedAmountOutNumnumberdata.expected_amount_out parsed and scaled by destination decimals
totalFeesUsdnumberSum of all fees[].usd for this quote
totalSwapSecondsnumberdata.total_swap_seconds (mirrored at top level for consistent sorting)
flagsstring[]Performance tags (see below). Empty array if no flag applies

Quote Flags

Quotes are automatically tagged with performance indicators:
  • FASTEST - Lowest totalSwapSeconds
  • CHEAPEST - Lowest totalFeesUsd
  • OPTIMAL - Highest expectedAmountOutNum (tie-broken by fees, then speed)
  • BEST_OUTPUT - Highest output across all quotes (alias of OPTIMAL on the winning quote)

Fee Breakdown Examples

Each quote includes a detailed fee breakdown with the following structure:
{
  "type": "Fee Type",
  "asset": "CHAIN.SYMBOL",
  "amount": 0.001,
  "usd": 3.5
}
Common Fee Types:
  • Affiliate Fee - Revenue sharing with integrators
  • Outbound Fee - Blockchain network fee for sending output
  • Network Fee - Protocol or router fee
  • Deposit Fee - Fee for depositing into protocol
  • Broadcast Fee - Fee for broadcasting transaction to destination chain

Error Responses

Missing Required Parameters (400)
{
  "error": "Missing required params: from_asset, to_asset, amount",
  "status": 400
}
No Quotes Available (404)
{
  "error": "No quotes available from any protocol",
  "status": 404
}
Internal Server Error (500)
{
  "error": "Internal server error",
  "details": "Error message",
  "status": 500
}

GET /leokit/streaming-quotes

Stream quotes as Server-Sent Events (SSE) for real-time updates as protocols respond.

Request Parameters

Same as /leokit/quote endpoint.

Response Format

Content-Type: text/event-stream Event Stream:
data: {"type":"init","quote_id":"01936b4a-7c8e-7890-abcd-ef1234567890","timestamp":"2026-01-15T12:34:56.789Z","total":6}

data: {"type":"quote","protocol":"chainflip","data":{"expected_amount_out":"1983500000",...}}

data: {"type":"quote","protocol":"thorchain","data":{"expected_amount_out":"1985000000",...}}

data: {"type":"quote","protocol":"relay","data":{"expected_amount_out":"1980000000",...}}

data: {"type":"final","quotes":[...],"timestamp":"2026-01-15T12:34:58.123Z","quote_id":"01936b4a-7c8e-7890-abcd-ef1234567890"}

data: {"type":"finished"}

Event Types

TypeDescription
initInitial event with quote_id and total expected protocols
quoteIndividual quote as it resolves from each protocol
finalAggregated final result with all quotes and flags
finishedStream completion signal
errorError occurred (e.g., no quotes available)

Stream Characteristics

  • Safety Timeout: 7 seconds maximum
  • Connection: Keep-alive with heartbeat
  • Cache-Control: no-cache
  • Client Disconnect: Gracefully handled, quote still logged to database

Error Event

data: {"type":"error","data":"No quotes available from any protocol"}