OxaPay Docs
Legacy
Legacy
  • Introduction
  • Getting Started
  • Integrations
    • Payment Links
    • Donations
    • Merchant API
    • Payout API
    • Plugins
      • WooCommerce
      • WISECP
      • Clientexec
      • Blesta
      • WHMCS
      • PrestaShop
      • Easy Digital Downloads
      • Paid Memberships Pro
      • Gravity Forms
      • Restrict Content Pro
    • Merchant and Payout Service with API
  • API Reference
    • Creating an Invoice
    • Creating White-Label Payment
    • Creating Static Wallet
    • Revoking Static Wallet
    • Static Wallets List
    • Payment Information
    • Payment History
    • Accepted Coins
    • Price
    • Creating Payout
    • Payout Information
    • Payout History
    • Account Balance
    • Exchange Rate
    • Exchange Calculate
    • Exchange Pairs
    • Exchange Request
    • Exchange History
    • Supported Currencies
    • Supported Fiat Currencies
    • Supported Networks
    • System Status
    • Result code table
    • Merchant status table
    • Payout status table
  • Webhook
  • Use Cases
  • Troubleshooting
Powered by GitBook
On this page
  1. API Reference

Exchange Request

PreviousExchange PairsNextExchange History

Last updated 4 months ago

Effortlessly initiate currency conversions for a specific amount from one cryptocurrency to another in real-time, receiving your desired currency at the prevailing global market price. To explore the available conversion options, refer to the endpoint, which provides a comprehensive list of supported currency pairs for seamless transactions. Whether you're swapping Bitcoin for Tether or Tether for Litecoin, this feature ensures quick and accurate conversions at the current market rates.

POST https://api.oxapay.com/exchange/request

To use this endpoint, you need to make a POST request to the specified URL with the required parameters. The typical parameters for this request include:

Request Body

Name
Type
Description

key*

string

Your general API key for authentication and authorization.

toCurrency*

string

fromCurrency*

string

amount*

decimal

The amount of cryptocurrency to you want to exchange

{
  "result": integer, // The result code indicates the success or failure of the request.
  "message": string, // A message providing additional information about the result.
  "trackId": string, // The unique identifier for the payout request in the OxaPay payment gateway. 
  "status": string, // The current status of the payout (Processing, Sending, Complete, or Rejected).
  "amount": string, // The amount you want to exchange
  "fromCurrency": string, // The currency code of the cryptocurrency you want to convert from
  "toCurrency": string, // The currency code of the cryptocurrency you want to convert to
  "toAmount": string, // The amount you'll receive in your desired cryptocurrency.
  "rate": string, // The real-time exchange rate representing the number of units of `fromCurrency` equivalent to `toCurrency`.
  "date": string // exchange time
}

Please ensure that you provide the necessary parameters accurately in the request to create a exchange request successfully.

Example codes

curl -X POST https://api.oxapay.com/exchange/request \
-d '{
  "key": "YOUR_GENERAL_API_KEY",
  "amount": 0.5,
  "fromCurrency": "BTC",
  "toCurrency": "USDT"
}'
<?php

$url = 'https://api.oxapay.com/exchange/request';

$data = array(
  'key' => 'YOUR_GENERAL_API_KEY',
  'amount": 0.5,
  'fromCurrency': 'BTC',
  'toCurrency': 'USDT'
);

$options = array(
    'http' => array(
        'header' => 'Content-Type: application/json',
        'method'  => 'POST',
        'content' => json_encode($data),
    ),
);

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response);
var_dump($result);
?>
const axios = require('axios');
const url = 'https://api.oxapay.com/exchange/request';
const data = {
  key: 'YOUR_GENERAL_API_KEY',
  amount: 0.5,
  fromCurrency: 'BTC',
  toCurrency: 'USDT'
};

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

url = 'https://api.oxapay.com/exchange/request'
data = {
  'key': 'YOUR_GENERAL_API_KEY',
  'amount': 0.5,
  'fromCurrency': 'BTC',
  'toCurrency': 'USDT'
}
response = requests.post(url, data=json.dumps(data))
result = response.json()
print(result)

Replace YOUR_GENERAL_API_KEY with your actual API key and adjust the parameters as needed for your specific use case.

The code of the cryptocurrency you want to convert to

The code of the cryptocurrency you want to convert from

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

exchange pairs
result codes
currency
currency