Integrate LI.FI Composer via the REST API with same-chain deposits, cross-chain flows, and error handling.
Prefer to author multi-step flows explicitly? See the Composer API, which documents the explicit Flow authoring API.
This guide walks you through integrating Composer directly via the LI.FI REST API. This approach gives you full control over the request/response flow and is ideal for backend services, custom frontends, or any environment where you want to manage transactions yourself.
Already using the LI.FI SDK or Widget? Composer works automatically. See the SDK guide or Widget guide instead.
The LI.FI API is open and requires no API key. You can start making requests immediately.
integrator (optional query parameter): A string that identifies your application in analytics and on-chain events. Defaults to "lifi-api" when omitted. Must be alphanumeric with hyphens, underscores, or dots, max 23 characters.
x-lifi-api-key (optional header): An API key is generated automatically when you create an integration in the LI.FI partner portal. Attach it for higher rate limits. Without a key, unauthenticated limits apply: 75 requests per two hours for /quote and /advanced/routes, 50 requests per two hours for /advanced/stepTransaction, and 100 requests per minute for other endpoints. With an API key, the default is 100 requests per minute across all endpoints.
Composer does not require a dedicated endpoint. Set toToken to a supported protocol token address and LI.FI returns a Composer route from the standard endpoints.The integration flow:
Request a quote via GET /v1/quote or POST /v1/advanced/routes
Set token allowance by approving the LI.FI Diamond contract to spend your tokens
Send the transaction using the transactionRequest from the quote response
Track status by polling GET /v1/status for cross-chain transfers
The simplest way to get a Composer transaction. Returns a single best route with transaction data included.
curl -X GET 'https://li.quest/v1/quote?fromChain=8453&toChain=8453&fromToken=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&toToken=0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A&fromAddress=0xYOUR_WALLET_ADDRESS&toAddress=0xYOUR_WALLET_ADDRESS&fromAmount=1000000'
The slippage parameter is a decimal value representing the maximum acceptable price difference. For example, 0.005 means 0.5%. If omitted, the API defaults to 0.005. Cross-chain routes involve more steps, so consider 0.01 (1%) or higher for cross-chain flows.
When using /advanced/routes, transaction data is not included in the response. You must call POST /v1/advanced/stepTransaction to get the transactionRequest for each step. With /quote, transaction data is included directly.
"composer" for same-chain Composer routes. For cross-chain routes, this is the bridge name (e.g., "stargateV2"). Check includedSteps for tool: "composer" to confirm Composer is in the route.
action.fromToken / action.toToken
Token objects with address, symbol, decimals, and chainId.
action.slippage
The slippage tolerance applied to this quote.
estimate.toAmount
Estimated output in the toToken’s smallest unit.
estimate.toAmountMin
Minimum output accounting for slippage.
estimate.approvalAddress
The contract address to approve for token spending (see below).
estimate.executionDuration
Estimated execution time in seconds.
transactionRequest
Ready-to-sign EVM transaction. Fields (value, gasLimit, gasPrice) are hex-encoded strings.
estimate.feeCosts
Array of fee entries. Every Composer route includes a feeCollection step that takes a small percentage fee. Check this array to surface fee details to users.
includedSteps
Ordered list of steps the route will execute. Typically includes a feeCollection step followed by the composer step.
Hex-encoded values: The transactionRequest fields value, gasLimit, and gasPrice are hex strings (e.g., "0x5f45bc"). The chainId field is a plain number. When building transactions manually (e.g., in Python), parse hex fields with int(value, 16).
The estimate.approvalAddress and transactionRequest.to both point to the LI.FI Diamond contract, a verified, audited smart contract deployed on all supported chains.
The Composer onchain VM (which executes the compiled bytecode) is a separate contract called internally by the Diamond. For audit reports and contract verification, see Security and Audits.
Quotes reflect current market conditions and may become stale. If the user reviews a quote for more than 30 seconds, re-fetch before signing to get up-to-date pricing and simulation results.
Morpho vaults are named after their curator, not after Morpho itself. For example, the address 0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A returns symbol: "sparkUSDC" because it is a Spark-curated Morpho vault. This is expected: Morpho provides the vault infrastructure, and curators like Spark create strategies on top.
Before executing, the LI.FI Diamond contract needs approval to spend your tokens. The approval address is returned in the quote response at estimate.approvalAddress.
Skip this step if fromToken is a native token (e.g., ETH). Native tokens don’t require approval.
If an approval transaction was sent, re-fetch the quote before executing. The transactionRequest contains gas estimates that can become stale by the time the approval confirms. Call GET /v1/quote again with the same parameters and use the fresh transactionRequest.
For same-chain Composer transactions, the operation is complete once the transaction is confirmed.For cross-chain Composer flows, poll the /status endpoint until the transfer completes: