# Token

### **Data API field**

**The Data API on Token Form is required as investment capacity of the token is expected, while rewards consists of object of rate and reward token, in case reward is not available then pass empty object.**

![](/files/4EbA8aJYQruyd94cK7QD)

<mark style="color:blue;">`GET`</mark> `https://api.myapi.com/get-rewards-details-by-token-address/:token-address`

Gets investment capacity and rewards from the token address

#### Request Body

| Name                                                   | Type      | Description                             |
| ------------------------------------------------------ | --------- | --------------------------------------- |
| rewards<mark style="color:red;">\*</mark>              | Object    | Object containing rate and reward token |
| investment\_capacity<mark style="color:red;">\*</mark> | float/int | Investment Capacity for the token       |
| rate                                                   | Float     | APY rate of reward token                |
| reward\_token                                          | String    | Reward token name                       |

{% tabs %}
{% tab title="200: OK Token successfully created" %}
Example

{% code overflow="wrap" %}

```javascript
{
    "investment_capacity": 100000,
    "reward": [
        {
            "reward_rate": 0.2,
            "reward_token": "stable fiat/WSP"
        }
    ]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### &#x20;**Blocksscan Api's  rendered from token address provided in the Token Form.**

{% hint style="danger" %}
&#x20;Please check that API are rendering data properly, else validation error is thrown.
{% endhint %}

## To fetch the token symbol, price and total supply&#x20;

<mark style="color:blue;">`GET`</mark> `https://xdc.blocksscan.io/api/tokens/token_address`

You can check your api data from blockscsan <https://xdc.blocksscan.io/docs/#/Tokens/get_api_tokens__hash_>

#### Request Body

| Name                                                | Type   | Description                   |
| --------------------------------------------------- | ------ | ----------------------------- |
| symbol<mark style="color:red;">\*</mark>            | float  | The token symbol              |
| totalSupplyNumber<mark style="color:red;">\*</mark> | String | The total supply of the token |
| priceUSD<mark style="color:red;">\*</mark>          | float  | The price of token in USD     |

{% tabs %}
{% tab title="200: OK Token successfully created" %}

{% endtab %}

{% tab title="400: Bad Request Token Validations Failed. Recheck the API fields' types" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

### CoinGeko ID feild

**Provide the string id of the token available on coinGecko. This API is to fetch the price history of the token from the range of token launched till upto date.  The API is called on platform, hence user is only expected to provide valid CoinGecko  ID. Please check below if the API are rendering data properly.**

![](/files/vEs4x6mVk1YfeEuhXa8I)

<mark style="color:blue;">`GET`</mark> `https://api.coingecko.com/api/v3/coins/${coingecko_id}/market_chart/range?vs_currency=usd&from=${startDate}&to=${today}`

<https://www.coingecko.com/en/api/documentation>

#### Headers

| Name                                           | Type   | Description                                                                   |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark>           | String | token id aailable on Coingecko                                                |
| from<mark style="color:red;">\*</mark>         | String | From date in UNIX timestamp                                                   |
| to<mark style="color:red;">\*</mark>           | String | to date in UNIX timestamp                                                     |
| vs\_currency<mark style="color:red;">\*</mark> | String | The target currency of the market data. In Tradefinex it is always set to USD |

### **Price API field**

**When Token Form is submitted, blocksscan api is called using the provided token address and stored in database. Incase, price is not fetched from Blocksscan, user is required to submit a separate API, as shown below in Price API field in request Token form.**

![](/files/0RoJtmwL3vUlrgBu8M18)

<mark style="color:blue;">`GET`</mark> `https://api.myapi.com/get-token-details-by-token-address/:token-address`

Gets price from the token address

**All parameters are required, send 0 incase if it is Not Applicable**

#### Request Body

| Name                                       | Type      | Description            |
| ------------------------------------------ | --------- | ---------------------- |
| priceUSD<mark style="color:red;">\*</mark> | float/int | The token price in USD |

{% tabs %}
{% tab title="200 Token successfully created" %}
{% code overflow="wrap" %}

```json
{
    "priceUSD":150000
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found Token Validations Failed. Recheck the API fields' types" %}

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yodaplus.gitbook.io/tradefinex-api/tradefinex/token.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
