Calculate the Exchange rate

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&quoteCurrency=USDT&sendAmount=-200&sendCurrency=USD' \
--header 'Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MzEzMjk0OTIsImV4cCI6MTczMTMzMDY5MiwidWlkIjo1ODYxNywiZXYiOnRydWUsInNjIjp7InRfMTM0NTAiOiIqIn19.mMGg9mdzSqwayb6rPhNNgp36HmEvesASkgtMxSOfgt6CX5-RwuCk_TEl4p5SMGPmiVrNhmmTcjHMugoAEdFQQw' \
--data ''
{
    "baseAmount": -177.28,//sendAmount - transferIn.feeAmount
    "baseCurrency": "USD",
    "sendAmount": -200,
    "sendCurrency": "USD",
    "quoteAmount": 177.1223611,//the quoted amount. Shows how much cryptocurrency X will the customer get for the baseAmount
    "quoteCurrency": "USDT",
    "receiveAmount": 175.93502096,//the amount end-user will receive after network transaction fees (transferOut.feeAmount) deducted
    "receiveCurrency": "USDT",
    "transferIn": {
        "medium": "card",
        "feeAmount": 22.71,
        "currency": "USD"
    },
    "transferOut": {
        "medium": "blockchain",
        "feeAmount": 1.18734014,//network transaction fees
        "currency": "USDT"
    }
}

Exchange Rate Calculation

Exchange Rate (USD to USDT) = baseAmount / quoteAmount = 177.28 / 177.12 = 1.00090334 USD/USDT