Skip to content

Ws

Quick Start

Restful API

Public Interface

User Interface

Order Interface

WebSocket API

WebSocket Introduction

Public Interface

User Interface

Order Interface

WebSocket API Introduction

  • Base URL for the wss interfaces listed here: wss://openapi.bitunix.com:443/ws-api/v1
  • Timestamps are millisecond timestamps unless otherwise noted
  • All field names and values are case sensitive.
  • websocket connections are valid for 24 hours, please be careful to handle reconnections in case of disconnection.

Request Format

WebSocket API requests must be transmitted in Json format in text frames, where a text frame message represents one request, example:

{
  "id": "2d812f20c9e1030f5551eab0e039f613",
  "method": "market.last_price",
  "params": {
    "symbol": "BTC",
    "nonce": "17832",
    "timestamp": "1724285700000",
    "apiKey": "9a25209b66004da404d9ddcb48d1e11f",
    "sign": "477eda21f570dd4e2f7392b729254d12bc2d403d1150d0b6cfdb52191267550c"
  }
}

String Explaination

Name Type Mandatory Description
id int/string/null Y Request ID, used to match the response to the corresponding request
method string Y Request Method
params object Y Request Parameter
  • id field can be any string, number, timestamp, etc., and is used to identify the request, and is returned in the response as is.
  • method field is the request method.
  • params field is the request parameters, according to the different request methods, the parameters are different, in any order.

Response Format

WebSocket API requests must be transmitted in Json format in text frames, where a text frame message represents one request, example:

  • Success example:
{
"id": "2d812f20c9e1030f5551eab0e039f613",
"code": "0",
"msg": "success",
"data": "10000.00"
}
  • Failed example:
{
"id": "2d812f20c9e1030f5551eab0e039f613",
"code": "1",
"msg": "invalid symbol",
"data": null
}

String Exmplaination

Name Types Mandatory Description
id int/string/null Y Request ID
code string Y Response code,"0" means success,others are error codes
msg string Y Response descrtiption
data object N Returns data, which varies depending on the request method and may be null

Authentication

WebSocket API requests require authentication and need to include the following fields in all request parameters:

Name Types Mandatory Description
apiKey string Y API Key
timestamp string Y Timestamp
nonce string Y Random String
sign string Y Signature String,Please refer toSignature

Connection Test

WebSocket API connection test. The test can be performed in the following ways:

{
  "id": "2d812f20c9e1030f5551eab0e039f613",
  "method": "ping",
  "params": {
    "nonce": "17832",
    "timestamp": "1724285700000",
    "apiKey": "9a25209b66004da404d9ddcb48d1e11f",
    "sign": "--signature here--"
    }
}