Skip to main content

Crypto to FIAT Quote

This endpoint allows you to calculate in advance how much the client will receive in FIAT when cashing out a specific amount in Crypto.


Endpoint​

  • Method: POST
Endpoint URL
https://api.xgateglobal.com/withdraw/conversion/brl/pix

Test Integration​

Use the form below to simulate the quote. The system will automatically fetch the cryptocurrency data and calculate how much it would yield in Fiat.

💱

Test: Conversion Quote

1. Your Credentials

2. Simulation Data

Request​

You need to send the authentication Header and the JSON body with the value and currency object.

Required Headers​

HeaderValueDescription
AuthorizationBearer <your_token>The JWT token obtained at login.

Body (Request Body)​

FieldTypeRequiredDescription
amountnumberYesAmount in Crypto for which you want to calculate the quote.
cryptocurrencyobjectYesThe cryptocurrency object, obtained from the cryptocurrencies listing route.

Responses​

Success (200 OK)​

Returns the converted value, the currency, and the exchange rate used at that moment.

{
"amount": 5.17,
"currency": "R$",
"cryptoToFiatExchangeRate": "R$ 5.170"
}

Common Errors​

StatusMessageLikely Reason
401Unauthorized• Invalid or expired token.
• Invalid or missing header.
• IP not allowed.
500Internal Server ErrorInternal server error. Contact support.

How to Use​

This route does not generate a payment order, it is only for consultation.

  1. Input: The user types "1" (amount in Crypto) in your app/site.
  2. Consultation: Your system calls POST /withdraw/conversion/brl/pix sending the value 1 Crypto and the cryptocurrency object.
  3. Display: The API returns that this equals 5.17. You display: "You will receive approximately R$ 5.17".
  4. Action: If the user agrees, you call the Create Withdrawal Order for Crypto to FIAT Conversion route (POST /withdraw).

Practical Example​

Follow the steps below to perform the Crypto to FIAT quote.

Step 1: Enter the Crypto amount for the quote:

{
"amount": 1,
"cryptocurrency": {
"_id": "6733a2a9******************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether",
"updatedDate": "202******************",
"createdDate": "202******************",
"__v": 0
}
}

Step 2: You must fetch and inject the cryptocurrency object inside cryptocurrency:

{
"amount": 1,
"cryptocurrency": {
"_id": "6733a2a9******************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether",
"updatedDate": "202******************",
"createdDate": "202******************",
"__v": 0
}
}

You can get the list of cryptocurrencies by clicking here.


Integration​

The integration example uses the Axios library in Node.js.

Installing Axios:

npm install axios

JavaScript Example:

const axios = require("axios");

(async () => {
const email = "your_email@domain.com";
const password = "**********";
const amount = 10.90;

try {
const url_api = "https://api.xgateglobal.com"
const login = await axios.post(`${url_api}/auth/token`, { email, password });
const cryptocurrencies = await axios.get(`${url_api}/withdraw/company/cryptocurrencies`, {
headers: {
"Authorization": `Bearer ${login.data.token}`
}
});
const { data } = await axios.post(`${url_api}/withdraw/conversion/brl/pix`, {
amount,
cryptocurrency: cryptocurrencies.data[0]
}, {
headers: {
"Authorization": `Bearer ${login.data.token}`
}
});
console.log(data); // Response
} catch (error) {
console.log(error.response.data.message) // Error
}
})()