# 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.meta()
```

{% endtab %}

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

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

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

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

```typescript
// sample for filtering response
const meta = await rango.meta({
    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)" %}

```javascript
const response = await axios.get('https://api.rango.exchange/basic/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/basic/meta?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 %}
{% endtabs %}

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

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

* For working with other API methods like `quote` or `swap`, 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, DeFi protocols 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 %}

{% hint style="info" %}
**When 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 unnecessary API calls when a token is not supported by Rango: For EVM and Solana blockchains, Rango supports custom tokens, so it's fine to pass tokens outside the list of Rango token list. However, for the other blockchains, we currently only support tokens that are on our existing token list (meta response).
* For Cosmos-based blockchains, the token's symbol is required to retrieve a quote for each token. Thi will be addressed in a future update.
  {% 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.&#x20;
  * Example: `POLYGON,ETH`
* **`blockchainsExclude`** Boolean
  * Description: A boolean[^1] 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.&#x20;
  * 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`
* **`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/terminology#blockchain)
* **`tokens`**
  * List of all [tokens](https://docs.rango.exchange/terminology#asset-token)
* **`swappers`**
  * List of all supported [protocols](https://docs.rango.exchange/terminology#swapper) (DEXes & Bridges)
    {% endtab %}

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

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

export type BlockchainMeta =
  | EvmBlockchainMeta
  | CosmosBlockchainMeta
  | TransferBlockchainMeta
  | SolanaBlockchainMeta
  | StarkNetBlockchainMeta
  | TronBlockchainMeta
  | TonBlockchainMeta
  
export type SwapperMeta = {
  id: string
  title: string
  logo: string
  swapperGroup: string
  types: SwapperType[]
  enabled: boolean
}  

export type Token = {
  blockchain: string
  chainId: string | null
  address: string | null
  symbol: string
  name: string | null
  decimals: number
  image: string
  blockchainImage: string
  usdPrice: number | null
  isPopular: boolean
  supportedSwappers: string[]
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
  "tokens": [
    {
      "blockchain": "ETH",
      "symbol": "USDT",
      "name": "USDT",
      "isPopular": true,
      "chainId": "1",
      "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "decimals": 6,
      "image": "https://rango.vip/i/r3Oex6",
      "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/ETH/icon.svg",
      "usdPrice": 1.001,
      "supportedSwappers": [
        "ThorChain",
        "Arbitrum Bridge",
        "Hyphen"
      ]
    }
  ],
  "blockchains": [
    {
      "name": "ETH",
      "defaultDecimals": 18,
      "addressPatterns": [
        "^(0x)[0-9A-Fa-f]{40}$"
      ],
      "feeAssets": [
        {
          "blockchain": "ETH",
          "symbol": "ETH",
          "address": null
        }
      ],
      "type": "EVM",
      "chainId": "0x1",
      "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/ETH/icon.svg",
      "displayName": "Ethereum",
      "shortName": "ETH",
      "sort": 0,
      "color": "#ecf0f1",
      "enabled": true,
      "info": {
        "infoType": "EvmMetaInfo",
        "chainName": "Ethereum Mainnet",
        "nativeCurrency": {
          "name": "ETH",
          "symbol": "ETH",
          "decimals": 18
        },
        "rpcUrls": [
          "https://rpc.ankr.com/eth"
        ],
        "blockExplorerUrls": [
          "https://etherscan.io"
        ],
        "addressUrl": "https://etherscan.io/address/{wallet}",
        "transactionUrl": "https://etherscan.io/tx/{txHash}",
        "enableGasV2": true
      }
    }
  ],
  "swappers": [
    {
      "id": "MDexHeco",
      "title": "MDex",
      "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/MDex/icon.svg",
      "swapperGroup": "MDex",
      "types": [
        "DEX"
      ],
      "enabled": true
    }
  ]
}
```

{% 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 chains = await rango.chains()
```

{% endtab %}

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

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

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

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

### Get List of Swappers API

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

```typescript
const swappers = await rango.swappers()
```

{% endtab %}

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

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

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

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

### Get List of Cross-Chain Messaging Protocols API

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

```typescript
const protocols = await rango.messagingProtocols()
```

{% endtab %}

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

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

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

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

[^1]:
