๐Swap
This documentation provides details on the API endpoints available for Whirlprivacy.io, focusing on swap-related operations.
โ ๏ธ You must be logged in to use these requests below.
For all requests that require user authentication, you must include the following headers:
GET /swap/data
- Retrieve Swap Data
Allows the retrieval of swap data for a given currency pair and amount.
Parameters:
Response:
{
"swapData": {
"tickerIn": "string",
"tickerOut": "string",
"amountIn": "string",
"rate": "string",
"expectedOut": "string"
}
}
Error Handling:
Example Code:
const fetch = require('node-fetch');
const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_key';
const retrieveSwapData = async (tickerIn, tickerOut, amountIn) => {
try {
const url = new URL(`${BASE_URL}swap/data`);
url.search = new URLSearchParams({ tickerIn, tickerOut, amountIn }).toString();
const response = await fetch(url, {
headers: {
'X-API-key': API_KEY
}
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error retrieving swap data:', error);
}
};
retrieveSwapData('tickerA', 'tickerB', 'amountIn');
POST /swap/initiate
- Initiate a Swap
Initiates a currency swap operation for a logged-in user.
Parameters:
Response:
{
"message": "Swap initiated"
}
Error Handling:
Example Code:
const fetch = require('node-fetch');
const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_key';
const initiateSwap = async (sender, tickerIn, tickerOut, amountIn, slippage) => {
try {
const response = await fetch(`${BASE_URL}swap/initiate`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-key': API_KEY
},
body: JSON.stringify({ sender, tickerIn, tickerOut, amountIn, slippage })
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error initiating swap:', error);
}
};
initiateSwap('uuid', 'tickerA', 'tickerB', 'amountIn', 100);
GET /swap/history
- Retrieve Swap History
Retrieves the swap history for a logged-in user.
Parameters:
Response:
{
"data": [
{
"tickerIn": "string",
"tickerOut": "string",
"status": "string",
"createdAt": "string",
"formattedIn": "string",
"formattedOut": "string"
}
],
"meta": {
"totalPages": "integer",
"currentPage": "integer",
"perPage": "integer",
"totalItems": "integer"
}
}
Error Handling:
Example Code:
const fetch = require('node-fetch');
const BASE_URL = 'https://api.whirlprivacy.io/';
const API_KEY = 'your_api_key';
const retrieveSwapHistory = async (uuid, page) => {
try {
const response = await fetch(`${BASE_URL}swap/history?uuid=${uuid}&page=${page}`, {
method: 'GET',
headers: {
'X-API-key': API_KEY
}
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error retrieving swap history:', error);
}
};
// Example usage with page number 1
retrieveSwapHistory("uuid", 1);
Last updated