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
  1. API
  2. Websocket API
  3. Subscriptions - Public

Full Order Book

Channel Update Frequency: 100ms

This order book depth channel sends a snapshot of the entire order book every 100ms.

Curl

Request format

{
  "op": "subscribe",
  "tag": 103,
  "args": ["depth:BTC-USD-SWAP-LIN"]
}

Success response format

{
    "success": true,
    "tag": "103",
    "event": "subscribe",
    "channel": "depth:BTC-USD-SWAP-LIN",
    "timestamp": "1665454814275"
}

Order book depth channel format

{
    "table": "depth",
    "data": {
        "seqNum": 2166539633781384,
        "asks": [
            [
                19024.0,
                1.0
            ],
            [
                19205.0,
                4.207
            ],
            [
                19395.0,
                8.414
            ]
        ],
        "bids": [
            [
                18986.0,
                1.0
            ],
            [
                18824.0,
                4.207
            ],
            [
                18634.0,
                8.414
            ]
        ],
        "checksum": 3475315026,
        "marketCode": "BTC-USD-SWAP-LIN",
        "timestamp": 1665454814328
    },
    "action": "partial"
}
Python
import websockets
import asyncio
import json

orderbook_depth = \
{
  "op": "subscribe",
  "tag": 103,
  "args": ["depthL10:BTC-USD-SWAP-LIN"]
}

url= 'wss://api.ox.fun/v2/websocket'
async def subscribe():
    async with websockets.connect(url) as ws:
        while True:
            if not ws.open:
                print("websocket disconnected")
                ws = await websockets.connect(url)
            response = await ws.recv()
            data = json.loads(response)
            print(data)
            if 'nonce' in data:
                await ws.send(json.dumps(orderbook_depth))
            elif 'success' in data and data['success'] == 'True':
                continue
asyncio.get_event_loop().run_until_complete(subscribe())

Request Parameters

Parameters
Type
Required
Description

op

STRING

Yes

subscribe

tag

INTEGER or STRING

No

If given it will be echoed in the reply and the max size of tag is 32

args

LIST

Yes

List of individual markets <depth>:<marketCode> e.g: [depth:BTC-USD-SWAP-LIN]

Channel Update Fields

Fields
Type
Description

table

STRING

depth

data

DICTIONARY

seqNum

INTEGER

Sequence number of the order book snapshot

asks

LIST of floats

Sell side depth;

  1. price

  2. quantity

bids

LIST of floats

Buy side depth;

  1. price

  2. quantity

checksum

INTEGER

checksum

marketCode

STRING

marketCode

timestamp

INTEGER

Millisecond timestamp

action

STRING

PreviousFixed Size Order BookNextIncremental Order Book

Last updated 3 months ago

☁️