# getRecommendedTokens

## Description

The `getRecommendedTokens` function retrieves an array of recommended tokens for a specified blockchain by making an HTTP GET request to a server.&#x20;

If the server returns a successful response, the function returns the `recommendedTokens` array from the response data.&#x20;

In case of an unsuccessful response, the function returns an object with a `code` property set to 0 and a `msg` property set to the error message from the response data.

## Parameters

| Name         | Type   | Description                                                         |
| ------------ | ------ | ------------------------------------------------------------------- |
| `blockchain` | string | The name of the blockchain for which to retrieve recommended tokens |

## Response

| Name                | Type  | Description                                                 |
| ------------------- | ----- | ----------------------------------------------------------- |
| `recommendedTokens` | array | An array of recommended tokens for the specified blockchain |

## Example Request and Response

### Prerequisites

Before making requests with NO.AI SDK, you must have it installed.

You can install NO.AI SDK using either **`npm`** or **`yarn`**. Use the following commands to install NO.AI SDK:

```jsx
npm install @nest25/xy-finance-lib
OR
yarn add @nest25/xy-finance-lib
```

### Request

Here is an example of how to make a `getRecommendedTokens` request using the NO.AI SDK:

```javascript
// import Nest SDK library
const { xySwap } = require('@nest25/xy-finance-lib');

// create xySwap instance
const swap = new xySwap();

async function main() {
  // get recommended tokens
  const result = await swap.getRecommendedTokens('klaytn');
  console.log(result);
}
// run main function
main();

```

### Response

```jsx
 [
      {
        address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
        symbol: 'KLAY',
        name: 'KLAY',
        chainId: '8217',
        decimals: 18,
        logoURI: 'https://assets.coingecko.com/coins/images/9672/small/klaytn.jpeg?1642775250'
      },
      {
        address: '0xCF87f94fD8F6B6f0b479771F10dF672f99eADa63',
        symbol: 'CLA',
        name: 'CLA',
        chainId: '8217',
        decimals: 18,
        logoURI: 'https://assets.coingecko.com/coins/images/24677/small/9pbkueWn_400x400.jpg?1648558565'
      },
      {
        address: '0x5c74070FDeA071359b86082bd9f9b3dEaafbe32b',
        symbol: 'KDAI',
        name: 'KDAI',
        chainId: '8217',
        decimals: 18,
        logoURI: 'https://assets.coingecko.com/coins/images/9956/small/4943.png?1636636734'
      }
    ]
```

## Use Cases

* **Token trading:** The `getRecommendedTokens` function can be used by decentralized exchanges to retrieve a list of recommended tokens for a specific blockchain network. This enables users to easily trade a variety of tokens on the decentralized exchange.
* **Token staking:** Some blockchain networks allow users to stake their tokens to earn rewards. The `getRecommendedTokens` function can be used to retrieve a list of recommended tokens for staking on a specific blockchain network.
* **Wallet integration:** Wallet applications can use the `getRecommendedTokens` function to suggest new tokens to their users for addition to their wallet. This enhances the user experience by providing easy access to popular tokens.
