Skip to main content

Making Your First API Call

Ready to get started? Here’s a simple example of fetching swap quotes:
curl -X GET "https://api.leokit.io/leokit/quote?from_asset=BTC.BTC&to_asset=ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&amount=100000000&destination=0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb" \
  -H "Api-Key: your_api_key_here"
This request will return quotes from all available protocols for swapping 1 BTC to USDC on Ethereum.

Common API Endpoints

Here’s a quick reference of the most commonly used endpoints:
EndpointMethodPurpose
/leokit/quoteGETGet swap quotes from all protocols
/leokit/streaming-quotesGET (SSE)Stream quotes in real-time
/leokit/depositPOSTGenerate unsigned transaction
/leokit/save-transactionPOSTSave broadcasted transaction hash
/leokit/statusPOSTGet swap transaction status
/leokit/assetsGETList supported tokens with prices
/leokit/balancesPOSTGet multi-chain wallet balances

Common Parameters

These parameters are used across multiple endpoints:
ParameterUsed InTypeDescription
from_assetQuotestringSource asset identifier
to_assetQuotestringDestination asset identifier
amountQuotestringAmount in base units
destinationQuotestringRecipient address
originQuotestringSource address (optional)
quote_idDeposit, Status, Save TXstringUUID from quote
selected_protocolDepositstringProtocol to use
tx_hashSave TXstringTransaction hash

Response Time Expectations

Understanding typical response times helps you build better user experiences:
OperationTypical TimeMaximum Time
Quote (HTTP)2-4 seconds10 seconds
Quote (Streaming)3-6 seconds7 seconds (timeout)
Deposit Generation1-3 seconds10 seconds
Status Check (cached)<100ms1 second
Status Check (API)1-2 seconds5 seconds
Assets List<100ms1 second (cached)
Balances2-5 seconds15 seconds

Best Practices

Follow these best practices to build robust integrations:
  1. Always validate quote_id before requesting deposit generation
  2. Poll status endpoint every 10-30 seconds, not more frequently
  3. Cache assets list for at least 20 seconds to reduce API calls
  4. Use streaming quotes for better UX with real-time updates
  5. Handle partial quote failures gracefully - some protocols may fail while others succeed
  6. Implement exponential backoff for failed requests
  7. Save transaction hashes immediately after broadcast
  8. Monitor trace IDs for debugging production issues
  9. Set reasonable slippage (1.5-3% for most swaps)
  10. Validate addresses before submitting to quote endpoint

Protocol Support by Ecosystem

Different protocols support different blockchain ecosystems:
ProtocolEVMUTXOCosmosNEAROther
THORChain✅ (XRP, TRON)
MAYAChain
Chainflip
Relay
NEAR
Rango✅ (All)

Error Code Categories

Understanding error codes helps with debugging:
  • 400-level: Client errors (validation, parameters, quotes)
  • 403: Authentication failures
  • 404: Resources not found (quotes, traces)
  • 500-level: Server errors (internal, external API failures)

Next Steps

Now that you understand the basics, explore the detailed endpoint documentation to learn about:
  • Fetching and comparing swap quotes
  • Generating unsigned transactions
  • Tracking swap status
  • Managing multi-chain assets and balances