Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/bullish-exchange/api-docs/llms.txt

Use this file to discover all available pages before exploring further.

The Private Data WebSocket provides real-time updates for your account’s orders, trade fills, asset balances, derivatives positions, AMM instructions, and more. All data on this stream is delivered in real time and requires an authenticated connection using a JWT token.
Authenticated WebSocket connections are limited to 10 open connections per API key. New connection requests are rejected once this limit is reached.

Authentication

Connection requests use JWT_COOKIE based authentication. To generate a JWT token, follow the Generate A JWT Token flow, then pass the token as a bearer token when establishing the WebSocket connection.

Establishing a Connection

There are two modes of connection depending on whether you want data from a single trading account or multiple trading accounts.
1

Single Trading Account

Connect to the endpoint with a tradingAccountId query parameter:
/trading-api/v1/private-data?tradingAccountId=<TRADING_ACCOUNT_ID>
Then subscribe to the desired topic:
{
  "jsonrpc": "2.0",
  "type": "command",
  "method": "subscribe",
  "params": {
    "topic": "orders"
  },
  "id": "1611082473000"
}
You can also subscribe to multiple topics in a single message by combining them with +. For example, to subscribe to both assetAccounts and derivativesPositionsV2:
{
  "jsonrpc": "2.0",
  "type": "command",
  "method": "subscribe",
  "params": {
    "topic": "assetAccounts+derivativesPositionsV2"
  },
  "id": "1611082473000"
}
2

Multiple Trading Accounts

Connect to the base endpoint without a tradingAccountId parameter:
/trading-api/v1/private-data
Then send a separate subscription message for each trading account, including the tradingAccountId in the subscription params:
{
  "jsonrpc": "2.0",
  "type": "command",
  "method": "subscribe",
  "params": {
    "topic": "orders",
    "tradingAccountId": "<TRADING_ACCOUNT_ID>"
  },
  "id": "1611082473000"
}

Available Topics

TopicDescriptionData TypeSubscription Type
ordersSnapshot and updates on your orders. Snapshot contains all open orders and the 20 most recent closed orders.V1TAOrderBy <TOPIC>
tradesSnapshot and updates on your trades. Snapshot contains the 20 most recent trades.V1TATradeBy <TOPIC>
assetAccountsSnapshot and updates on assets in your account.V1TAAssetAccountBy <TOPIC>
tradingAccountsSnapshot and updates on your trading account summary.V1TATradingAccountBy <TOPIC>
heartbeatPeriodic heartbeat for health monitoring.V1TAHeartbeatBy <TOPIC>
derivativesPositionsV2Derivative position information on your trading account.V1TADerivativesPositionBy <TOPIC>
ammInstructionsAMM instruction updates on your trading account. Updates only — no snapshot.V1TAAmmInstructionBy <TOPIC>
mmpTriggerSnapshot and updates on market maker protection trigger events.V1TAMMPTriggerBy <TOPIC>
mmpRequestSnapshot and updates on market maker protection configurations.V1TAMMPConfigRequestBy <TOPIC>
The spotAccounts topic is deprecated (replaced by assetAccounts) and the derivativesPositions topic is deprecated (replaced by derivativesPositionsV2).

Heartbeat

A heartbeat message is sent approximately every 30 seconds on the heartbeat topic. It serves to validate end-to-end communication between the exchange and your client.
If you stop receiving heartbeats, first check the official status page for any exchange announcements. If no announcements have been made, disconnect and reconnect immediately — the issue may be isolated to a specific gateway and reconnecting will route you to a healthy one.
Subscribe to the heartbeat topic:
{
  "jsonrpc": "2.0",
  "type": "command",
  "method": "subscribe",
  "params": {
    "topic": "heartbeat"
  },
  "id": "1611082473000"
}
Heartbeat response format:
{
  "type": "update",
  "dataType": "V1TAHeartbeat",
  "data": [
    {
      "sequenceNumber": "3",
      "createdAtTimestamp": "1611082473000"
    }
  ]
}

Topic Response Details

Orders Response

Provides a snapshot and real-time updates of your orders. The snapshot includes all open orders and the 20 most recent closed orders.
FieldTypeDescription
clientOrderIdStringUnique numeric identifier generated on the client side
orderIdStringUnique order ID
symbolStringMarket symbol
priceStringOrder price
averageFillPriceStringAverage fill price
stopPriceStringStop price
allowBorrowBooleanIndicates if the order was allowed to borrow
quantityStringOrder quantity
quoteAmountStringQuote quantity deducted from asset account
quantityFilledStringQuantity filled
baseFeeStringBase fee rate charged upon trade execution
quoteFeeStringQuote fee rate charged upon trade execution
borrowedBaseQuantityStringBase quantity borrowed
borrowedQuoteQuantityStringQuote quantity borrowed
isLiquidationBooleanIndicates if the order was executed as a liquidation order
sideStringOrder side (BUY or SELL)
typeStringOrder type (e.g. LMT)
timeInForceStringTime in force (e.g. GTC)
statusStringOrder status
statusReasonStringDescribes why the order is in its current state
statusReasonCodeIntegerStatus reason code
createdAtDatetimeStringISO 8601 time the order was acknowledged by the exchange
createdAtTimestampStringEpoch millisecond time the order was acknowledged
publishedAtTimestampStringTime the update was broadcast to connected clients
{
  "tradingAccountId": "1111",
  "type": "snapshot",
  "dataType": "V1TAOrder",
  "data": [
    {
      "orderId": "392883006043848705",
      "symbol": "BTCUSD",
      "price": "66858.2000",
      "averageFillPrice": "66858.2000",
      "stopPrice": null,
      "quantity": "2.00000000",
      "quantityFilled": "2.00000000",
      "quoteAmount": "23000.0000",
      "baseFee": "0.00000000",
      "quoteFee": "0.0005",
      "side": "BUY",
      "allowBorrow": false,
      "borrowedBaseQuantity": "0.00000000",
      "borrowedQuoteQuantity": "0.0010",
      "isLiquidation": false,
      "type": "LMT",
      "timeInForce": "GTC",
      "status": "CLOSED",
      "statusReason": "Executed",
      "statusReasonCode": 6002,
      "createdAtDatetime": "2021-12-30T07:36:35.918Z",
      "createdAtTimestamp": "1640849795918",
      "publishedAtTimestamp": "1640849795920"
    }
  ]
}

Python Example

A complete Python example for connecting to the Private Data WebSocket is available in the official API examples repository: private_data_web_socket.py

Build docs developers (and LLMs) love