If you want to calculate the exchange rate between the requested FIAT and Cryptocurrency and display it to your end-users, this page shows you how to do that.
Here's the Approximate quote API request and response that we are going to use to calculate the exchange rate for the sake of demonstration. In this example, the end-user wants to buy 200 USD worth of USDT, all fees are included in the requested amount of 200 USD:
curl --location 'https://app-api.sandbox.coinify.com/partners/24d17a54-81e6-464b-aba8-30935fc0fd3f/approximate-quote?transferInMedium=card&transferOutMedium=blockchain"eCurrency=USDT&baseAmount=-200&baseCurrency=USD' \
--header 'Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MzEzMjk0OTIsImV4cCI6MTczMTMzMDY5MiwidWlkIjo1ODYxNywiZXYiOnRydWUsInNjIjp7InRfMTM0NTAiOiIqIn19.mMGg9mdzSqwayb6rPhNNgp36HmEvesASkgtMxSOfgt6CX5-RwuCk_TEl4p5SMGPmiVrNhmmTcjHMugoAEdFQQw' \
--data ''
{
"baseAmount": -200, //the amount specified by the end-user. This amount gets converted to the requested cryptocurrency
"baseCurrency": "USD",
"quoteAmount": 198.79355345,//the amount end-user will receive after the transferOut.feeAmount has been deducted
"quoteCurrency": "USDT",
"transferIn": {
"medium": "card",
"feeAmount": 24.49,
"currency": "USD"
},
"transferOut": {
"medium": "blockchain",
"feeAmount": 1.02860483, //network transaction fees
"currency": "USDT"
}
}
Exchange Rate Calculation (FIAT to Crypto)
Exchange Rate (USD to USDT) = baseAmount
/ (quoteAmount
+ transferOut.feeAmount
) = 200 / (198.79355345
+ 1.02860483
) = 200
/ 199.81
= 1.00095 USD/USDT