Calculate approximate rate for operations with exchange [Private]
Find out the approximate exchange rate for a future operation.
Method name: | /v2/rate/calculate |
Request type: | POST |
To call private endpoints, you need to get a JWT token or an API key for authentication.
Here you can learn in detail how to successfully authenticate.
Data dictionary
Name | Type | Parameter type | Required | Range | Description |
---|---|---|---|---|---|
sourceAsset | string | BODY | YES | - | Source or base Asset code. |
targetAsset | string | BODY | YES | - | Target or quote Asset code. |
sourceAmount | int | BODY | NO | - | Amount for sourceAsset. |
targetAmount | int | BODY | NO | - | Amount for targetAsset. |
operationType | string | BODY | YES | DepositWithExchange, WithdrawWithExchange, CryptoExchange, BuyToSendCrypto | The type of operation for which you are requesting a pre-request. |
depositPaymentCode | string | BODY | NO | - | Deposit payment code (only for DepostWithExchange and BuyToSendCrypto operations). You can get it via a pre-request. |
withdrawPaymentCode | string | BODY | NO | - | Withdrawal payment code (only for WithdrawWithExchange and BuyToSendCrypto operations). You can get it via a pre-request. |
withInternalFiat | boolean | BODY | NO | true, false | Show if operation processing with merchant fiat funds (only for DepositWithExchange, WithdrawWithExchange, BuyToSendCrypto). |
Exemplary request
const url = BASE_URL;
const path = "/v2/rate/calculate";
const body = {
operationType: "DepositWithExchange",
withInternalFiat: false,
sourceAsset: "EUR",
targetAsset: "USDT",
sourceAmount: "50",
depositPaymentCode: "payment_card_eur_hpp_europe"
};
const options = {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${data.accessToken}` // data.accessToken - generated a JWT token via /v2/auth/login.
},
body: JSON.stringify(body),
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
import requests
url = BASE_URL
path = "/v2/rate/calculate"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + data.accessToken # data.accessToken - generated a JWT token via /v2/auth/login.
}
body = {
"operationType": "DepositWithExchange",
"withInternalFiat": False,
"sourceAsset": "EUR",
"targetAsset": "USDT",
"sourceAmount": "50",
"depositPaymentCode": "payment_card_eur_hpp_europe"
}
request = requests.post(url + path, headers=headers, json=body)
print(request.json())
How to call private endpoints here
Response
{
"data": {
"feeDeposit": "0.5", // Deposit fee.
"feeDepositAsset": "EUR", // Asset of the deposit fee.
"feeTrade": "0", // Trade fee.
"feeTradeAsset": "USDT", // Asset of the rade fee.
"feeWithdraw": "0", // Withdrawal fee.
"feeWithdrawAsset": "USDT", // Asset of the withdrawal fee.
"rate": "0.899986", // Exchange rate.
"sourceAmount": "50", // Amount spent.
"sourceAsset": "EUR", // Asset of the amount spent.
"targetAmount": "44.549307", // Amount received.
"targetAsset": "USDT", // Asset of the amount received.
"totalFeeSourceAsset": "0.5", // Total fees of the base (Source) asset.
"totalFeeTargetAsset": "0.449993" // Total fees of the quote (Target) asset.
}
}
Updated 6 months ago