# Get Custom Conversion Rate History

This endpoint retrieves the custom crypto-to-FX rate configured by the merchant

**Endpoint**

<mark style="color:green;">**`GET`**</mark>`https://api.tylt.money/transactions/merchant/getRateHistory?fromCurrencySymbol={fromCurrencySymbol}&toCurrencySymbol={toCurrencySymbol}&transactionType={transactionType}`

**Endpoint  Example**

<mark style="color:green;">**`GET`**</mark>`https://api.tylt.money/transactions/merchant/getRateHistory?fromCurrencySymbol=INR&toCurrencySymbol=USDT&transactionType=payin`

**Request Headers**

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

<table data-full-width="true"><thead><tr><th width="133">Name</th><th width="79">Type</th><th width="167">Example</th><th>Description</th></tr></thead><tbody><tr><td>X-TLP-APIKEY</td><td>string</td><td>93ee3c5e133697251b5362bcf9cc8532476785t8768075616f58d88</td><td>Your Tylt API Key, used to identify your account in API requests.</td></tr><tr><td>X-TLP-SIGNATURE</td><td>string</td><td>d0afef3853dfc8489c8b9affa5825171fdd7y7685675e4966a05f66ed2b3eaf9462b3c9c0</td><td>HMAC SHA-256 signature generated using the API Secret Key to secure the request.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
When using the API, ensure to include your API Key and generate the signature for the request payload using your API Secret. The tables provided above contain example values for illustration purposes only. Please refer to the code snippets for detailed instructions on how to sign the request and generate the signature properly.
{% endhint %}

**Code Snippet**

{% tabs %}
{% tab title="Node JS" %}

```javascript
import axios from "axios";
import crypto from "crypto";

const apiKey = "your-api-key";
const apiSecret = "your-api-secret";

const data = {
    fromCurrencySymbol: "INR", // optional
    toCurrencySymbol: "USDT", // optional
    transactionType: "payin" // optional. Accepted values: "payin" , "payout"
};

/*
    If you pass both, it gives 10 most recent rates with fromCurrencySymbol and toCurrencySymbol
    If you pass one, it gives 10 most recent rates with that fromCurrencySymbol or toCurrencySymbol, whichever one is passed
    If you pass none, it gives 10 most recent rates irrespective of currencySymbol
    If you pass either the fromCurrencySymbol or the toCurrencySymbol, remember -
    
    fromCurrencySymbol can only be of currenctType 'fiat'
    toCurrencySymbol can only be of currenctType 'crypto'

    currencyType of a currency can be checked here - 
    https://docs.tylt.money/tylt-cpg-crypto-payment-gateway/api-reference/supporting-apis/supported-base-currency-list

    For your reference - 
    fromCurrencySymbol can be 'INR' and other fiat currencies
    toCurrencySymbol can be 'USDT' and other crypto currencies
*/

const queryString = new URLSearchParams(data).toString();
const signaturePayload = JSON.stringify(data);
const signature = crypto
    .createHmac("sha256", apiSecret)
    .update(signaturePayload)
    .digest("hex");

const url = `https://api.tylt.money/transactions/merchant/getRateHistory?${queryString}`;

const config = {
    method: "get",
    url: url,
    headers: {
        "X-TLP-APIKEY": apiKey,
        "X-TLP-SIGNATURE": signature,
    },
};

axios
    .request(config)
    .then((response) => {
        console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
        console.error(error);
    });

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import hmac
import hashlib
import json

# Replace with your API Key and Secret
api_key = 'your-api-key'
api_secret = 'your-api-secret'

# Query Parameters
params = {
    "fromCurrencySymbol": "INR",  # optional
    "toCurrencySymbol": "USDT",   # optional
    "transactionType": "payin" # optional. Accepted values: "payin" , "payout"
}

# Create query string for URL
query_params = '&'.join([f"{key}={value}" for key, value in params.items()])

# Use compact JSON string for signing
body_string = json.dumps(params, separators=(',', ':'), ensure_ascii=False)

# Generate HMAC SHA-256 signature
signature = hmac.new(api_secret.encode(), body_string.encode(), hashlib.sha256).hexdigest()

# Set headers
headers = {
    "X-TLP-APIKEY": api_key,
    "X-TLP-SIGNATURE": signature
}

# Send GET request
response = requests.get(
    f"https://api.tylt.money/transactions/merchant/getRateHistory?{query_params}",
    headers=headers
)

# Print response
if response.status_code == 200:
    print("Response:", json.dumps(response.json(), indent=2))
else:
    print(f"Failed with status code {response.status_code}: {response.text}")

```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const fetch = require('node-fetch');
const crypto = require('crypto');

// Replace with your API Key and Secret
const apiKey = 'your-api-key';
const apiSecret = 'your-api-secret';

// Query Parameters
const params = {
  fromCurrencySymbol: 'INR',  // optional
  toCurrencySymbol: 'USDT'    // optional
  transactionType: "payin" // optional. Accepted values: "payin" , "payout"
};

const queryParams = new URLSearchParams(params).toString();

// Create the HMAC SHA-256 signature
const signature = crypto
  .createHmac('sha256', apiSecret)
  .update(JSON.stringify(params))  // compact JSON body
  .digest('hex');

// Define headers
const headers = {
  "X-TLP-APIKEY": apiKey,
  "X-TLP-SIGNATURE": signature
};

// Send the GET request
fetch(`https://api.tylt.money/transactions/merchant/getRateHistory?${queryParams}`, { headers })
  .then(response => {
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return response.json();
  })
  .then(data => console.log("Response:", data))
  .catch(error => console.error("Error:", error));

```

{% endtab %}
{% endtabs %}

**Response**

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

```json
{
  "data": [
    {
      "fromCurrencySymbol": "INR",
      "toCurrencySymbol": "USDT",
      "rate": "90.000000000000000000000000000000",
      "createdAt": "2025-08-04T12:18:07Z",
      "isReciprocal": 0
      "transactionType": "payin" 
    }
  ],
  "errorCode": 0,
  "msg": "Rate history fetched successfully"
}
```

{% 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.tylt.money/tylt-cpg-crypto-asset-gateway/api-reference/accept-crypto-assets/get-custom-conversion-rate-history.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.
