OxaPay Docs
v1
v1
  • Introduction
    • Welcome to OxaPay
    • Integrations
      • Payment Link
      • Donation Service
      • Merchant Service
      • Payout Service
      • Swap Service
      • Plugins
        • WooCommerce
        • WISECP
        • Clientexec
        • Blesta
        • WHMCS
        • PrestaShop
        • Easy Digital Downloads
        • Paid Memberships Pro
        • Gravity Forms
        • Restrict Content Pro
  • API Reference
    • Payment
      • Generate Invoice
      • Generate White Label
      • Generate Static Address
      • Revoking Static Address
      • Static Address List
      • Payment Information
      • Payment History
      • Accepted Currencies
      • Payment Status Table
    • Payout
      • Generate Payout
      • Payout Information
      • Payout History
      • Payout Status Table
    • Swap
      • Swap Request
      • Swap History
      • Swap Pairs
      • Swap Calculate
      • Swap Rate
    • Common
      • Account Balance
      • Prices
      • Supported Currencies
      • Supported Fiat Currencies
      • Supported Networks
      • System Status
    • Error
  • Webhook
  • Use Cases
Powered by GitBook
On this page
  • API Request Sample Codes
  • API Response Example
  1. API Reference
  2. Swap

Swap History

This endpoint allows you to retrieve a list of swap transactions based on your General API Key. You can filter the results by various criteria, including time range, currency, and swap type (e.g., auto_convert, manual_swap, or swap_by_api). Pagination support lets you fetch the results in smaller, manageable sets for better control and efficiency.

GET 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.

Name
Type
Description

general_api_key*

string

Your General API Key for authentication and authorization.

Request Params

Name
Type
Description

track_id

integer

Filter spesific exchange by it`s trackId.

type

string

Filter exchanges based on type (autoConvert or manualSwap or swapByApi).

from_currency

string

to_currency

string

from_date

integer

The start of the date window to query for exchanges in unix format.

to_date

integer

The start of the date window to query for exchanges in unix format.

sort_by

string

Sort the received list by a parameter. Set to 'create_date' by default. Possible values: 'create_date', 'amount' [default 'create_date'].

sort_type

string

Display the list in ascending or descending order. Possible values: 'asc', 'desc' [default 'desc'].

size

integer

Number of records to be displayed on one page. Possible values: from 1 to 200 - default 10.

page

integer

The page number of the results you want to retrieve. Possible values: from 1 to the total number of pages - default 1.

{
  "data": {
    "list": 
      {
        "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).
      }[],
    "meta": {
      "page": integer, // The current page number of the result set.
      "last_page": integer, // The total number of pages available based on the number of records and page size.
      "total": integer // The total number of payments available for the specified criteria.
    },
  },
  "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.
}

API Request Sample Codes

curl -X GET "https://api.oxapay.com/v1/general/swap/?size=20&page=1" \
    -H "general_api_key: YOUR_GENERAL_API_KEY" \
    -H "Content-Type: application/json"
<?php

$url = 'https://api.oxapay.com/v1/general/swap/';

$data = array(
    'size' => 20,
    'page' => 1
);

$query = http_build_query($data);
$url = $url . '?' . $query;

$headers = [
    'Content-Type: application/json',
    'general_api_key: YOUR_GENERAL_API_KEY'
];

$options = array(
    'http' => array(
        'header'  => implode("\r\n", $headers),
        'method'  => 'GET'
    ),
);

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);
if ($response === FALSE) {
    die('Error occurred');
}

$result = json_decode($response, true);
var_dump($result);
?>
const axios = require('axios');

const url = 'https://api.oxapay.com/v1/general/swap/';

const params = {
  size: 20,
  page: 1
};

const headers = {
  'general_api_key': `YOUR_GENERAL_API_KEY`,
  'Content-Type': 'application/json',
};

axios.get(url, { params, headers })
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error);
  });
import requests

url = 'https://api.oxapay.com/v1/general/swap/'

params = {
    'size': 20,
    'page': 1
}

headers = {
    'general_api_key': 'YOUR_GENERAL_API_KEY',
    'Content-Type': 'application/json'
}

response = requests.get(url, params=params, headers=headers)
result = response.json()
print(result)

Please make sure to replace YOUR_GENERAL_API_KEY in the code snippets with your actual General API Key.

These example code snippets demonstrate how to request the "Swap History" endpoint using different programming languages. You can customize the data parameters according to your specific requirements.

API Response Example

{
    "data": {
        "list": [
            {
                "track_id": "393831199",
                "from_currency": "USDT",
                "to_currency": "BTC",
                "from_amount": 10.0000000000,
                "to_amount": 0.0001054000,
                "rate": 94876.66034156,
                "date": 1736508792
            },
            {
                "track_id": "315890329",
                "from_currency": "USDT",
                "to_currency": "BTC",
                "from_amount": 1.0000000000,
                "to_amount": 0.0000105200,
                "rate": 95057.03422053,
                "date": 1736503906
            }
        ],
        "meta": {
            "page": 1,
            "last_page": 1,
            "total": 10
        }
    },
    "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.

PreviousSwap RequestNextSwap Pairs

Last updated 3 months ago

Specify the for filtering exchanges in a specific fromCurrency.

Specify the for filtering exchanges in a specific toCurrency.

Please note that a successful request will return status 200. In case of any issues or validation problems, refer to the corresponding for further details.

error
currency symbol
currency symbol