# Current Token Rate Interface

## Return current rate of target token

<mark style="color:green;">`POST`</mark> `https://admin.ccpayment.com/ccpayment/v1/token/rate`

Return the real-time price of the target token and its equivalent value in passed amount in USD

#### Headers

| Name                                           | Type   | Description                                                                                                                                                                                                                   |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Appid<mark style="color:red;">\*</mark>        | string | Merchant's unique credential. Find it on the [Developer page](https://admin.ccpayment.com/developer/config).                                                                                                                  |
| Timestamp<mark style="color:red;">\*</mark>    | string | Timestamp in seconds (10-digit). The request is valid for two minutes.                                                                                                                                                        |
| Sign<mark style="color:red;">\*</mark>         | string | SHA-256 (APPID + APP Secret +timestamp+<mark style="color:red;">**body (json string)**</mark>). [Signature guide](https://doc.ccpayment.com/~/changes/HSMg9pcC4k6HIczMjOvx/ccpayment-for-developer/to-get-started/signature). |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json; charset=utf-8                                                                                                                                                                                               |

#### Request Body

| Name                                        | Type   | Description                                                                                                                                                                                     |
| ------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| amount<mark style="color:red;">\*</mark>    | string | Amount in USD                                                                                                                                                                                   |
| token\_id<mark style="color:red;">\*</mark> | string | Token ID for the target token. Get token id by [calling interface](/ccpayment-v1.0-api/resources-document/token-id-interface.md) or checking it [on the sheet](https://bit.ly/CCsupportedcoins) |

{% tabs %}
{% tab title="200: OK Success (200)/Fail (201)" %}
{% tabs %}
{% tab title="Success (200)" %}

#### Response

#### Header

#### Body

```json
{
	"code": 10000,
	"msg": "success",
	"data": {
		"price": "16944.3",
		"value": "0.0590168965374787"
	}
}
```

#### Parameters

{% endtab %}

{% tab title="Fail (201)" %}

```json
{
    "code": 224066,
    "msg": "service err, please try again"
}
```

{% endtab %}

{% tab title="Remarks" %}
As a security measure, we will sign the returned data (and according to this only { code: 10000 } should be signed, but it's signing all the returned body.). Additionally, it will return Appid, Sign, Timestamp  in the header of the response.  The signature method SHA-256 (appid+appSecret+Timestamp+body).

Please use the data with caution if the signature verification fails. It indicates that the data has been tampered with.
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="93">Name</th><th width="99">Value</th><th width="105" data-type="checkbox">Required</th><th width="90">Type</th><th>Description</th></tr></thead><tbody><tr><td>code</td><td>10000</td><td>true</td><td>Integer</td><td></td></tr><tr><td>msg</td><td>Success</td><td>true</td><td>String</td><td>Status description</td></tr><tr><td>data</td><td></td><td>true</td><td>Object</td><td>Return data</td></tr><tr><td>data.price</td><td>16944.3</td><td>true</td><td>String</td><td>Current rate of the target token</td></tr><tr><td>data.value</td><td>0.0590168965374787</td><td>true</td><td>String</td><td>Target token's equivalent value in passed amount in USD</td></tr></tbody></table>

<table><thead><tr><th width="134">Name</th><th width="188">Value</th><th width="104" align="center">Required</th><th width="82">Type</th><th width="299">Description</th></tr></thead><tbody><tr><td>Appid</td><td>202302010636261620672405236006912</td><td align="center">Y</td><td>string</td><td>Merchant's unique credential. Find it on the Developer page.</td></tr><tr><td>Timestamp</td><td>1677152490</td><td align="center">Y</td><td>string</td><td>Timestamp in seconds (10-digit). The request is valid for two minutes.</td></tr><tr><td>Sign</td><td>871f0223c66ea72435208d03603a0cb00b90f6ac4a4ba725d00164d967e291f6</td><td align="center">Y</td><td>string</td><td>SHA-256 (appId + appSecret + timestamp+<mark style="color:red;"><strong>body (json string)</strong></mark>)</td></tr></tbody></table>

### Request Body Example

{% tabs %}
{% tab title="Body" %}

```json
{
	"amount": "1000",
	"token_id": "f36ad1cf-222a-4933-9ad0-86df8069f916",
}
```

{% endtab %}

{% tab title="Remarks" %}
The body of HTTP is a json string .

Add the content in body of HTTP to the signature. Ensure the body content matches the signature content. As soon as CCPayment receives the request, the body content will be read and the signature will be verified.
{% 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://docs.ccpayment.com/ccpayment-v1.0-api/resources-document/current-token-rate-interface.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.
