Quote for External Wallet
This endpoint allows you to calculate in advance how much the client will receive in Crypto when creating a withdrawal request to an external wallet, already deducting the blockchain network gas fees.
Endpoint
- Method: POST
https://api.xgateglobal.com/withdraw/transaction/crypto/amount
Test Integration
Use the form below to simulate a withdrawal to an external wallet. The system will automatically fetch the necessary data and calculate how much you would receive in Crypto.
Test: Crypto Quote (External Wallet)
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 withdrawal. |
cryptocurrency | object | Yes | The cryptocurrency object, obtained from the cryptocurrencies listing route. |
blockchainNetwork | object | Yes | The blockchain network object, obtained from the blockchain networks listing. |
Responses
Success (200 OK)
Returns the value that approximately will be received at the external wallet.
{
"amount": 99.521405,
"cryptocurrency": "USDT"
}
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 endpoint does not create a withdrawal request or move any funds. It is strictly for consultation to quote rates and estimate network fees.
Recommended Flow (UX)
To provide the best experience for your clients, we recommend the following integration flow:
- User Input: The client enters the desired withdrawal amount (e.g.,
10) in your application or website. - Quote Consultation: In the background, your system calls the
POST /withdraw/transaction/crypto/amountendpoint, sending the value10along with the selected network and cryptocurrency objects. - Display Net Amount: The API calculates the blockchain costs and returns the exact amount that will arrive in the destination wallet (e.g.,
9.369984879637112 USDT). You display on the screen something like: "You will receive approximately 9.36 USDT". - Action / Confirmation: If the user agrees with the fees and the net amount, your system then calls the definitive Create Withdrawal Request route (
POST /withdraw) to execute the transaction.
Practical Example
Follow the steps below to perform a quote for external wallet.
Step 1: Enter the crypto amount for the quote:
{
"amount": 100,
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
},
"cryptocurrency": {
"_id": "6733a2a9007**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
}
}
Step 2: You must fetch and inject the blockchain network object inside blockchainNetwork:
{
"amount": 100,
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
},
"cryptocurrency": {
"_id": "6733a2a9007**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
}
}
You can get the list of blockchain networks by clicking here.
Step 3: You must fetch and inject the cryptocurrency object inside cryptocurrency:
{
"amount": 100,
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
},
"cryptocurrency": {
"_id": "6733a2a9007**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
}
}
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 = "email@domain.com";
const password = "••••••";
const amount = 10;
try {
const url_api = "https://api.xgateglobal.com"
// 1. Login
const login = await axios.post(`${url_api}/auth/token`, { email, password });
const config = {
headers: { "Authorization": `Bearer ${login.data.token}` }
};
// 2. Fetch Networks and Cryptocurrencies
const blockchains = await axios.get(`${url_api}/withdraw/company/blockchain-networks`, config);
// Selects the first available network
const selectedNetwork = blockchains.data[0];
// Searches specifically for the USDT object within the network's crypto list
const usdtObject = selectedNetwork.cryptocurrencies.find(
item => item.cryptocurrency.symbol === 'USDT'
);
if (!usdtObject) {
throw new Error(`USDT not found in ${selectedNetwork.name} network`);
}
// 3. Calculate Quote
const { data } = await axios.post(`${url_api}/withdraw/transaction/crypto/amount`, {
amount,
cryptocurrency: usdtObject.cryptocurrency,
blockchainNetwork: selectedNetwork
}, config);
console.log("Quote Received:", data);
} catch (error) {
console.log(error.response ? error.response.data : error.message);
}
})()