# Get Blockchains & Tokens

## Get Full Metadata API

This service gathers all the essential data needed for a swap's UI, including list of all [blockchains](https://docs.rango.exchange/terminology#blockchain), [tokens](https://docs.rango.exchange/terminology#asset-token) and [protocols](https://docs.rango.exchange/terminology#swapper) (DEXes & Bridges) metadata.

{% tabs %}
{% tab title="Typescript (SDK)" %}

```typescript
// basic usage
const meta = await rango.getAllMetadata()
```

{% endtab %}

{% tab title="Node.js (Axios)" %}

```typescript
const response = await axios.get('https://api.rango.exchange/meta', {
  params: {
    'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
  }
});
```

{% endtab %}

{% tab title="Bash (cURL)" %}

```bash
curl --request GET \
     --url 'https://api.rango.exchange/meta?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' 
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Typescript (SDK)" %}

```typescript
// filtering blockchains, swappers and tokens
const meta = await rango.getAllMetadata({
    blockchains: ['ETH', 'POLYGON'],
    blockchainsExclude: false,
    swappers: ['Across', 'OneInchEth'],
    swappersExclude: false,
    swappersGroups: ['Across', '1Inch'],
    swappersGroupsExclude: false,
    transactionTypes: ['EVM'],
    transactionTypesExclude: false,
    excludeNonPopulars: false
})
```

{% endtab %}

{% tab title="Node.js (Axios)" %}

```typescript
const response = await axios.get('https://api.rango.exchange/meta', {
  params: {
    'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32',
    'blockchains': 'ETH,POLYGON',
    'blockchainsExclude': false,
    'swappers': 'Across,OneInchEth',
    'swappersExclude': false,
    'swapperGroups': 'Across,1Inch',
    'swappersGroupsExclude': false,
    'transactionTypes': 'EVM',
    'transactionTypesExclude': false,
    'excludeNonPopulars': false
  }
});
```

{% endtab %}

{% tab title="Bash (cURL)" %}

```bash
curl --request GET \
     --url 'https://api.rango.exchange/meta?blockchains=ETH&blockchains=POLYGON&blockchainsExclude=false&swappers=Across&swappers=OneInchEth&swappersExclude=false&swapperGroups=Across&swapperGroups=1Inch&swappersGroupsExclude=false&transactionTypes=EVM&transactionTypesExclude=false&excludeNonPopulars=false&apiKey=c6381a79-2817-4602-83bf-6a641a409e32'
```

{% endtab %}
{% endtabs %}

{% embed url="<https://rango-api.readme.io/reference/getallmeta>" %}
GET Metadata Swagger
{% endembed %}

{% hint style="info" %}
**Why is it required to obtain the list of supported tokens from Rango API?**

Even if dApp has its own list of tokens and blockchains, it's still useful to get list of supported tokens by Rango:

* To avoid extra API call when token is not supported by Rango
* Access tokens' `symbol` which is required for getting quote for each token.
  {% endhint %}

{% hint style="info" %}
**Why is it recommended to obtain the list of supported blockchains from Rango API?**

* For working with other API methods like `getBestRoute`, you need to have identifier  (name) of each blockchain. You could hard code blockchain names if you want to have limited chains support or get them dynamically via the API. (You could store a map of each blockchain `chainId` to Rango `name` if required.)&#x20;
* Because of different reasons like blockchains maintenance, Rango maintenance, hacks, and etc, a blockchain could be disabled in Rango. You could check which blockchains are enabled now using `enabled` flag for each blockchain in meta response.&#x20;
  {% endhint %}

### Metadata Request&#x20;

{% tabs %}
{% tab title="API Definition" %}

* **`blockchains`** String
  * Description: Pass comma separated list of blockchains if you want to filter meta blockchains to some specific ones.
  * Example: `POLYGON,ETH`
* **`blockchainsExclude`** Boolean
  * Description: A boolean value indicating whether the specified blockchains should be excluded or included in the response.
  * Example: `true`
* **`swappers`** String
  * Description: Pass comma separated list of swappers if you want to filter meta swappers to some specific ones.
  * Example: `Across,OneInchEth`
* **`swappersExclude`** Boolean
  * Description: A boolean value indicating whether the specified swappers should be excluded or included in the response.
  * Example: `false`
* **`swappersGroups`** String
  * Description: Pass comma separated list of swapper groups if you want to filter meta swapper groups to some specific ones.
  * Example: `Across,1Inch`
* **`swappersGroupsExclude`** Boolean
  * Description: A boolean value indicating whether the specified swapper groups should be excluded or included in the response.
  * Example: `false`
* **`transactionTypes`** String
  * Description: Pass comma separated list of transaction types if you want to filter blockchains types to some specific ones.
  * Example: `EVM,COSMOS`
* **`transactionTypesExclude`** Boolean
  * Description: A boolean value indicating whether the specified transaction types should be excluded or included in the response.
  * Example: `false`
* **`excludeSecondaries`** Boolean
  * Description: It indicates whether secondary tokens should be excluded from the response. By secondary tokens, we mean tokens that are imported from our secondary tokens lists.
  * Example: `false`
* **`excludeNonPopulars`** Boolean
  * Description: It indicates whether non-popular tokens should be excluded from the response. By popular tokens, we mean native token and stable coins of each blockchain.
  * Example: `false`
* **`ignoreSupportedSwappers`** Boolean
  * Description: Set this flag to false to exclude the supported swappers for each token from the response. The default value is true.
  * Example: `false`
* **`enableCentralizedSwappers`** Boolean
  * Description: Set this flag to true if you want to enable routing through the centralized solutions and obtain the associated metadata, including related swappers and tokens. The default value for this argument is false.
  * Example: `true`
    {% endtab %}

{% tab title="SDK Models (Typescript)" %}

```typescript
export type MetaRequest = {
  blockchains?: string[]
  blockchainsExclude?: boolean
  swappers?: string[]
  swappersExclude?: boolean
  swappersGroups?: string[]
  swappersGroupsExclude?: boolean
  transactionTypes?: TransactionType[]
  transactionTypesExclude?: boolean
  excludeSecondaries?: boolean
  excludeNonPopulars?: boolean
  ignoreSupportedSwappers?: boolean
  enableCentralizedSwappers?: boolean
}

export enum TransactionType {
  EVM = 'EVM',
  TRANSFER = 'TRANSFER',
  COSMOS = 'COSMOS',
  SOLANA = 'SOLANA',
  TRON = 'TRON',
  STARKNET = 'STARKNET',
  TON = 'TON',
}
```

{% endtab %}
{% endtabs %}

### Metadata Response&#x20;

{% tabs %}
{% tab title="API Definition" %}

* **`blockchains`**
  * Description: List of all supported [blockchains](https://docs.rango.exchange/api-integration/terminology#blockchain)
* **`tokens`**
  * Description: List of all [tokens](https://docs.rango.exchange/api-integration/terminology#asset-token)
* **`popularTokens`**
  * Description: List of all popular tokens
* **`swappers`**
  * Description: List of all supported [protocols](https://docs.rango.exchange/api-integration/terminology#swapper) (DEXes & Bridges)
    {% endtab %}

{% tab title="SDK Models (Typescript)" %}

```typescript
export type MetaResponse = {
  blockchains: BlockchainMeta[]
  tokens: Token[]
  popularTokens: Token[]
  swappers: SwapperMeta[]
}

export type BlockchainMeta =
  | EvmBlockchainMeta
  | CosmosBlockchainMeta
  | TransferBlockchainMeta
  | SolanaBlockchainMeta
  | StarkNetBlockchainMeta
  | TronBlockchainMeta
  | TonBlockchainMeta

export type Token = {
  blockchain: string
  address: string | null
  symbol: string
  name: string | null
  decimals: number
  image: string
  usdPrice: number | null
  isSecondaryCoin: boolean
  coinSource: string | null
  coinSourceUrl: string | null
  isPopular: boolean
  supportedSwappers?: string[]
}

export type SwapperMeta = {
  id: string
  title: string
  logo: string
  swapperGroup: string
  types: SwapperType[]
  enabled: boolean
}

export type SwapperType = 'BRIDGE' | 'DEX' | 'AGGREGATOR' | 'OFF_CHAIN'

export type BlockchainMetaBase = {
  type: TransactionType
  name: string
  shortName: string
  displayName: string
  defaultDecimals: number
  feeAssets: Asset[]
  addressPatterns: string[]
  logo: string
  color: string
  sort: number
  enabled: boolean
  chainId: string | null
  info:
  | EVMChainInfo
  | CosmosChainInfo
  | StarkNetChainInfo
  | TronChainInfo
  | null
}

export interface EvmBlockchainMeta extends BlockchainMetaBase {
  type: TransactionType.EVM
  chainId: string
  info: EVMChainInfo
}

export interface CosmosBlockchainMeta extends BlockchainMetaBase {
  type: TransactionType.COSMOS
  chainId: string | null
  info: CosmosChainInfo | null
}

export interface TransferBlockchainMeta extends BlockchainMetaBase {
  type: TransactionType.TRANSFER
  chainId: null
  info: null
}

export interface SolanaBlockchainMeta extends BlockchainMetaBase {
  type: TransactionType.SOLANA
  chainId: string
  info: null
}

export interface StarkNetBlockchainMeta extends BlockchainMetaBase {
  type: TransactionType.STARKNET
  chainId: string
  info: StarkNetChainInfo
}

export interface TronBlockchainMeta extends BlockchainMetaBase {
  type: TransactionType.TRON
  chainId: string
  info: TronChainInfo
}

export interface TonBlockchainMeta extends BlockchainMetaBase {
  type: TransactionType.TON
  chainId: string
  info: null
}

```

{% endtab %}

{% tab title="Sample Response" %}

```typescript
{
  "tokens": [
    {
      "blockchain": "ETH",
      "symbol": "USDT",
      "image": "https://rango.vip/i/r3Oex6",
      "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "usdPrice": 0.999631,
      "decimals": 6,
      "name": "USD Tether",
      "isPopular": true,
      "isSecondaryCoin": false,
      "coinSource": null,
      "coinSourceUrl": null,
      "supportedSwappers": [
        "ThorChain",
        "Arbitrum Bridge",
        "Hyphen"
      ]
    },
  ],
  "popularTokens": [
    {
      "blockchain": "BSC",
      "symbol": "USDT",
      "image": "https://rango.vip/i/6837hX",
      "address": "0x55d398326f99059ff775485246999027b3197955",
      "usdPrice": 0.999554,
      "decimals": 18,
      "name": "Tether USD",
      "isPopular": true,
      "isSecondaryCoin": false,
      "coinSource": null,
      "coinSourceUrl": null,
      "supportedSwappers": [
        "ThorChain"
      ]
    }
  ],
  "blockchains": [
    {
      "name": "OPTIMISM",
      "defaultDecimals": 18,
      "addressPatterns": [
        "^(0x)[0-9A-Fa-f]{40}$"
      ],
      "feeAssets": [
        {
          "blockchain": "OPTIMISM",
          "symbol": "ETH",
          "address": null
        }
      ],
      "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/OPTIMISM/icon.svg",
      "displayName": "Optimism",
      "shortName": "Optimism",
      "sort": 6,
      "color": "#FF0420",
      "enabled": true,
      "type": "EVM",
      "chainId": "0xa",
      "info": {
        "infoType": "EvmMetaInfo",
        "chainName": "Optimism",
        "nativeCurrency": {
          "name": "ETH",
          "symbol": "ETH",
          "decimals": 18
        },
        "rpcUrls": [
          "https://mainnet.optimism.io"
        ],
        "blockExplorerUrls": [
          "https://optimistic.etherscan.io"
        ],
        "addressUrl": "https://optimistic.etherscan.io/address/{wallet}",
        "transactionUrl": "https://optimistic.etherscan.io/tx/{txHash}",
        "enableGasV2": false
      }
    },
  ],
  "swappers": [
    {
      "id": "Diffusion",
      "title": "Diffusion",
      "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/Diffusion/icon.svg",
      "swapperGroup": "Diffusion",
      "types": [
        "DEX"
      ],
      "enabled": false
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Get Specific Part of Metadata

If you only want to load a specific part of metadata rather than full metadata, i.e. only blockchains data, tokens list or supported protocols, you can use the following methods/endpoints:

### Get List of Blockchains API

{% tabs %}
{% tab title="Typescript (SDK)" %}

```typescript
const meta = await rango.getBlockchains()
```

{% endtab %}

{% tab title="Node.js (Axios)" %}

```typescript
const response = await axios.get('https://api.rango.exchange/meta/blockchains', {
  params: {
    'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
  }
});
```

{% endtab %}

{% tab title="Bash (cURL)" %}

```bash
curl --request GET \
     --url 'https://api.rango.exchange/meta/blockchains?apiKey=c6381a79-2817-4602-83bf-6a641a409e32'
```

{% endtab %}
{% endtabs %}

{% embed url="<https://rango-api.readme.io/reference/getblockchains>" %}
GET Blockchains Swagger
{% endembed %}

### Get List of Swappers API

{% tabs %}
{% tab title="Typescript (SDK)" %}

```typescript
const meta = await rango.getSwappers()
```

{% endtab %}

{% tab title="Node.js (Axios)" %}

```typescript
const response = await axios.get('https://api.rango.exchange/meta/swappers', {
  params: {
    'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
  }
});
```

{% endtab %}

{% tab title="Bash (cURL)" %}

```bash
curl --request GET \
     --url 'https://api.rango.exchange/meta/swappers?apiKey=c6381a79-2817-4602-83bf-6a641a409e32'
```

{% endtab %}
{% endtabs %}

{% embed url="<https://rango-api.readme.io/reference/getswappers>" %}
GET Swappers Swagger&#x20;
{% endembed %}
