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

Incremental Order Book

Channel Update Frequency: 100ms

Incremental order book stream

Usage Instructions: 1. Connect to websocket wss://api.ox.fun/v2/websocket 2. Subscribe to depthUpdate and you will get a message reply saying your subscription is successful 3. Afterwards you will get a snapshot of the book with table:depthUpdate 4. If you receive a reply with table:depthUpdate-diff first, keep it locally and wait for snapshot reply in step 3 5. The first incremental depthUpdate-diff message should have the same seqNum as the depthUpdate snapshot 6. After that, each new incremental update should have an incrementally larger seqNum to the previous update 7. The data in each event represents the absolute quantity for a price level. 8. If the quantity is 0, remove the price level.

Curl

Request format

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

Success response format

{
    "success": true,
    "tag": "test1",
    "event": "subscribe",
    "channel": "depthUpdate:BTC-USD-SWAP-LIN",
    "timestamp": "1665456142779"
}

** depth update channel format**

{
    "table": "depthUpdate-diff",
    "data": {
        "seqNum": 2166539633794590,
        "asks": [],
        "bids": [],
        "checksum": 364462986,
        "marketCode": "BTC-USD-SWAP-LIN",
        "timestamp": "1665456142843"
    },
    "action": "increment"
}
{
    "table": "depthUpdate",
    "data": {
        "seqNum": 2166539633794591,
        "asks": [
            [
                19042.0,
                1.0
            ]
        ],
        "bids": [
            [
                19003.0,
                1.0
            ]
        ],
        "checksum": 2688268653,
        "marketCode": "BTC-USD-SWAP-LIN",
        "timestamp": "1665456142843"
    },
    "action": "partial"
}

Request Parameters

Parameters
Type
Required
Description

op

STRING

Yes

subscribe

tag

INTEGER or STRING

No

If given it will be echoed in the reply

args

LIST

Yes

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

Channel Update Fields

Fields
Type
Description

table

STRING

depthUpdate-diff depthUpdate

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

marketCode

STRING

marketCode

checksum

LONG

timestamp

STRING

Millisecond timestamp

action

STRING

partial increment

PreviousFull Order BookNextBest Bid/Ask

Last updated 6 months ago

☁️