Getting all possible Connections
A connection is a pair of two tokens (on the same chain or on different chains) that can be exchanged via our platform.
The complete API documentation for our /connections
endpoint can be found here.
After gathering information about available chains and tokens, the next step could be learning which transfers from one token to another are possible. We call those transfer possibilities "connections".
To get those connections we provide a /connections
endpoint. It accepts filtering by fromChain
, toChain
, fromToken,
toToken
or chainTypes
. Please note that the alternatives for `chainTypes` are SVM (Solana virtual machine) and EVM. By default, only EVM connections will be returned.
Which combination of filters you want to use, is up to you. There is only one limitation:
Since we support many different chains with many different tokens, the connections endpoint has to be filtered to ensure the response size doesn't get too big.
For this reason, either fromChain
or toChain
has to be passed in the query.
For example, if you want to know which tokens you can receive on Gnosis by sending out USDT on Polygon (https://li.quest/v1/connections?fromChain=POL&toChain=DAI&fromToken=USDT
) you will get a response that looks the following:
It is essential to know that there can be multiple connections for the same fromChainId
and toChainId
pair. This is because we try to group the available tokens as much as possible to reduce redundancy, but not every token can be exchanged for every other token.
Scenario: Showing all possible connections based on a predefined destination token
Imagine the following scenario: You are a game that allows the players to buy custom skins using USDT on Polygon. To allow your players to swap their own assets into USDT, you integrate LI.FI.
In your user interface you now want to show your players a list of all tokens grouped by their chain that they can swap to USDT (on Polygon) in order to buy a skin:
Now you should be able to simply render this list and provide an excellent overview of the available exchange options.
If you don't feel like implementing all of that yourself and you happen to work in a JavaScript/TypeScript environment, you should look at our SDK.
However, if you want to include our beautiful widget in your application, head to our Widget Documentation.
Last updated