li-fi-api

REST API for cross-chain and same-chain token swaps, bridging, and DeFi operations. USE THIS SKILL WHEN USER WANTS TO: - Swap tokens between different blockchains (e.g., "swap USDC on Ethereum to ETH on Arbitrum") - Bridge tokens to another chain (e.g., "move my ETH from mainnet to Optimism") - Swap tokens on the same chain with best rates (e.g., "swap ETH to USDC on Polygon") - Find the best route or quote for a token swap across chains - Execute DeFi operations across chains (zap, bridge+swap+deposit, yield farming entry) - Build multi-chain payment flows (accept any token, settle in specific token) - Check supported chains, tokens, or bridges for cross-chain transfers - Track status of a cross-chain transaction - Build backend services (Python, Go, Rust, etc.) that need cross-chain swaps - Integrate cross-chain functionality via HTTP/REST (not JavaScript SDK)

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "li-fi-api" with this command: npx skills add lifinance/lifi-agent-skills/lifinance-lifi-agent-skills-li-fi-api

LI.FI REST API Integration

The LI.FI REST API provides direct HTTP access to cross-chain swap and bridge functionality. Use this API when building backend services, working with non-JavaScript languages, or needing fine-grained control over cross-chain operations.

Base URL

https://li.quest/v1

Authentication

API key is optional but recommended for higher rate limits.

# Without API key (lower rate limits)
curl "https://li.quest/v1/chains"

# With API key (higher rate limits)
curl "https://li.quest/v1/chains" \
  -H "x-lifi-api-key: YOUR_API_KEY"

Important: Never expose your API key in client-side code. Use it only in server-side applications.

Rate Limits

TierLimit
Without API keyPer IP address
With API keyPer API key

Request an API key from LI.FI for production use with higher limits.

Quick Start

1. Get a Quote

curl "https://li.quest/v1/quote?\
fromChain=42161&\
toChain=10&\
fromToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&\
toToken=0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1&\
fromAmount=10000000&\
fromAddress=0xYourAddress&\
slippage=0.005"

2. Execute the Transaction

Use the transactionRequest from the quote response to send the transaction via your wallet or web3 library.

3. Track Status

curl "https://li.quest/v1/status?\
txHash=0xYourTxHash&\
fromChain=42161&\
toChain=10&\
bridge=stargate"

Core Endpoints

GET /quote

Get a single-step quote with transaction data ready for execution.

Parameters:

ParameterTypeRequiredDescription
fromChainnumberYesSource chain ID
toChainnumberYesDestination chain ID
fromTokenstringYesSource token address
toTokenstringYesDestination token address
fromAmountstringYesAmount in smallest unit
fromAddressstringYesSender wallet address
toAddressstringNoRecipient address
slippagenumberNoSlippage tolerance (0.005 = 0.5%)
integratorstringNoYour integrator ID
allowBridgesstring[]NoAllowed bridges (or all, none, default)
denyBridgesstring[]NoDenied bridges
preferBridgesstring[]NoPreferred bridges
allowExchangesstring[]NoAllowed exchanges (or all, none, default)
denyExchangesstring[]NoDenied exchanges
preferExchangesstring[]NoPreferred exchanges
allowDestinationCallbooleanNoAllow contract calls on destination (default: true)
orderstringNoRoute preference: FASTEST or CHEAPEST
feenumberNoIntegrator fee (0.02 = 2%, max <100%)
referrerstringNoReferrer tracking information
fromAmountForGasstringNoAmount to convert to gas on destination
maxPriceImpactnumberNoMax price impact threshold (0.1 = 10%, default: 10%)
skipSimulationbooleanNoSkip TX simulation for faster response
swapStepTimingStrategiesstring[]NoTiming strategy for swap rates
routeTimingStrategiesstring[]NoTiming strategy for route selection

Example Request:

curl "https://li.quest/v1/quote?\
fromChain=1&\
toChain=137&\
fromToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&\
toToken=0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174&\
fromAmount=1000000000&\
fromAddress=0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0&\
slippage=0.005"

The response includes transactionRequest with all data needed to execute the swap. See references/REFERENCE.md for complete response schema.

POST /advanced/routes

Get multiple route options for comparison. Returns routes without transaction data (use /advanced/stepTransaction to get TX data for a specific step).

Request Body:

{
  "fromChainId": 42161,
  "toChainId": 10,
  "fromTokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
  "toTokenAddress": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
  "fromAmount": "10000000",
  "fromAddress": "0xYourAddress",
  "options": {
    "integrator": "YourAppName",
    "slippage": 0.005,
    "order": "CHEAPEST",
    "bridges": {
      "allow": ["stargate", "hop", "across"]
    },
    "exchanges": {
      "allow": ["1inch", "uniswap"]
    },
    "allowSwitchChain": true,
    "maxPriceImpact": 0.1
  }
}

Example Request:

curl -X POST "https://li.quest/v1/advanced/routes" \
  -H "Content-Type: application/json" \
  -d '{
    "fromChainId": 42161,
    "toChainId": 10,
    "fromTokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
    "toTokenAddress": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
    "fromAmount": "10000000",
    "options": {
      "slippage": 0.005,
      "integrator": "YourApp"
    }
  }'

Returns array of routes sorted by order preference. Each route contains steps but no transactionRequest - use /advanced/stepTransaction to get TX data.

POST /advanced/stepTransaction

Populate a step (from /advanced/routes) with transaction data. Use this after selecting a route to get the actual transaction to execute.

Request Body: Send the full Step object from a route.

Query Parameters:

ParameterTypeRequiredDescription
skipSimulationbooleanNoSkip TX simulation for faster response

Example:

curl -X POST "https://li.quest/v1/advanced/stepTransaction" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "step-id",
    "type": "cross",
    "tool": "stargate",
    "action": {...},
    "estimate": {...}
  }'

Response: Returns the Step object with transactionRequest populated.

GET /status

Track transaction status across chains. Can query by sending TX hash, receiving TX hash, or transactionId.

Parameters:

ParameterTypeRequiredDescription
txHashstringYesTransaction hash (sending, receiving, or transactionId)
fromChainnumberNoSource chain ID (speeds up request)
toChainnumberNoDestination chain ID
bridgestringNoBridge tool name

For same-chain swaps, set fromChain and toChain to the same value.

Example Request:

curl "https://li.quest/v1/status?txHash=0x123abc..."

Response includes: transactionId, sending (txHash, amount, chainId), receiving (txHash, amount, chainId), status, substatus, lifiExplorerLink.

Status Values: NOT_FOUND, INVALID, PENDING, DONE, FAILED

Poll until status is DONE or FAILED. See references/REFERENCE.md for complete substatus values.

GET /chains

Get all supported chains.

Parameters:

ParameterTypeRequiredDescription
chainTypesstringNoFilter by chain types: EVM, SVM
curl "https://li.quest/v1/chains"
curl "https://li.quest/v1/chains?chainTypes=EVM,SVM"

GET /tokens

Get tokens for specified chains.

Parameters:

ParameterTypeRequiredDescription
chainsstringNoComma-separated chain IDs or keys (e.g., POL,DAI)
chainTypesstringNoFilter by chain types: EVM, SVM
minPriceUSDnumberNoMin token price filter (default: 0.0001 USD)
curl "https://li.quest/v1/tokens?chains=1,137,42161"

GET /token

Get information about a specific token.

Parameters:

ParameterTypeRequiredDescription
chainstringYesChain ID or key (e.g., POL or 137)
tokenstringYesToken address or symbol (e.g., DAI)
curl "https://li.quest/v1/token?chain=POL&token=DAI"

GET /tools

Get available bridges and exchanges. Use this to discover valid tool keys for filtering quotes.

Parameters:

ParameterTypeRequiredDescription
chainsstringNoFilter by chain IDs
curl "https://li.quest/v1/tools"
curl "https://li.quest/v1/tools?chains=1,137"

Returns bridges and exchanges arrays with key, name, and supportedChains. Use these keys in allowBridges, denyBridges, allowExchanges, etc.

Special values: all, none, default, []

GET /connections

Get available token pair connections. At least one filter (chain, token, bridge, or exchange) is required.

Parameters:

ParameterTypeRequiredDescription
fromChainstringNoSource chain ID or key
toChainstringNoDestination chain ID or key
fromTokenstringNoSource token address or symbol
toTokenstringNoDestination token address or symbol
chainTypesstringNoFilter by chain types: EVM,SVM
allowBridgesstring[]NoAllowed bridges
denyBridgesstring[]NoDenied bridges
preferBridgesstring[]NoPreferred bridges
allowExchangesstring[]NoAllowed exchanges
denyExchangesstring[]NoDenied exchanges
preferExchangesstring[]NoPreferred exchanges
allowSwitchChainbooleanNoInclude routes requiring chain switch (default: true)
allowDestinationCallbooleanNoInclude routes with destination calls (default: true)
curl "https://li.quest/v1/connections?\
fromChain=POL&\
fromToken=DAI"

POST /quote/contractCalls

Get a quote for bridging tokens and performing multiple contract calls on the destination chain. This enables 1-click DeFi workflows like bridge + swap + deposit.

Request Body:

{
  "fromChain": 10,
  "fromToken": "0x4200000000000000000000000000000000000042",
  "fromAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0",
  "toChain": 1,
  "toToken": "ETH",
  "toAmount": "100000000000001",
  "integrator": "YourAppName",
  "contractCalls": [
    {
      "fromAmount": "100000000000001",
      "fromTokenAddress": "0x0000000000000000000000000000000000000000",
      "toTokenAddress": "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
      "toContractAddress": "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
      "toContractCallData": "0x",
      "toContractGasLimit": "110000"
    },
    {
      "fromAmount": "100000000000000",
      "fromTokenAddress": "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
      "toTokenAddress": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",
      "toContractAddress": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",
      "toFallbackAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0",
      "toContractCallData": "0xea598cb000000000000000000000000000000000000000000000000000005af3107a4000",
      "toContractGasLimit": "100000"
    }
  ]
}

Integration Examples

Python

import requests

BASE_URL = "https://li.quest/v1"

def get_quote(from_chain, to_chain, from_token, to_token, amount, address):
    response = requests.get(f"{BASE_URL}/quote", params={
        "fromChain": from_chain,
        "toChain": to_chain,
        "fromToken": from_token,
        "toToken": to_token,
        "fromAmount": amount,
        "fromAddress": address,
        "slippage": 0.005
    })
    return response.json()

def get_status(tx_hash, from_chain, to_chain, bridge):
    response = requests.get(f"{BASE_URL}/status", params={
        "txHash": tx_hash,
        "fromChain": from_chain,
        "toChain": to_chain,
        "bridge": bridge
    })
    return response.json()

# Example usage
quote = get_quote(
    from_chain=42161,
    to_chain=10,
    from_token="0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
    to_token="0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
    amount="10000000",
    address="0xYourAddress"
)

print(f"Estimated output: {quote['estimate']['toAmount']}")
print(f"Gas cost: {quote['estimate']['gasCosts']}")

Node.js (fetch)

const BASE_URL = 'https://li.quest/v1';

async function getQuote(params) {
  const searchParams = new URLSearchParams(params);
  const response = await fetch(`${BASE_URL}/quote?${searchParams}`);
  return response.json();
}

async function getRoutes(body) {
  const response = await fetch(`${BASE_URL}/routes`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });
  return response.json();
}

async function pollStatus(txHash, fromChain, toChain, bridge) {
  const params = new URLSearchParams({ txHash, fromChain, toChain, bridge });
  
  while (true) {
    const response = await fetch(`${BASE_URL}/status?${params}`);
    const data = await response.json();
    
    if (data.status === 'DONE' || data.status === 'FAILED') {
      return data;
    }
    
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
}

// Example usage
const quote = await getQuote({
  fromChain: 42161,
  toChain: 10,
  fromToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
  toToken: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
  fromAmount: '10000000',
  fromAddress: '0xYourAddress',
  slippage: 0.005,
});

Error Handling

HTTP StatusDescription
200Success
400Bad request - check parameters
429Rate limit exceeded - wait or use API key
500Internal error - retry

See references/REFERENCE.md for complete error codes and response schemas.

Best Practices

  1. Always specify slippage - Default is conservative. Adjust based on token volatility.

  2. Poll status endpoint - For cross-chain transfers, poll every 5-10 seconds until DONE or FAILED.

  3. Handle rate limits - Implement exponential backoff for 429 responses.

  4. Cache chain/token data - /chains and /tokens responses change infrequently.

  5. Use integrator parameter - Always include integrator for analytics and potential monetization.

  6. Validate addresses - Ensure token addresses match the specified chain.

  7. Handle gas estimation - The API provides gas estimates, but actual costs may vary.

See references/REFERENCE.md for complete endpoint documentation and response schemas.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

li-fi-sdk

No summary provided by upstream source.

Repository SourceNeeds Review
Web3

china-sportswear-outdoor-sourcing

Comprehensive sportswear and outdoor equipment sourcing guide for international buyers – provides detailed information about China's athletic apparel, footwear, outdoor gear, and accessories manufacturing clusters, supply chain structure, regional specializations, and industry trends (2026 updated).

Archived SourceRecently Updated
Web3

china-lighting-sourcing

Comprehensive lighting industry sourcing guide for international buyers – provides detailed information about China's LED, smart, outdoor, automotive, and specialty lighting manufacturing clusters, supply chain structure, regional specializations, and industry trends (2026 updated).

Archived SourceRecently Updated
Web3

china-furniture-sourcing

Comprehensive furniture industry sourcing guide for international buyers – provides detailed information about China's residential, office, hotel, outdoor, and custom furniture manufacturing clusters, supply chain structure, regional specializations, and industry trends (2026 updated).

Archived SourceRecently Updated