Skip to main content

Fiat to Crypto Quote

This endpoint allows you to calculate in advance how much the customer will receive in Crypto when depositing a specific amount in fiat currency.

Use this route to display a "preview" or real-time quote on your user's screen before they confirm the generation of the deposit order.


Endpoint​

  • Method: POST
Endpoint URL
https://api.xgateglobal.com/deposit/conversion/tether

Test Integration​

Use the form below to simulate a conversion. The system will automatically fetch BRL currency data and calculate how much it would yield in Crypto.

💱

Test: Conversion Quote

1. Your Credentials

2. Simulation Data

Request​

You must send the authentication Header and the JSON body with the amount and currency object.

Required Headers​

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

Body (Request Body)​

FieldTypeRequiredDescription
amountnumberYesAmount in FIAT Currency that you want to convert.
currencyobjectYesThe Fiat currency object, obtained from the currency listing route.

Responses​

Success (200 OK)​

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

{
"amount": 0.186433,
"crypto": "USDT",
"fiatToCryptoExchangeRate": "R$ 5.364"
}

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 serves only for consultation.

  1. Input: The user types "R$ 100.00" in your app/site.
  2. Query: Your system calls POST /deposit/conversion/tether sending the amount 100 and the BRL currency object.
  3. Display: The API returns that this equals 18.64 USDT. You display: "You will receive approximately 18.64 USDT".
  4. Action: If the user agrees, then you call the Create Deposit Order route (POST /deposit).

Practical Example​

Follow the steps below to perform the quote

Step 1: Insert the BRL amount for the quote:

{
"amount": 100,
"currency": {
"_id": "6728cba3******************",
"name": "BRL",
"type": "PIX",
"createdDate": "2024-11-04T16:04:50.019Z",
"updatedDate": "2024-11-07T02:23:38.606Z",
"__v": 0,
"symbol": "R$"
}
}

Step 2: You must fetch and inject the currency object within currency:

{
"amount": 100,
"currency": {
"_id": "6728cba3******************",
"name": "BRL",
"type": "PIX",
"createdDate": "2024-11-04T16:04:50.019Z",
"updatedDate": "2024-11-07T02:23:38.606Z",
"__v": 0,
"symbol": "R$"
}
}

You can obtain the list of currencies by clicking here.


Integration​

This 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 currencies = await axios.get(`${url_api}/deposit/company/currencies`, {
headers: {
"Authorization": `Bearer ${login.data.token}`
}
});
const { data } = await axios.post(`${url_api}/deposit/conversion/tether`, {
amount,
currency: currencies.data[0]
}, {
headers: {
"Authorization": `Bearer ${login.data.token}`
}
});
console.log(data); // Response
} catch (error) {
console.log(error.response.data.message) // Error
}
})()