Orderbook

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

WebSocket Endpoint

TypeEndpoint
Publicwss://{region}-api.upbit.com/websocket/v1

Use the endpoint for your region.

RegionEndpoint
Singaporewss://sg-api.upbit.com/websocket/v1
Indonesiawss://id-api.upbit.com/websocket/v1
Thailandwss://th-api.upbit.com/websocket/v1

Request Message Format

To request announcement data, after establishing a WebSocket connection, create a JSON Object with the structure below and include it as a Data Type Object in the request message.

For the complete WebSocket request message specification, including the Ticket and Format Objects, refer to the WebSocket Usage and Error Guide.

Field NameTypeDescriptionRequiredDefault
typeStringData type to receive. Set to orderbook to receive orderbook data.Required
codesList:StringList of trading pairs to receive.
Must be requested in uppercase.
Required
is_only_snapshotBooleanProvide snapshot data onlyOptionalfalse
is_only_realtimeBooleanProvide real-time data onlyOptionalfalse
formatStringData format to receive.

DEFAULT: Default format.
SIMPLE: Simplified format with abbreviated field names.
JSON_LIST: List format.
SIMPLE_LIST: List format with abbreviated field names.
Required

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.

Subscription Data Specification

When a new announcement is published or an existing announcement is updated, real-time stream data is returned as follows.

Field NameAbbreviationDescriptionTypeValue Example
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

Subscription Request Example

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

Subscription Data Example

[
  {
    "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"
  }
]

Error Information

If an error occurs after establishing a WebSocket connection and sending a request, the response is returned in the following JSON format.

{
  "error": {
    "name": "ERROR_CODE",
    "message": "ERROR_MESSAGE"
  }
}

The main error codes that may be returned are listed below.

error.nameReasonRecommended Action
INVALID_AUTHMissing authentication information or authentication token verification failureWhen using a Private WebSocket endpoint, make sure you are connected to the correct endpoint and that the Authorization header contains a valid authentication token.
WRONG_FORMATInvalid request message formatMake sure the request message follows the WebSocket request format. Check the Object structure as well as the type and value of each field.
NO_TICKETMissing ticket fieldMake sure the request message includes a Ticket Object and the ticket field.
NO_TYPEMissing type fieldMake sure the Data Type Object includes the type field and specify the data type to subscribe to.
NO_CODESMissing codes fieldCheck whether the subscribed data type requires the codes field and specify the trading pair codes to receive.
INVALID_PARAMMissing required request field or unsupported valueMake sure all required fields are included and that each field contains a supported value.
Too Many RequestsRequest rate limit exceededWait until another request can be made, then retry. Refer to the Rate Limits section for details.
I'm a teapotRequests are temporarily restricted due to repeated Too Many Requests errorsCheck the restriction period included in the response and retry after the specified time has passed.

Rate Limits

APIs are grouped into Rate Limit groups. APIs within the same group share the same per-second request limit.

The maximum number of requests allowed per Rate Limit group may change after prior notice according to service policy, and additional restrictions may be applied depending on service conditions. For details, refer to Rate Limits.

Rate Limit GroupPolicyApplied By
websocket-connectUp to 5 connections per secondIP
websocket-messageUp to 5 messages per second and 100 messages per minuteConnection

Managing WebSocket Rate Limits

Unlike REST API responses, WebSocket does not provide the number of remaining requests. Clients should track the number of WebSocket connection attempts and data request messages they send to ensure compliance with the applicable rate limits. If a rate limit is reached, wait for an appropriate period before sending another request..