OX.FUN
TradeSupport
  • 🏠OX.FUN
  • OX.FUN DOCS
    • 📈Perps
    • 📊Strategies
    • 🐂OX Coin
    • 🍂Seasons
    • 📩Referral
  • Page
  • API
    • ⚙️OX FUN API
    • 🔑API Key Management
    • ☁️Websocket API
      • Authentication
      • Session Keep Alive
      • Order Commands
        • Place Limit Order
        • Place Market Order
        • Place Stop Limit Order
        • Place Stop Market Order
        • Place Batch Market Order
        • Cancel Order
        • Cancel Batch Order
        • Modify Order
        • Modify Batch Orders
      • Subscriptions - Private
        • Balance Channel
        • Position Channel
        • Order Channel
          • Order Opened
          • Order Closed
          • Order Closed Failure
          • Order Modified
          • Order Modified Failure
          • Order Matched
      • Subscriptions - Public
        • Fixed Size Order Book
        • Full Order Book
        • Incremental Order Book
        • Best Bid/Ask
        • Trade
        • Ticker
        • Candles
        • Liquidation RFQ
        • Market
      • Other Responses
      • Error Codes
        • Curl Error Codes
    • 🔌REST API V3
      • Account & Wallet - Private
      • Deposits & Withdrawals - Private
      • Market Data - Public
      • Orders - Private
      • Trades - Private
  • 🔗External
    • 💧Aerodrome Pool
    • 🔵Trade on Uniswap (Base)
    • Trade on Solana
    • 🦎CoinGecko
    • API Code Examples
  • 🔗SOCIALS
    • 🐂OX.FUN
    • Discord
    • Twitter
Powered by GitBook
On this page
  • GET /v3/deposit-addresses
  • GET /v3/deposit
  • GET /v3/withdrawal-addresses
  • GET /v3/withdrawal
  • POST /v3/withdrawal
  • GET /v3/withdrawal-fee
  1. API
  2. REST API V3

Deposits & Withdrawals - Private

GET /v3/deposit-addresses

Deposit addresses

Curl

Request

GET /v3/deposit-addresses?asset={asset}&network={network}

Successful response format

{
    "success": true,
    "data": {
        "address":"0xD25bCD2DBb6114d3BB29CE946a6356B49911358e"
    }
}
Python
import os
import requests
import hmac
import hashlib
import base64
from dotenv import load_dotenv
from datetime import datetime
import random
import string

load_dotenv()

def get_deposit_address(asset, network):
    api_key = os.getenv('API_KEY')
    secret_key = os.getenv('API_SECRET').encode('utf-8')
    timestamp = datetime.utcnow().isoformat()
    nonce = ''.join(random.choices(string.ascii_lowercase + string.digits, k=16))
    method = 'GET'
    path = 'api.ox.fun'
    endpoint = '/v3/deposit-addresses'
    query = f'asset={asset}&network={network}'
    msg_string = f'{timestamp}\n{nonce}\n{method}\n{path}\n{endpoint}\n{query}'

    sign = base64.b64encode(hmac.new(secret_key, msg_string.encode('utf-8'), hashlib.sha256).digest()).decode('utf-8')

    try:
        response = requests.get(f'https://{path}{endpoint}?{query}', headers={
            'Content-Type': 'application/json',
            'AccessKey': api_key,
            'Timestamp': timestamp,
            'Signature': sign,
            'Nonce': nonce
        })
        response_data = response.json()
        if response_data.get('success'):
            return response_data['data']['address']
        else:
            print('Failed to fetch deposit address')
    except requests.exceptions.RequestException as error:
        print('Error making API request:', error)

# Example usage

address = get_deposit_address('OX', 'Solana')
print(address)

Javascript
require('dotenv').config();
const axios = require('axios');
const CryptoJS = require("crypto-js");

async function getDepositAddress(asset, network) {
  const apiKey = process.env.API_KEY;
  const secretKey = process.env.API_SECRET;
  const timestamp = new Date().toISOString();
  const nonce = Math.random().toString(36).substring(2);
  const method = 'GET';
  const path = 'api.ox.fun';
  const endpoint = '/v3/deposit-addresses';
  const query = `asset=${asset}&network=${network}`;
  const msgString = `${timestamp}\n${nonce}\n${method}\n${path}\n${endpoint}\n${query}`;

  const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(msgString, secretKey));

  try {
    const response = await axios.get(`https://${path}${endpoint}?${query}`, {
      headers: {
        'Content-Type': 'application/json',
        'AccessKey': apiKey,
        'Timestamp': timestamp,
        'Signature': sign,
        'Nonce': nonce
      }
    });
    //console.log(response.data);
    if (response.data.success) {
      return response.data.data.address;
    } else {
      console.error('Failed to fetch deposit address');
    }
  } catch (error) {
    console.error('Error making API request:', error.response ? error.response.data : error.message);
  }
}

async function main() {
  const address = await getDepositAddress('OX', 'Solana');
  console.log(address);
}

main();

Request Parameter
Type
Required
Description

asset

STRING

YES

network

STRING

YES

Response Field
Type
Description

address

STRING

Deposit address

memo

STRING

Memo (tag) if applicable

GET /v3/deposit

Deposit history

Curl

Request

GET /v3/deposit?asset={asset}&limit={limit}&startTime={startTime}&endTime={endTime}

Successful response format

{
    "success": true,
    "data": [
        {
            "asset": "USDT",
            "network": "ERC20",
            "address": "0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B",
            "quantity": "100.0",
            "id": "651573911056351237",
            "status": "COMPLETED",
            "txId": "0x2b2f01a3cbe5165c883e3b338441182f309ddb8f504b52a2e9e15f17ea9af044",
            "creditedAt": "1617940800000"
        }
    ]
}
Python
import os
import requests
import hmac
import hashlib
import base64
from dotenv import load_dotenv
from datetime import datetime
import random
import string
import time

load_dotenv()

def get_deposit_data(asset, limit, start_time, end_time):
    api_key = os.getenv('API_KEY')
    secret_key = os.getenv('API_SECRET').encode('utf-8')
    timestamp = datetime.utcnow().isoformat()
    nonce = ''.join(random.choices(string.ascii_lowercase + string.digits, k=16))
    method = 'GET'
    path = 'api.ox.fun'
    endpoint = '/v3/deposit'
    query = f'asset={asset}&limit={limit}&startTime={start_time}&endTime={end_time}'
    msg_string = f'{timestamp}\n{nonce}\n{method}\n{path}\n{endpoint}\n{query}'

    sign = base64.b64encode(hmac.new(secret_key, msg_string.encode('utf-8'), hashlib.sha256).digest()).decode('utf-8')

    try:
        response = requests.get(f'https://{path}{endpoint}?{query}', headers={
            'Content-Type': 'application/json',
            'AccessKey': api_key,
            'Timestamp': timestamp,
            'Signature': sign,
            'Nonce': nonce
        })
        response_data = response.json()
        if response_data.get('success'):
            return response_data['data']
        else:
            print('Failed to fetch deposit data')
    except requests.exceptions.RequestException as error:
        print('Error making API request:', error)

# Example usage
start_time = int(time.time() * 1000) - 24 * 60 * 60 * 1000  # 24 hours ago in milliseconds
end_time = int(time.time() * 1000)  # current time in milliseconds
deposit_data = get_deposit_data('OX', 100, start_time, end_time)
print(deposit_data)
Javascript
require('dotenv').config();
const axios = require('axios');
const crypto = require('crypto');

async function getDepositData(asset, limit, startTime, endTime) {
  const apiKey = process.env.API_KEY;
  const secretKey = process.env.API_SECRET;
  const timestamp = new Date().toISOString();
  const nonce = Math.random().toString(36).substring(2);
  const method = 'GET';
  const path = 'api.ox.fun';
  const endpoint = '/v3/deposit';
  const query = `asset=${asset}&limit=${limit}&startTime=${startTime}&endTime=${endTime}`;
  const msgString = `${timestamp}\n${nonce}\n${method}\n${path}\n${endpoint}\n${query}`;

  const sign = crypto.createHmac('sha256', secretKey).update(msgString).digest('base64');

  try {
    const response = await axios.get(`https://${path}${endpoint}?${query}`, {
      headers: {
        'Content-Type': 'application/json',
        'AccessKey': apiKey,
        'Timestamp': timestamp,
        'Signature': sign,
        'Nonce': nonce
      }
    });

    if (response.data.success) {
      return response.data.data;
    } else {
      console.error('Failed to fetch deposit data');
    }
  } catch (error) {
    console.error('Error making API request:', error.response ? error.response.data : error.message);
  }
}

// Example usage
async function main() {
const startTime = Date.now() - 24 * 60 * 60 * 1000; // 24 hours ago in milliseconds
const endTime = Date.now(); // current time in milliseconds
data = await getDepositData('OX', 100, startTime, endTime);
console.log(data);
}

main();

Request Parameter
Type
Required
Description

asset

STRING

NO

Default all assets

limit

LONG

NO

Default 50, max 200

startTime

LONG

NO

Millisecond timestamp. Default 24 hours ago. startTime and endTime must be within 7 days of each other. startTime is INCLUSIVE

endTime

LONG

NO

Millisecond timestamp. Default time now. startTime and endTime must be within 7 days of each other. endTime is INCLUSIVE

Response Field
Type
Description

asset

STRING

network

STRING

address

STRING

Deposit address

memo

STRING

Memo (tag) if applicable

quantity

STRING

id

STRING

status

STRING

txId

STRING

creditedAt

STRING

Millisecond timestamp

GET /v3/withdrawal-addresses

Withdrawal addresses

Provides a list of all saved withdrawal addresses along with their respected labels, network, and whitelist status

Curl

Request

GET /v3/withdrawal-addresses?asset={asset}&network={network}

Successful response format

{
    "success": true,
    "data": [
        {
            "asset": "USDT",
            "network": "ERC20",
            "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
            "label": "farming",
            "whitelisted": true
        }
    ]
}
Python
import os
import datetime
import time
import base64
import hmac
import hashlib
import requests
from dotenv import load_dotenv

load_dotenv()

def get_withdrawal_address(asset, network):
    api_key = os.getenv('API_KEY')
    secret_key = os.getenv('API_SECRET').encode('utf-8')
    timestamp = datetime.datetime.utcnow().isoformat()
    nonce = str(int(time.time() * 1000))
    verb = 'GET'
    path = 'api.ox.fun'
    method = '/v3/withdrawal-addresses'
    body = f'asset={asset}&network={network}'

    msg_string = f'{timestamp}\n{nonce}\n{verb}\n{path}\n{method}\n{body}'
    sign = base64.b64encode(hmac.new(secret_key, msg_string.encode('utf-8'), hashlib.sha256).digest()).decode('utf-8')

    try:
        response = requests.get(f'https://{path}{method}?{body}', headers={
            'Content-Type': 'application/json',
            'AccessKey': api_key,
            'Timestamp': timestamp,
            'Signature': sign,
            'Nonce': nonce
        })
        response_data = response.json()
        if response_data.get('success'):
            print('Withdrawal Address:', response_data['data'])
        else:
            print('Failed to fetch withdrawal address')
    except requests.exceptions.RequestException as error:
        print('Error making API request:', error)

# Example usage
get_withdrawal_address('OX', 'Solana')
Javascript
require('dotenv').config();
const axios = require('axios');
const CryptoJS = require("crypto-js");

async function getWithdrawalAddress(asset, network) {
  const apiKey = process.env.API_KEY;
  const secretKey = process.env.API_SECRET;
  const timestamp = new Date().toISOString();
  const nonce = Math.random().toString(36).substring(2);
  const verb = 'GET';
  const path = 'api.ox.fun';
  const method = '/v3/withdrawal-addresses';
  const body = `asset=${asset}&network=${network}`;

  const msgString = `${timestamp}\n${nonce}\n${verb}\n${path}\n${method}\n${body}`;
  const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(msgString, secretKey));

  try {
    const response = await axios.get(`https://${path}${method}?${body}`, {
      headers: {
        'Content-Type': 'application/json',
        'AccessKey': apiKey,
        'Timestamp': timestamp,
        'Signature': sign,
        'Nonce': nonce
      }
    });

    if (response.data.success) {
      console.log('Withdrawal Address:', response.data.data);
    } else {
      console.error('Failed to fetch withdrawal address');
    }
  } catch (error) {
    console.error('Error making API request:', error.response ? error.response.data : error.message);
  }
}

// Example usage
getWithdrawalAddress('OX', 'Solana');

Request Parameter
Type
Required
Description

asset

STRING

NO

Default all assets

network

STRING

NO

Default all networks

Response Field

Type

Description

asset

STRING

network

STRING

address

STRING

memo

STRING

Memo (tag) if applicable

label

STRING

Withdrawal address label

whitelisted

BOOL

GET /v3/withdrawal

Curl

Request

GET /v3/withdrawal?id={id}&asset={asset}&limit={limit}&startTime={startTime}&endTime={endTime}

Successful response format

{
    "success": true,
    "data": [
        {
            "id": "651573911056351237",
            "asset": "USDT",
            "network": "ERC20",
            "address": "0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B",
            "quantity": "1000.0",
            "fee": "0.000000000",
            "status": "COMPLETED",
            "txId": "0x2b2f01a3cbe5165c883e3b338441182f309ddb8f504b52a2e9e15f17ea9af044",
            "requestedAt": "1617940800000",
            "completedAt": "16003243243242"
        }
    ]
}
Python
import os
import datetime
import time
import base64
import hmac
import hashlib
import requests
from dotenv import load_dotenv

load_dotenv()



def get_withdrawal(id, asset, limit, start_time, end_time):
    api_key = os.getenv('API_KEY')
    secret_key = os.getenv('API_SECRET').encode('utf-8')
    timestamp = datetime.datetime.utcnow().isoformat()
    nonce = str(int(time.time() * 1000))
    verb = 'GET'
    path = 'api.ox.fun'
    method = '/v3/withdrawal'
    body = f'id={id}&asset={asset}&limit={limit}&startTime={start_time}&endTime={end_time}'    
    msg_string = f'{timestamp}\n{nonce}\n{verb}\n{path}\n{method}\n{body}'
    sign = base64.b64encode(hmac.new(secret_key, msg_string.encode('utf-8'), hashlib.sha256).digest()).decode('utf-8')
    sign = base64.b64encode(hmac.new(secret_key, msg_string.encode('utf-8'), hashlib.sha256).digest()).decode('utf-8')
    try:
        response = requests.get(f'https://{path}{method}?{body}', headers={
            'Content-Type': 'application/json',
            'AccessKey': api_key,
            'Timestamp': timestamp,
            'Signature': sign,
            'Nonce': nonce
        })
        response_data = response.json()
        if response_data.get('success'):
            return response_data
        else:
            print('Failed to fetch withdrawal data', response_data)
    except requests.exceptions.RequestException as error:
        print('Error making API request:', error)
        
        
# Ensure start_time and end_time are within 7 days of each other
current_time = int(time.time() * 1000)
seven_days_ago = current_time - (7 * 24 * 60 * 60 * 1000)

response = get_withdrawal('11111111111111111', 'OX', 100, seven_days_ago, current_time)
print(response)
Javascript
require('dotenv').config();
const axios = require('axios');
const CryptoJS = require("crypto-js");

async function getWithdrawal(id, asset, limit, startTime, endTime) {
  const apiKey = process.env.API_KEY;
  const secretKey = process.env.API_SECRET;
  const timestamp = new Date().toISOString();
  const nonce = Math.random().toString(36).substring(2);
  const verb = 'GET';
  const path = 'api.ox.fun';
  const method = '/v3/withdrawal';
  const body = `id=${id}&asset=${asset}&limit=${limit}&startTime=${startTime}&endTime=${endTime}`;
  const msgString = `${timestamp}\n${nonce}\n${verb}\n${path}\n${method}\n${body}`;
  const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(msgString, secretKey));

  try {
    const response = await axios.get(`https://${path}${method}?${body}`, {
      headers: {
        'Content-Type': 'application/json',
        'AccessKey': apiKey,
        'Timestamp': timestamp,
        'Signature': sign,
        'Nonce': nonce
      }
    });

    if (response.data.success) {
      return response.data;
    } else {
      console.error('Failed to fetch withdrawal data', response.data);
    }
  } catch (error) {
    console.error('Error making API request:', error);
  }
}

// Example usage
const currentTime = Date.now();
const sevenDaysAgo = currentTime - (7 * 24 * 60 * 60 * 1000);

getWithdrawal('11111111111111111', 'OX', 100, sevenDaysAgo, currentTime)
  .then(response => console.log(response))
  .catch(error => console.error(error));
Request Parameter
Type
Required
Description

id

STRING

NO

asset

STRING

NO

Default all assets

limit

LONG

NO

Default 50, max 200

startTime

LONG

NO

Millisecond timestamp. Default 24 hours ago. startTime and endTime must be within 7 days of each other. This filter applies to "requestedAt". startTime is INCLUSIVE

endTime

LONG

NO

Millisecond timestamp. Default time now. startTime and endTime must be within 7 days of each other. This filter applies to "requestedAt". endTime is INCLUSIVE

Response Field
Type
Description

id

STRING

asset

STRING

network

STRING

address

STRING

memo

STRING

Memo (tag) if applicable

quantity

STRING

fee

STRING

status

STRING

COMPLETED, PROCESSING, IN SWEEPING, PENDING, ON HOLD, CANCELED, or FAILED

txId

STRING

requestedAt

STRING

Millisecond timestamp

completedAt

STRING

Millisecond timestamp

POST /v3/withdrawal

Withdrawal request

Withdrawals may only be initiated by API keys that are linked to the parent account and have withdrawals enabled. If the wrong 2fa code is provided the endpoint will block for 10 seconds.

Curl

Request

POST /v3/withdrawal
{
    "asset": "USDT",
    "network": "ERC20",
    "address": "0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B",
    "quantity": "100",
    "externalFee": true,
    "tfaType": "GOOGLE",
    "code": "743249"
}

Successful response format

{
    "success": true,
    "data": {
        "id": "752907053614432259",
        "asset": "USDT",
        "network": "ERC20",
        "address": "0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B",
        "quantity": "100.0",
        "externalFee": true,
        "fee": "0",
        "status": "PENDING",
        "requestedAt": "1617940800000"
    }
}
Python
import os
import datetime
import time
import json
import base64
import hmac
import hashlib
import requests
from dotenv import load_dotenv

load_dotenv()

def make_withdrawal():
    api_key = os.getenv('API_KEY')
    secret_key = os.getenv('API_SECRET').encode('utf-8')
    withdraw_address = os.getenv('WITHDRAW_ADDRESS')
    ts = datetime.datetime.utcnow().isoformat()
    nonce = str(int(time.time() * 1000))
    method = "/v3/withdrawal"
    api_url = "api.ox.fun"
    timestamp = int(round(time.time() * 1000))
    post_data = {
        "asset": "OX",
        "network": "Solana",
        "address": withdraw_address,
        "quantity": "100",
        "externalFee": True,
        "recvWindow": 3000,
        "timestamp": timestamp,
        "responseType": "FULL"
    }
    body = json.dumps(post_data)

    msg_string = '{}\n{}\n{}\n{}\n{}\n{}'.format(ts, nonce, 'POST', api_url, method, body)
    sig = base64.b64encode(hmac.new(secret_key, msg_string.encode('utf-8'), hashlib.sha256).digest()).decode('utf-8')

    headers = {
        'Content-Type': 'application/json',
        'AccessKey': api_key,
        'Timestamp': ts,
        'Signature': sig,
        'Nonce': nonce
    }

    try:
        response = requests.post(f"https://{api_url}{method}", data=body, headers=headers)
        print("Status Code:", response.status_code)
        print("Response Text:", response.json())  # Print the raw response content
    except requests.exceptions.RequestException as e:
        print('Error making withdrawal request:', e)

make_withdrawal()
Javascript
require('dotenv').config();
const axios = require('axios');
const CryptoJS = require("crypto-js");

async function makeWithdrawal() {
  const apiKey = process.env.API_KEY;
  const secretKey = process.env.API_SECRET;
  const withdrawAddress = process.env.WITHDRAW_ADDRESS;
  const ts = new Date().toISOString();
  const nonce = Math.random().toString(36).substring(2);
  const method = "/v3/withdrawal";
  const timestamp = Math.floor(Date.now() / 1000);
  const postData = {
    asset: "OX",
    network: "Solana",
    address: withdrawAddress,
    quantity: "100",
    externalFee: true,
    recvWindow: 3000,
    timestamp: timestamp,
    responseType: "FULL"
  };
  const body = JSON.stringify(postData);

  const msgString = `${ts}\n${nonce}\nPOST\napi.ox.fun\n${method}\n${body}`;
  const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(msgString, secretKey));

  try {
    const response = await axios.post(`https://api.ox.fun${method}`, body, {
      headers: {
        'Content-Type': 'application/json',
        'AccessKey': apiKey,
        'Timestamp': ts,
        'Signature': sign,
        'Nonce': nonce
      }
    });

    if (response.data.success) {
      console.log('Withdrawal Successful:', response.data.data);
    } else {
      console.error('Failed to initiate withdrawal');
    }
  } catch (error) {
    console.error('Error making withdrawal request:', error);
  }
}

makeWithdrawal();

Request Parameter
Type
Required
Description

asset

STRING

YES

network

STRING

YES

address

STRING

YES

memo

STRING

NO

Memo is required for chains that support memo tags

quantity

STRING

YES

externalFee

BOOL

YES

If false, then the fee is taken from the quantity, also with the burn fee for asset SOLO

tfaType

STRING

NO

GOOGLE, or AUTHY_SECRET, or YUBIKEY

code

STRING

NO

2fa code if required by the account

Response Field
Type
Description

id

STRING

asset

STRING

network

STRING

address

STRING

memo

STRING

quantity

STRING

externalFee

BOOL

If false, then the fee is taken from the quantity

fee

STRING

status

STRING

requestedAt

STRING

Millisecond timestamp

GET /v3/withdrawal-fee

Withdrawal fee estimate

Curl

Request

GET /v3/withdrawal-fee?asset={asset}&network={network}&address={address}&memo={memo}&quantity={quantity}&externalFee={externalFee}

Successful response format

{
    "success": true,
    "data": {
        "asset": "USDT",
        "network": "ERC20",
        "address": "0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B",
        "quantity": "1000.0",
        "externalFee": true,
        "estimatedFee": "0.01"
    }
}
Python
import os
import requests
import hmac
import hashlib
import base64
from dotenv import load_dotenv
from datetime import datetime
import random
import string

load_dotenv()

def get_withdrawal_fee(asset, network, address, memo, quantity, external_fee):
    api_key = os.getenv('API_KEY')
    secret_key = os.getenv('API_SECRET').encode('utf-8')
    timestamp = datetime.utcnow().isoformat()
    nonce = ''.join(random.choices(string.ascii_lowercase + string.digits, k=16))
    verb = 'GET'
    path = 'api.ox.fun'
    method = '/v3/withdrawal-fee'
    body = f'asset={asset}&network={network}&address={address}&quantity={quantity}&externalFee={external_fee}'
    msg_string = f'{timestamp}\n{nonce}\n{verb}\n{path}\n{method}\n{body}'
    sign = base64.b64encode(hmac.new(secret_key, msg_string.encode('utf-8'), hashlib.sha256).digest()).decode('utf-8')

    try:
        response = requests.get(f'https://{path}{method}?{body}', headers={
            'Content-Type': 'application/json',
            'AccessKey': api_key,
            'Timestamp': timestamp,
            'Signature': sign,
            'Nonce': nonce
        })

        if response.json().get('success'):
            print('Withdrawal Fee Data:', response.json().get('data'))
        else:
            print('Failed to fetch withdrawal fee data')
    except requests.exceptions.RequestException as error:
        print('Error making API request:', error)

# Example usage
withdrawal_wallet = os.getenv('WITHDRAW_ADDRESS')
if not withdrawal_wallet:
    print('WITHDRAW_ADDRESS environment variable is not set.')
else:
    get_withdrawal_fee('OX', 'Solana', withdrawal_wallet, '', '100.0', True)
Javascript
require('dotenv').config();
const axios = require('axios');
const CryptoJS = require("crypto-js");

async function getWithdrawalFee(asset, network, address, memo, quantity, externalFee) {
  const apiKey = process.env.API_KEY;
  const secretKey = process.env.API_SECRET;
  const timestamp = new Date().toISOString();
  const nonce = Math.random().toString(36).substring(2);
  const verb = 'GET';
  const path = 'api.ox.fun';
  const method = '/v3/withdrawal-fee';
  const body = `asset=${asset}&network=${network}&address=${address}&quantity=${quantity}&externalFee=${externalFee}`;
  const msgString = `${timestamp}\n${nonce}\n${verb}\n${path}\n${method}\n${body}`;
  const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(msgString, secretKey));

  try {
    const response = await axios.get(`https://${path}${method}?${body}`, {
      headers: {
        'Content-Type': 'application/json',
        'AccessKey': apiKey,
        'Timestamp': timestamp,
        'Signature': sign,
        'Nonce': nonce
      }
    });

    if (response.data.success) {
      console.log('Withdrawal Fee Data:', response.data.data);
    } else {
      console.error('Failed to fetch withdrawal fee data');
    }
  } catch (error) {
    console.error('Error making API request:', error);
  }
}

// Example usage
const withdrawalWallet = process.env.WITHDRAW_ADDRESS;
if (!withdrawalWallet) {
  console.error('WITHDRAWAL_WALLET environment variable is not set.');
} else {
  getWithdrawalFee('OX', 'Solana', withdrawalWallet, '', '100.0', true);
}
Request Parameter
Type
Required
Description

asset

STRING

YES

network

STRING

YES

address

STRING

YES

memo

STRING

NO

Required only for 2 part addresses (tag or memo)

quantity

STRING

YES

externalFee

BOOL

NO

Default false. If false, then the fee is taken from the quantity

Response Field
Type
Description

asset

STRING

network

STRING

address

STRING

memo

STRING

Memo (tag) if applicable

quantity

STRING

externalFee

BOOL

If false, then the fee is taken from the quantity

estimatedFee

STRING

PreviousAccount & Wallet - PrivateNextMarket Data - Public

Last updated 3 months ago

🔌