How to request available chains, tokens and token pairs

Request all supported chains and tokens

The full API reference for our /config endpoint can be found in the API reference section.

We are continuously expanding our ecosystem by incorporating new blockchain networks and tokens to allow for a greater number of cross-chain token transfers and swaps.

To get a list of all chains and all tokens that are currently supported, the /config endpoint can be queried.

If you have a project-specific configuration applied through the Swing Platform, make sure to send you projectId with the request to get all supported chains and tokens for your project.

const getConfig = async () => {
    const result = await axios.get(
        'https://swap.prod.swing.xyz/v0/transfer/config'.
     );
    return {
        chains: result.data.chains,
        tokens: result.data.tokens
        bridges: result.data.bridges
    };
};

The result contains a list of chains that look like the following:

{
  "name": "Ethereum",
  "slug": "ethereum",
  "chainId": 1,
  "protocolType": "evm",
  "isSingleChainSupported": false,
  "nativeCurrency": "ETH",
  "logo: https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/eth.jpg",
  "blockExploreUrls": [
    "https://etherscan.io/"
  ],
  "rpcUrls": [
    "https://eth-mainnet.alchemyapi.io/v2/hrkUnlgn_VD_KbxEjpo7D2mVwTfAVUJW"
  ],
  "tokens": [],
  "allowSwapFromChains": [
    "fantom",
    "bsc",
    "polygon",
    "avalanche",
    "arbitrum",
    "optimism"
  ],
  "allowSwapToChains": [
    "fantom",
    "bsc",
    "polygon",
    "avalanche",
    "arbitrum",
    "optimism"
  ]
}

The result contains a list of tokens that look like the following:

{
  "symbol": "USDC",
  "name": "USD Coin",
  "logoURI": "https://raw.githubusercontent.com/sushiswap/list/master/logos/token-logos/token/usdc.jpg"
}

(Advanced) Request available token pairs for project-specific configurations

This step is only important if you have project-specific rules applied through the Swing Platform. This would ensure your users can get routes and start transfers only for allowed token pairs based on your project’s configurations.

Set up your project in Swing Platform to configure your integration and access transaction data.

Given a projectId, directionPriority, chain and token you can get all available token pairs for this token..

This is useful for the user experience, and making sure that only allowed route options are presented to the user. For example: your configuration only allows users to swap ETH on Etherium to MATIC on Polygon and the other way arround. Given ETH on Etherium is selected as a sending token, what tokens can we recieve? If you query /config/token_pairs endpoint with parameter directionPriority: from, you will get MATIC on Polygon as the only possible pair.

To get a list of available token pairs for a specific sending token - query /config/tokenpairs endpoint with parameter _directionPriority: from.

To get a list of available token pairs for a specific receiving token - query /config/tokenpairs endpoint with parameter _directionPriority: to

The full API reference for our /config/token_pairs endpoint can be found in the API reference section.