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
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
Request
You must send the authentication Header and the JSON body with the amount and currency object.
Required Headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer <your_token> | The JWT token obtained from login. |
Body (Request Body)
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Amount in FIAT Currency that you want to convert. |
currency | object | Yes | The 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
| 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 serves only for consultation.
The Recommended Flow (UX)
- Input: The user types "R$ 100.00" in your app/site.
- Query: Your system calls
POST /deposit/conversion/tethersending the amount 100 and the BRL currency object. - Display: The API returns that this equals
18.64 USDT. You display: "You will receive approximately 18.64 USDT". - 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
- Node.js
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
}
})()