# Websocket Stream

#### Overview： <a href="#overview" id="overview"></a>

The WebSocket connection enables full-duplex communication between the client and the server, allowing data to be transmitted quickly in both directions.

#### Connect <a href="#connect" id="connect"></a>

**Base URL for the WebSocket :** wss\://stream.jayxstaging.com:8443

#### Subscription Events <a href="#subscription-events" id="subscription-events"></a>

1. **kline**\
   **Event**: kline\
   **Message**:&#x20;

   `{ "category": "spot", "symbol": "BTCUSDT", "interval": "60" }`

**Response Parameters**

| **Parameter** | **Comments**                                             |
| ------------- | -------------------------------------------------------- |
| \_id          | Unique identifier for the K-Line data entry              |
| `symbol`      | The trading pair symbol (e.g., BTCUSDT for Bitcoin/USDT) |
| o             | Open price of the K-Line.                                |
| h             | High price of the K-Line.                                |
| l             | Low price of the K-Line.                                 |
| c             | Close price of the K-Line                                |
| v             | Volume traded during the K-Line period.                  |
| m             | The timestamp of the last modification                   |

**Response Example**

```json
{
  "add": null,
  "modify": {
    "_id": "664a16fccb5c1735c25557a0",
    "created": 1716131580,
    "o": 6678147,
    "h": 6690062,
    "l": 6674783,
    "c": 6689523,
    "v": 241690,
    "m": 1716131619,
    "symbol": "BTCUSDT"
  }
}
```

&#x20;

2. **orderbook**\
   **Event**: orderbook\
   **Message**: `{ "category": "spot", "symbol": "BTCUSDT", "precise": "1" }`

   **Response Parameters**

| **Parameter** | **Comments**                               |
| ------------- | ------------------------------------------ |
| **orderBook** | Object containing `asks` and `bids` arrays |
| asks          | Array of ask orders                        |
| bids          | Array of bid orders                        |
| lots          | Tick size of the order                     |
| count         | Count of the orders                        |
| **trades**    | Array of trade orders                      |
| lots          | Lot size of the trade                      |
| ticks         | Tick size of the trade                     |
| side          | Side of the trade (e.g., BUY, SELL)        |
| created       | Timestamp when the trade was created       |

**Response Example**

```json
{
  "orderBook": {
    "asks": [
      {
        "ticks": 6684363,
        "lots": 1004817,
        "count": 1
      },
      {
        "ticks": 6751207,
        "lots": 2993562,
        "count": 1
      },
      {
        "ticks": 6818050,
        "lots": 4992059,
        "count": 1
      }
    ],
    "bids": [
      {
        "ticks": 6657678,
        "lots": 997207,
        "count": 1
      },
      {
        "ticks": 6591101,
        "lots": 2989353,
        "count": 1
      },
      {
        "ticks": 6524524,
        "lots": 4989821,
        "count": 1
      }
    ]
  },
  "trades": [
    {
      "lots": 3779,
      "ticks": 6667418,
      "side": "BUY",
      "created": 1716136436758
    },
    {
      "lots": 591,
      "ticks": 6670338,
      "side": "BUY",
      "created": 1716136436747
    },
    {
      "lots": 1510,
      "ticks": 6664049,
      "side": "BUY",
      "created": 1716136436745
    }
  ]
}
```

3. positions\
   **Event**: positions\
   **Message**:&#x20;

   `{ "apiKey": "clmsionk21ru", "category": "spot" }`

   **Response Parameters**

| **Parameter** | **Comments**                                   |
| ------------- | ---------------------------------------------- |
| **spot**      | Array of position objects                      |
| `asset`       | The asset name (e.g., BTC for Bitcoin)         |
| `balance`     | The total balance of the asset                 |
| `available`   | The available balance of the asset for trading |

**Response Example**

```json
{
  "spot": [
    {
      "asset": "BTC",
      "balance": "0.000998",
      "available": "0.000998"
    },
    {
      "asset": "USDT",
      "balance": "9932.44065",
      "available": "9932.44065"
    }
  ]
}
```

4. openorders
5. **Event**: openorders\
   **Message**: \
   `{ "apiKey": "clmsionk21ru", "category": "spot", "symbol": "BTCUSDT" }`

**Response Parameters**

| **Parameter** | **Comments**                                             |
| ------------- | -------------------------------------------------------- |
| `id`          | Unique identifier for the order                          |
| `symbol`      | The trading pair symbol (e.g., BTCUSDT for Bitcoin/USDT) |
| `type`        | Type of the order (e.g., LIMIT, MARKET)                  |
| `state`       | State of the order (e.g., NEW, CANCELED)                 |
| `side`        | Side of the order (e.g., BUY, SELL)                      |
| `resd`        | Reserved size                                            |
| `exec`        | Executed size                                            |
| `cost`        | Cost of the order                                        |
| `created`     | Timestamp when the order was created                     |
| `modified`    | Timestamp when the order was last modified               |
| `price`       | Price of the order                                       |
| `quantity`    | Quantity of the order                                    |

**Response Example**

```json
{ 
    "cancel": [], 
    "modify": [ { 
        "id": 117805625, 
        "type": "LIMIT", 
        "state": "NEW", 
        "side": "BUY", 
        "resd": 1000000, 
        "exec": 0, 
        "cost": 0, 
        "lastLots": null, 
        "lastTicks": null, 
        "created": 1716135452487, 
        "modified": 1716135452487, 
        "symbol": "BTCUSDT", 
        "price": "1000", 
        "quantity": "1000" 
    } ] 
}
```

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jayx.com/jayx-docs-n8rfmgwto77q5ila/api-docs/websocket-stream.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
