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
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
Request
You need to send the authentication Header and the JSON body with the value and currency object.
Required Headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer <your_token> | The JWT token obtained at login. |
Body (Request Body)
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Amount in Crypto for which you want to calculate the quote. |
cryptocurrency | object | Yes | The 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
| Status | Message | Likely Reason |
|---|---|---|
| 401 | Unauthorized | • Invalid or expired token. • Invalid or missing header. • IP not allowed. |
| 500 | Internal Server Error | Internal server error. Contact support. |
How to Use
This route does not generate a payment order, it is only for consultation.
The Recommended Flow (UX)
- Input: The user types "1" (amount in Crypto) in your app/site.
- Consultation: Your system calls
POST /withdraw/conversion/brl/pixsending the value 1 Crypto and the cryptocurrency object. - Display: The API returns that this equals
5.17. You display: "You will receive approximately R$ 5.17". - 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
- Node.js
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
}
})()