Skip to main content

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
Endpoint URL
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)

1. Your Credentials

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 withdrawal.
cryptocurrencyobjectYesThe cryptocurrency object, obtained from the cryptocurrencies listing route.
blockchainNetworkobjectYesThe 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​

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

How to use​

Consultation Only

This endpoint does not create a withdrawal request or move any funds. It is strictly for consultation to quote rates and estimate network fees.

To provide the best experience for your clients, we recommend the following integration flow:

  1. User Input: The client enters the desired withdrawal amount (e.g., 10) in your application or website.
  2. Quote Consultation: In the background, your system calls the POST /withdraw/transaction/crypto/amount endpoint, sending the value 10 along with the selected network and cryptocurrency objects.
  3. 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".
  4. 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​

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);
}
})()