Orderbook

This document provides example request and subscription payloads for receiving order book data via WebSocket.

Request Message Format

To request trade data, after establishing the WebSocket connection, you must create a JSON object with the structure below and include it as a Data Type Object in the request message. For the full WebSocket data request message specification including Ticket and Format fields, please refer to the WebSocket Usage Guide document.

Field Name Type Description Required Default Value
type String orderbook Required
codes List<String> List of trading pairs to receive.
Must be requested in uppercase.
Required
is_only_snapshot Boolean Provide snapshot orderbook data only Optional false
is_only_realtime Boolean Provide real-time orderbook data only Optional false
Check the proper endpoint based on your region.
The examples in this page is written using Singapore fiat code(SGD). Set the quote currency to match your region. The base_url differs by country/region. Make sure to specify the correct region value for your environment.

Quotation
- Singapore (sg): wss://sg-api.upbit.com/websocket/v1
- Indonesia (id): wss://id-api.upbit.com/websocket/v1
- Thailand (th): wss://th-api.upbit.com/websocket/v1

Exchange
- Singapore (sg): wss://sg-api.upbit.com/websocket/v1/private
- Indonesia (id): wss://id-api.upbit.com/websocket/v1/private
- Thailand (th): wss://th-api.upbit.com/websocket/v1/private
ℹ️ Custom function for Orderbook Unit quantity is added

You can adjust the quantity of Orderbook Units only for orderbook-type packets. Please input the market code and unit quantity as follows.

Format: {code}.{count}

Example: SGD-BTC.5, SGD-ETH.5

Supported values for count: 1, 5, 15, 30

If an unsupported value is specified, it defaults to 30.


Examples

[
  {
    "ticket": "test"
  },
  {
    "type": "orderbook",
    "codes": ["SGD-BTC","SGD-ETH"]
  },
  {
    "format": "DEFAULT"
  }
]
[
  {
    "ticket": "test"
  },
  {
    "type": "orderbook",
    "codes": ["SGD-BTC","SGD-ETH"]
  },
  {
    "format": "SIMPLE_LIST"
  }
]

Subscription Data Specification

The current price snapshot or real-time stream data is returned as follows.

Field Name Abbreviation Description Type Example Value
typetyTypeStringorderbook
codecdTrading pair codeStringSGD-BTC
total_ask_sizetasTotal ask sizeDouble
total_bid_sizetbsTotal bid sizeDouble
orderbook_unitsobuOrderbook unitsList of Objects
orderbook_units.ask_priceobu.apThe lowest sell (ask) price in the orderbookDouble
orderbook_units.bid_priceobu.bpThe highest buy (bid) price in the orderbookDouble
orderbook_units.ask_sizeobu.asSell (ask) quantity at the corresponding ask priceDouble
orderbook_units.bid_sizeobu.bsBuy (bid) quantity at the corresponding bid priceDouble
timestamptmsTimestamp (ms)Long
stream_typestStream typeStringSNAPSHOT
: Snapshot
REALTIME
: Real-time

Examples

[
  {
    "type": "orderbook",
    "code": "SGD-BTC",
    "timestamp": 1746602359173,
    "total_ask_size": 0.68780013,
    "total_bid_size": 0.78754733,
    "orderbook_units": [
      {
        "ask_price": 125056.0,
        "bid_price": 124743.0,
        "ask_size": 0.17,
        "bid_size": 0.17
      },
      {
        "ask_price": 125207.0,
        "bid_price": 124332.0,
        "ask_size": 0.09,
        "bid_size": 0.09
      },
      {
        "ask_price": 125416.0,
        "bid_price": 124167.0,
        "ask_size": 0.2,
        "bid_size": 0.2
      },
      {
        "ask_price": 126661.0,
        "bid_price": 122917.0,
        "ask_size": 0.01210697,
        "bid_size": 0.01844114
      },
      {
        "ask_price": 126786.0,
        "bid_price": 122716.0,
        "ask_size": 0.01142233,
        "bid_size": 0.0175997
      },
      {
        "ask_price": 126997.0,
        "bid_price": 122577.0,
        "ask_size": 0.01442522,
        "bid_size": 0.02204438
      },
      {
        "ask_price": 127288.0,
        "bid_price": 122283.0,
        "ask_size": 0.0139072,
        "bid_size": 0.02114427
      },
      {
        "ask_price": 127451.0,
        "bid_price": 122002.0,
        "ask_size": 0.01378211,
        "bid_size": 0.0203521
      },
      {
        "ask_price": 127946.0,
        "bid_price": 121665.0,
        "ask_size": 0.0128153,
        "bid_size": 0.01977116
      },
      {
        "ask_price": 127970.0,
        "bid_price": 121504.0,
        "ask_size": 0.0084267,
        "bid_size": 0.0129707
      },
      {
        "ask_price": 128351.0,
        "bid_price": 121372.0,
        "ask_size": 0.00766313,
        "bid_size": 0.04750075
      },
      {
        "ask_price": 128649.0,
        "bid_price": 121263.0,
        "ask_size": 0.00716242,
        "bid_size": 0.0123517
      },
      {
        "ask_price": 128849.0,
        "bid_price": 120969.0,
        "ask_size": 0.00690843,
        "bid_size": 0.01155361
      },
      {
        "ask_price": 128956.0,
        "bid_price": 120643.0,
        "ask_size": 0.00732903,
        "bid_size": 0.01096038
      },
      {
        "ask_price": 129000.0,
        "bid_price": 120436.0,
        "ask_size": 0.03875968,
        "bid_size": 0.01039539
      },
      {
        "ask_price": 129066.0,
        "bid_price": 120095.0,
        "ask_size": 0.00655781,
        "bid_size": 0.01010256
      },
      {
        "ask_price": 129228.0,
        "bid_price": 119824.0,
        "ask_size": 0.00684494,
        "bid_size": 0.00948499
      },
      {
        "ask_price": 129231.0,
        "bid_price": 119618.0,
        "ask_size": 0.00626955,
        "bid_size": 0.00903197
      },
      {
        "ask_price": 129515.0,
        "bid_price": 119279.0,
        "ask_size": 0.00595153,
        "bid_size": 0.00853212
      },
      {
        "ask_price": 129579.0,
        "bid_price": 119120.0,
        "ask_size": 0.0064701,
        "bid_size": 0.00172935
      },
      {
        "ask_price": 130312.0,
        "bid_price": 118969.0,
        "ask_size": 0.00553463,
        "bid_size": 0.0080544
      },
      {
        "ask_price": 130535.0,
        "bid_price": 118613.0,
        "ask_size": 0.00450619,
        "bid_size": 0.00770287
      },
      {
        "ask_price": 130797.0,
        "bid_price": 118290.0,
        "ask_size": 0.00413189,
        "bid_size": 0.00712616
      },
      {
        "ask_price": 131288.0,
        "bid_price": 118107.0,
        "ask_size": 0.00452539,
        "bid_size": 0.00674375
      },
      {
        "ask_price": 131399.0,
        "bid_price": 117808.0,
        "ask_size": 0.00369111,
        "bid_size": 0.00658978
      },
      {
        "ask_price": 131510.0,
        "bid_price": 117595.0,
        "ask_size": 0.00417261,
        "bid_size": 0.0060327
      },
      {
        "ask_price": 131727.0,
        "bid_price": 117300.0,
        "ask_size": 0.00342738,
        "bid_size": 0.00566733
      },
      {
        "ask_price": 131821.0,
        "bid_price": 117156.0,
        "ask_size": 0.00392284,
        "bid_size": 0.00538776
      },
      {
        "ask_price": 131867.0,
        "bid_price": 116805.0,
        "ask_size": 0.00326427,
        "bid_size": 0.00533339
      },
      {
        "ask_price": 132107.0,
        "bid_price": 116593.0,
        "ask_size": 0.00382137,
        "bid_size": 0.00494292
      }
    ],
    "stream_type": "SNAPSHOT"
  }
]
 [
  {
    "ty": "orderbook",
    "cd": "SGD-BTC",
    "tms": 1749471183353,
    "tas": 0.74160598,
    "tbs": 0.72452668,
    "obu": [
      {
        "ap": 138696,
        "bp": 138349,
        "as": 0.17,
        "bs": 0.17
      },
      {
        "ap": 138948,
        "bp": 138025,
        "as": 0.09,
        "bs": 0.09
      },
      {
        "ap": 139274,
        "bp": 137887,
        "as": 0.2,
        "bs": 0.2
...
    "st": "SNAPSHOT"
  }
]