Skip to main content
The LI.FI SDK provides functionality to request routes and quotes, as well as to execute them. This guide will walk you through the process of making a request using getRoutes and getQuote functions.

How to request Routes

To get started, here is a simple example of how to request routes to bridge and swap 10 USDC on Arbitrum to the maximum amount of DAI on Optimism.
When you request routes, you receive an array of route objects containing the essential information to determine which route to take for a swap or bridging transfer. At this stage, transaction data is not included and must be requested separately. Read more Execute Routes/Quotes. Additionally, if you would like to receive just one best option that our smart routing API can offer, it might be better to request a quote using getQuote.

Routes request parameters

The getRoutes function expects a RoutesRequest object, which specifies a desired any-to-any transfer and includes all the information needed to calculate the most efficient routes.

Parameters

Below are the parameters for the RoutesRequest interface along with their descriptions:

Route Options

The RouteOptions interface allows for further customization of the route request. Below are the parameters for the RouteOptions interface along with their descriptions:

Allow/Deny/Prefer

The AllowDenyPrefer interface is used to specify preferences for bridges or exchanges. Using the allow option, you can allow tools, and only those tools will be used to find the best routes. Tools specified in deny will be blocklisted. You can find all available keys in List: Chains, Bridges, DEX Aggregators, Solvers or get the available option from the API. See Chains and Tools. Below are the parameters for the AllowDenyPrefer interface:

Timing

The Timing interface allows you to specify preferences for the timing of route execution. This can help optimize the performance of your requests based on timing strategies. Parameters for the Timing interface:

Timing Strategy

This can help optimize the timing of requests based on specific conditions.
You can implement custom timing strategies to improve the user experience and optimize the performance of your application by controlling the timing of route execution.

Request a Quote

When you request a quote, our smart routing API provides the best available option. The quote includes all necessary information and transaction data required to initiate a swap or bridging transfer. You can request a quote by specifying either fromAmount (the amount to send) or toAmount (the desired amount to receive). Use fromAmount when the user knows how much they want to spend, and toAmount when they know how much they want to receive. Here is a simple example of how to request a quote to bridge and swap 10 USDC on Arbitrum to the maximum amount of DAI on Optimism.

Quote request parameters

The getQuote function expects a QuoteRequest object. You must provide either fromAmount or toAmount, but not both. Below are the parameters for the QuoteRequest interface.

Other Quote parameters

In addition to the parameters mentioned above, all parameters listed in the Route Options section are also available when using getQuote, except for allowSwitchChain, which is used exclusively to control chain switching in route requests. Also, parameters to specify options for allowing, denying, or preferring certain bridges, exchanges, and protocols have slightly different names:
  • allowBridges (string[], optional)
  • denyBridges (string[], optional)
  • preferBridges (string[], optional)
  • allowExchanges (string[], optional)
  • denyExchanges (string[], optional)
  • preferExchanges (string[], optional)
  • allowProtocols (string[], optional)
  • denyProtocols (string[], optional)
Additionally, you can specify timing strategies for the swap steps using the swapStepTimingStrategies parameter:
  • swapStepTimingStrategies (string[], optional) Specifies the timing strategy for swap steps. This parameter allows you to define how long the request should wait for results and manage expected outcomes. The format is:

Request contract call Quote

Besides requesting general quotes, the LI.FI SDK also provides functionality to request quotes for destination contract calls. Read more in the Composer documentation. For SDK-specific Composer integration, see SDK Composer Integration Guide. Here is a simple example of how to request a quote to bridge and purchase an NFT on the OpenSea marketplace costing 0.0000085 ETH on the Base chain using ETH from Optimism. The call data for this example was obtained using the OpenSea Seaport SDK.

Contract call Quote request parameters

The getContractCallsQuote function expects a ContractCallsQuoteRequest object, which includes all the information needed to request a quote for a destination contract call. Contract call quote request can be treated as an extension to the quote request and in addition to the parameters mentioned below, all parameters listed in the Other Quote parameters section (such as integrator, fee, slippage, etc.) are also available when using getContractCallsQuote. Array of contract call objects.

Difference between Route and Quote

Even though Route and Quote terms lie in the same field of providing you with the best option to make a swap or bridging transfer, there are some differences you need to be aware of. A Route in LI.FI represents a detailed transfer plan that may include multiple steps. Each step corresponds to an individual transaction, such as swapping tokens or bridging funds between chains. These steps must be executed in a specific sequence, as each one depends on the output of the previous step. A Route provides a detailed pathway for complex transfers involving multiple actions. In contrast, a Quote is a single-step transaction. It contains all the necessary information to perform a transfer in one go, without requiring any additional steps. Quotes are used for simpler transactions where a single action, such as a token swap or a cross-chain transfer, is sufficient. Thus, while Routes can involve multiple steps to complete a transfer, a Quote always represents just one step.