Swap Request
This endpoint allows you to swap your account assets. You can swap one cryptocurrency for another instantly at the current market rate. To see the supported swap options, refer to the swap pairs endpoint. Whether you're swapping Bitcoin for Tether, Tether for Litecoin, or any other supported combination, this feature ensures secure and accurate asset swaps. Swaps are processed in real-time to provide you with the best available rates.
POST
https://api.oxapay.com/v1/general/swap
Authentication
You must include the General API Key in the request header to authenticate your access to the API.
general_api_key*
string
Your General API Key for authentication and authorization.
Request Body
from_currency*
string
to_currency*
string
amount*
decimal
Specify the amount of currency you want to swap.
{
"data": {
"track_id": string, // Unique identifier for the transaction, typically represented as a string (e.g., transaction ID or session ID).
"from_currency": string, // The currency being exchanged from, e.g., 'USDT' (Tether).
"to_currency": string, // The currency being exchanged to, e.g., 'BTC' (Bitcoin).
"from_amount": decimal, // The amount of the "from_currency" being swapped, represented with high precision (e.g., 10 USDT).
"to_amount": decimal, // The amount of the "to_currency" received after the swap, represented with high precision (e.g., 0.0001054 BTC).
"rate": decimal, // The exchange rate between the "from_currency" and "to_currency" at the time of the transaction (e.g., 1 USDT = 94876.66034156 BTC).
"date": integer // Timestamp (UNIX epoch) representing when the swap occurred, typically in seconds (e.g., 1736508792 for the time the swap was executed).
},
"message": string, // A message containing additional information about the result of the request.
"error": {
"type": string,
"key": string,
"message": string
} || {}, // An object that provides details about any errors that occurred.
"status": integer, // The status of the request response. Typically provided as a numeric code (e.g., 200 for success or other codes for errors).
"version": string // The version of the API being used.
}
Please note that a successful request will return status 200. In case of any issues or validation problems, refer to the corresponding error for further details.
API Request Sample Codes
curl -X POST https://api.oxapay.com/v1/general/swap \
-H "general_api_key: YOUR_GENERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 0.5,
"from_currency": "BTC",
"to_currency": "USDT"
}'
These example code snippets demonstrate how to request the "Swap Request" endpoint using different programming languages. You can customize the data parameters according to your specific requirements.
API Response Example
{
"data": {
"track_id": "393831199",
"from_currency": "USDT",
"to_currency": "BTC",
"from_amount": 10.0000000000,
"to_amount": 0.0001054000,
"rate": 94876.66034156,
"date": 1736508792
},
"message": "Operation completed successfully!",
"error": {},
"status": 200,
"version": "1.0.0"
}
The response example above is provided to help you understand the format and structure of the response. If you have any further questions or need assistance, please feel free to contact to your account manager.
Last updated