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/markets
  • GET /v3/assets
  • GET /v3/tickers
  • GET /v3/funding/estimates
  • GET /v3/candles
  • GET /v3/depth
  • GET /v3/markets/operational
  • GET /v3/exchange-trades
  • GET /v3/funding/rates
  • GET /v3/leverage/tiers
  1. API
  2. REST API V3

Market Data - Public

GET /v3/markets

Get a list of markets by OX.FUN.

Curl

Python
import requests

def fetch_market_data():
    market_code = 'BTC-USD-SWAP-LIN'
    url = f'https://api.ox.fun/v3/markets?marketCode={market_code}'

    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for bad responses
        print('Market Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching market data:', error)

fetch_market_data()
Javascript
const axios = require('axios');

async function fetchMarketData() {
  const marketCode = 'BTC-USD-SWAP-LIN';
  const url = `https://api.ox.fun/v3/markets?marketCode=${marketCode}`;

  try {
    const response = await axios.get(url);
    console.log('Market Data:', response.data);
  } catch (error) {
    console.error('Error fetching market data:', error.response ? error.response.data : error.message);
  }
}

fetchMarketData();
Request Parameter
Type
Required
Description

marketCode

STRING

YES

Response Field
Type
Description

marketCode

STRING

Market Code

name

STRING

Name of the contract

referencePair

STRING

Reference pair

base

STRING

Base asset

counter

STRING

Counter asset

type

STRING

Type of the contract

tickSize

STRING

Tick size of the contract

minSize

STRING

Minimum tradable quantity and quantity increment

listedAt

STRING

Listing date of the contract

settlementAt

STRING

Timestamp of settlement if applicable i.e. Quarterlies and Spreads

upperPriceBound

STRING

Sanity bound

lowerPriceBound

STRING

Sanity bound

markPrice

STRING

Mark price

indexPrice

STRING

index price

lastUpdatedAt

STRING

GET /v3/assets

Get a list of assets supported by OX.FUN

Curl

Request

GET /v3/assets?asset={asset}

Successful response format

{
    "success": true,
    "data": [
        {
            "asset": "OX",
            "isCollateral": true,
            "loanToValue": "1.000000000",
            "loanToValueFactor": "0",
            "networkList": [
                {
                    "network": "ERC20",
                    "transactionPrecision": "6",
                    "isWithdrawalFeeChargedToUser": true,
                    "canDeposit": true,
                    "canWithdraw": true,
                    "minDeposit": "0.0001",
                    "minWithdrawal": "1"
                }
            ]
        },
        {
            "asset": "LINK",
            "isCollateral": false,
            "networkList": [
                {
                    "network": "ERC20",
                    "tokenId": "0x514910771af9ca656af840dff83e8264ecf986ca",
                    "transactionPrecision": "18",
                    "isWithdrawalFeeChargedToUser": true,
                    "canDeposit": true,
                    "canWithdraw": true,
                    "minDeposit": "0.0001",
                    "minWithdrawal": "0.0001"
                }
            ]
        }
    ]
}

Python
import requests

def fetch_assets_data():
    asset = 'BTC'
    url = f'https://api.ox.fun/v3/assets?asset={asset}'

    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for bad responses
        print('Assets Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching assets data:', error)

fetch_assets_data()
Javascript
const axios = require('axios');

async function fetchMarketData() {
  const asset = 'BTC';
  const url = `https://api.ox.fun/v3/assets?asset=${asset}`;

  try {
    const response = await axios.get(url);
    console.log('Market Data:', response.data);
  } catch (error) {
    console.error('Error fetching market data:', error.response ? error.response.data : error.message);
  }
}

fetchMarketData();
Request Parameter
Type
Required
Description

asset

STRING

YES

Asset name

Response Field
Type
Description

asset

STRING

Asset name

isCollateral

BOOL

Indicates if the asset can be used as collateral to trade perps

loanToValue

STRING

Ignore

loanToValueFactor

STRING

Ignore

networkList

LIST

List of dictionaries

network

STRING

Network for deposit and withdrawal

tokenId

STRING

Token ID

transactionPrecision

STRING

Precision for the transaction

isWithdrawalFeeChargedToUser

BOOL

Indicates if there is a withdrawal fee

canDeposit

BOOL

Indicates can deposit or not

canWithdraw

BOOL

Indicates can withdraw or not

minDeposit

STRING

Minimum deposit amount

minWithdrawal

STRING

Minimum withdrawal amount

GET /v3/tickers

Get tickers.

Curl

Request

GET /v3/tickers?marketCode={marketCode}

Successful response format

{
    "success": true,
    "data": [
        {
            "marketCode": "BTC-USD-SWAP-LIN",
            "markPrice": "41512.4",
            "open24h": "41915.3",
            "high24h": "42662.2",
            "low24h": "41167.0",
            "volume24h": "22206.50440",
            "currencyVolume24h": "0.004780",
            "openInterest": "0.001300",
            "lastTradedPrice": "41802.5",
            "lastTradedQuantity": "0.001",
            "lastUpdatedAt": "1642585256002"
        }
    ]
}

Python
import requests

def fetch_ticker_data(market_code):
    url = f'https://api.ox.fun/v3/tickers?marketCode={market_code}'

    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for bad responses
        print('Ticker Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching ticker data:', error)

# Example usage
fetch_ticker_data('BTC-USD-SWAP-LIN') 
Javascript
const axios = require('axios');

async function fetchTickerData(marketCode) {
  const url = `https://api.ox.fun/v3/tickers?marketCode=${marketCode}`;

  try {
    const response = await axios.get(url);
    console.log('Ticker Data:', response.data);
  } catch (error) {
    console.error('Error fetching ticker data:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchTickerData('BTC-USD-SWAP-LIN'); 

Request Parameter
Type
Required
Description

marketCode

STRING

NO

Market code

Response Field
Type
Description

marketCode

STRING

Market code

markPrice

STRING

Mark price

open24h

STRING

Rolling 24 hour opening price

high24h

STRING

Rolling 24 hour highest price

low24h

STRING

Rolling 24 hour lowest price

volume24h

STRING

Rolling 24 hour notional trading volume in OX terms

currencyVolume24h

STRING

Rolling 24 hour trading volume in Contracts

openInterest

STRING

Open interest in Contracts

lastTradedPrice

STRING

Last traded price

lastTradedQuantity

STRIN

Last traded quantity

lastUpdatedAt

STRING

Millisecond timestamp of lastest update

GET /v3/funding/estimates

Curl

Request

GET /v3/funding/estimates?marketCode={marketCode}

Successful response format

{
    "success": true,
    "data": [
        {
            "marketCode": "ETH-USD-SWAP-LIN",
            "fundingAt": "1667012400000",
            "estFundingRate": "0"
        },
        {
            "marketCode": "BTC-USD-SWAP-LIN",
            "fundingAt": "1667012400000",
            "estFundingRate": "0"
        }
    ]
}

Python
import requests

def fetch_funding_estimates(market_code):
    url = f'https://api.ox.fun/v3/funding/estimates?marketCode={market_code}'

    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for bad responses
        print('Funding Estimates:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching funding estimates:', error)

# Example usage
fetch_funding_estimates('BTC-USD-SWAP-LIN')
Javascript
const axios = require('axios');

async function fetchFundingEstimates(marketCode) {
  const url = `https://api.ox.fun/v3/funding/estimates?marketCode=${marketCode}`;

  try {
    const response = await axios.get(url);
    console.log('Funding Estimates:', response.data);
  } catch (error) {
    console.error('Error fetching funding estimates:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchFundingEstimates('BTC-USD-SWAP-LIN'); 

Request Parameter
Type
Required
Description

marketCode

STRING

NO

Market code

Response Field
Type
Description

marketCode

STRING

Market code

estFundingRate

STRING

Estimates funding rate

fundingAt

STRING

Millisecond timestamp

GET /v3/candles

Get candles.

Curl

Request

GET /v3/candles?marketCode={marketCode}&timeframe={timeframe}&limit={limit}
&startTime={startTime}&endTime={endTime}

Successful response format

{
    "success": true, 
    "timeframe": "3600s", 
    "data": [
        {
            "open": "35888.80000000", 
            "high": "35925.30000000", 
            "low": "35717.00000000", 
            "close": "35923.40000000", 
            "volume": "0",
            "currencyVolume": "0",
            "openedAt": "1642932000000"
        },
        {
            "open": "35805.50000000", 
            "high": "36141.50000000", 
            "low": "35784.90000000", 
            "close": "35886.60000000", 
            "volume": "0",
            "currencyVolume": "0",
            "openedAt": "1642928400000"
        }
    ]
}

Python
import requests
import time

def fetch_candle_data(market_code, timeframe='3600s', limit=100):
    # Validate the timeframe
    valid_timeframes = ['60s', '300s', '900s', '1800s', '3600s', '7200s', '14400s', '86400s']
    if timeframe not in valid_timeframes:
        print('Invalid timeframe. Please use one of the following:', ', '.join(valid_timeframes))
        return

    # Calculate startTime as 24 hours ago
    start_time = int(time.time() * 1000) - 24 * 60 * 60 * 1000  # 24 hours in milliseconds

    # Calculate endTime as the current time
    end_time = int(time.time() * 1000)

    url = f'https://api.ox.fun/v3/candles?marketCode={market_code}&timeframe={timeframe}&limit={limit}&startTime={start_time}&endTime={end_time}'

    try:
        response = requests.get(url)
        response.raise_for_status()
        print('Candle Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching candle data:', error)

# Example usage
fetch_candle_data('BTC-USD-SWAP-LIN', '3600s', 100)
Javascript
const axios = require('axios');

async function fetchCandleData(marketCode, timeframe = '3600s', limit) {
  // Validate the timeframe
  const validTimeframes = ['60s', '300s', '900s', '1800s', '3600s', '7200s', '14400s', '86400s'];
  if (!validTimeframes.includes(timeframe)) {
    console.error('Invalid timeframe. Please use one of the following:', validTimeframes.join(', '));
    return;
  }

  // Calculate startTime as 24 hours ago
  const startTime = Date.now() - 24 * 60 * 60 * 1000; // 24 hours in milliseconds

  // Calculate endTime as the current time
  const endTime = Date.now();

  const url = `https://api.ox.fun/v3/candles?marketCode=${marketCode}&timeframe=${timeframe}&limit=${limit}&startTime=${startTime}&endTime=${endTime}`;

  try {
    const response = await axios.get(url);
    console.log('Candle Data:', response.data);
  } catch (error) {
    console.error('Error fetching candle data:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchCandleData('BTC-USD-SWAP-LIN', '3600s', 100); 
Request Parameter
Type
Required
Description

marketCode

STRING

YES

Market code

timeframe

STRING

NO

Available values: 60s,300s,900s,1800s,3600s,7200s,14400s,86400s, default is 3600s

limit

LONG

NO

Default 200, max 500

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

timeframe

STRING

Available values: 60s,300s,900s,1800s,3600s,7200s,14400s,86400s

open

STRING

Opening price

high

STRING

Highest price

low

STRING

Lowest price

close

STRING

Closing price

volume

STRING

Trading volume in OX terms

currencyVolume

STRING

Trading volume in Contract terms

openedAt

STRING

Millisecond timestamp of the candle open

GET /v3/depth

Get depth.

Curl

Request

GET /v3/depth?marketCode={marketCode}&level={level}

Successful response format

{
    "success": true, 
    "level": "5", 
    "data": {
        "marketCode": "BTC-USD-SWAP-LIN", 
        "lastUpdatedAt": "1643016065958", 
        "asks": [
            [
                39400, 
                0.261
            ], 
            [
                41050.5, 
                0.002
            ], 
            [
                41051, 
                0.094
            ], 
            [
                41052.5, 
                0.002
            ], 
            [
                41054.5, 
                0.002
            ]
        ], 
        "bids": [
            [
                39382.5, 
                0.593
            ], 
            [
                39380.5, 
                0.009
            ], 
            [
                39378, 
                0.009
            ], 
            [
                39375.5, 
                0.009
            ], 
            [
                39373, 
                0.009
            ]
        ]
    }
}

Python
import requests

def fetch_market_depth(market_code, level):
    url = f'https://api.ox.fun/v3/depth?marketCode={market_code}&level={level}'

    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for bad responses
        print('Market Depth Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching market depth data:', error)

# Example usage
fetch_market_depth('BTC-USD-SWAP-LIN', 10)
Javascript
const axios = require('axios');

async function fetchMarketDepth(marketCode, level) {
  const url = `https://api.ox.fun/v3/depth?marketCode=${marketCode}&level=${level}`;

  try {
    const response = await axios.get(url);
    console.log('Market Depth Data:', response.data);
  } catch (error) {
    console.error('Error fetching market depth data:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchMarketDepth('BTC-USD-SWAP-LIN', 10);

Request Parameter
Type
Required
Description

marketCode

STRING

YES

Market code

level

LONG

NO

Default 5, max 100

Response Field
Type
Description

level

LONG

Level

marketCode

STRING

Market code

lastUpdatedAt

STRING

Millisecond timestamp of the lastest depth update

asks

LIST of floats

Sell side depth: [price, quantity]

bids

LIST of floats

Buy side depth: [price, quantity]

GET /v3/markets/operational

Get markets operational.

Curl

Request

GET /v3/markets/operational?marketCode={marketCode}

Successful response format

{
    "success": true,
    "data": {
        "marketCode": "BTC-USD-SWAP-LIN",
        "operational": true
    }
}

Python
import requests

def fetch_operational_market_data(market_code):
    url = f'https://api.ox.fun/v3/markets/operational?marketCode={market_code}'

    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for bad responses
        print('Operational Market Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching operational market data:', error)

# Example usage
fetch_operational_market_data('BTC-USD-SWAP-LIN')
Javascript
const axios = require('axios');

async function fetchOperationalMarketData(marketCode) {
  const url = `https://api.ox.fun/v3/markets/operational?marketCode=${marketCode}`;

  try {
    const response = await axios.get(url);
    console.log('Operational Market Data:', response.data);
  } catch (error) {
    console.error('Error fetching operational market data:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchOperationalMarketData('BTC-USD-SWAP-LIN');
Request Parameter
Type
Required
Description

marketCode

STRING

YES

Market code

Response Field
Type
Description

marketCode

STRING

Market code

operational

BOOL

whether the market of the marketCode is operational

GET /v3/exchange-trades

Curl

Request

GET /v3/exchange-trades?marketCode={marketCode}&limit={limit}&startTime={startTime}&endTime={endTime}

Successful response format

{
    "success": true,
    "data": [
        {
            "marketCode": "BTC-USD-SWAP-LIN",
            "matchPrice": "9600.00000" ,
            "matchQuantity": "0.100000" ,
            "side": "BUY" ,
            "matchType": "TAKER" ,
            "matchedAt": "1662207330439" 
        }
    ]
}

Python
import requests
import time

def fetch_exchange_trades(market_code, limit=100):
    # Calculate startTime as 24 hours ago
    start_time = int(time.time() * 1000) - 24 * 60 * 60 * 1000  # 24 hours in milliseconds

    # Calculate endTime as the current time
    end_time = int(time.time() * 1000)

    url = f'https://api.ox.fun/v3/exchange-trades?marketCode={market_code}&limit={limit}&startTime={start_time}&endTime={end_time}'

    try:
        response = requests.get(url)
        response.raise_for_status()
        print('Exchange Trades Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching exchange trades data:', error)

# Example usage
fetch_exchange_trades('BTC-USD-SWAP-LIN', 100)
Javascript
const axios = require('axios');

async function fetchExchangeTrades(marketCode, limit = 100) {
  // Calculate startTime as 24 hours ago
  const startTime = Date.now() - 24 * 60 * 60 * 1000; // 24 hours in milliseconds

  // Calculate endTime as the current time
  const endTime = Date.now();

  const url = `https://api.ox.fun/v3/exchange-trades?marketCode=${marketCode}&limit=${limit}&startTime=${startTime}&endTime=${endTime}`;

  try {
    const response = await axios.get(url);
    console.log('Exchange Trades Data:', response.data);
  } catch (error) {
    console.error('Error fetching exchange trades data:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchExchangeTrades('BTC-USD-SWAP-LIN', 100);
Request Parameter
Type
Required
Description

marketCode

STRING

NO

Market code

limit

LONG

NO

Default 200, max 500

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

marketCode

STRING

matchPrice

STRING

matchQuantity

STRING

side

STRING

matchType

STRING

matchedAt

STRING

GET /v3/funding/rates

Get all historical funding rates

Curl

Request

GET /v3/funding/rates?marketCode={marketCode}&limit={limit}&startTime={startTime}&endTime={endTime}

Successful response format

{
    "success": true,
    "data": [
        {
            "marketCode": "BTC-USD-SWAP-LIN",
            "fundingRate": "0.0",
            "createdAt": "1628362803134"
        }
    ]
}

Python
import requests
import time

def fetch_funding_rates(market_code, limit=100):
    # Calculate startTime as 24 hours ago
    start_time = int(time.time() * 1000) - 24 * 60 * 60 * 1000  # 24 hours in milliseconds

    # Calculate endTime as the current time
    end_time = int(time.time() * 1000)

    url = f'https://api.ox.fun/v3/funding/rates?marketCode={market_code}&limit={limit}&startTime={start_time}&endTime={end_time}'

    try:
        response = requests.get(url)
        response.raise_for_status()
        print('Funding Rates Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching funding rates data:', error)

# Example usage
fetch_funding_rates('BTC-USD-SWAP-LIN', 100)
Javascript
const axios = require('axios');

async function fetchFundingRates(marketCode, limit = 100) {
  // Calculate startTime as 24 hours ago
  const startTime = Date.now() - 24 * 60 * 60 * 1000; // 24 hours in milliseconds

  // Calculate endTime as the current time
  const endTime = Date.now();

  const url = `https://api.ox.fun/v3/funding/rates?marketCode=${marketCode}&limit=${limit}&startTime=${startTime}&endTime=${endTime}`;

  try {
    const response = await axios.get(url);
    console.log('Funding Rates Data:', response.data);
  } catch (error) {
    console.error('Error fetching funding rates data:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchFundingRates('BTC-USD-SWAP-LIN', 100);

Request Parameter
Type
Required
Description

marketCode

STRING

NO

Market code

limit

LONG

NO

Default 200, max 500

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

marketCode

STRING

Market code

fundingRate

STRING

Funding rate

createdAt

STRING

Millisecond timestamp

GET /v3/leverage/tiers

Get markets leverage tiers

Curl

Request

GET  /v3/leverage/tiers?marketCode={marketCode}

Successful response format

{
    "success": true,
    "data": [
        {
            "marketCode": "BTC-USD-SWAP-LIN",
            "tiers": [
                {
                    "tier": 1,
                    "leverage": "10",
                    "positionFloor": "0",
                    "positionCap": "100",
                    "initialMargin": "0.1",
                    "maintenanceMargin": "0.05"
                },
                {
                    "tier": 2,
                    "leverage": "5",
                    "positionFloor": "100",
                    "positionCap": "250",
                    "initialMargin": "0.2",
                    "maintenanceMargin": "0.1"
                },
                {
                    "tier": 3,
                    "leverage": "4",
                    "positionFloor": "250",
                    "positionCap": "1000",
                    "initialMargin": "0.25",
                    "maintenanceMargin": "0.125"
                }
            ]
        }
    ]
}

Python
import requests

def fetch_leverage_tiers(market_code):
    url = f'https://api.ox.fun/v3/leverage/tiers?marketCode={market_code}'

    try:
        response = requests.get(url)
        response.raise_for_status()
        print('Leverage Tiers Data:', response.json())
    except requests.exceptions.RequestException as error:
        print('Error fetching leverage tiers data:', error)

# Example usage
fetch_leverage_tiers('BTC-USD-SWAP-LIN')
Javascript
const axios = require('axios');

async function fetchLeverageTiers(marketCode) {
  const url = `https://api.ox.fun/v3/leverage/tiers?marketCode=${marketCode}`;

  try {
    const response = await axios.get(url);
    console.log('Leverage Tiers Data:', response.data);
  } catch (error) {
    console.error('Error fetching leverage tiers data:', error.response ? error.response.data : error.message);
  }
}

// Example usage
fetchLeverageTiers('BTC-USD-SWAP-LIN');
Request Parameter
Type
Required
Description

marketCode

STRING

NO

Market code

Response Field
Type
Description

marketCode

STRING

Market code

tier

STRING

Leverage tier

leverage

STRING

Market leverage

positionFloor

STRING

The lower position limit

positionCap

STRING

The upper position limit

initialMargin

STRING

Initial margin

maintenanceMargin

STRING

Maintenance margin

PreviousDeposits & Withdrawals - PrivateNextOrders - Private

Last updated 3 months ago

🔌