Bitmex · AsyncAPI Specification

BitMEX Realtime WebSocket API

Version 1.0.0

AsyncAPI 2.6 specification for the BitMEX public Realtime WebSocket API. BitMEX exposes a single WebSocket endpoint at `wss://ws.bitmex.com/realtime`. Clients subscribe to one or more topics ("tables") and receive a stream of JSON messages. Each topic delivers messages with one of four `action` values: * `partial` - the initial full snapshot of the table for this subscription along with the key fields used to identify rows on subsequent updates. * `insert` - new rows appended to the table. * `update` - partial updates to existing rows (matched by `keys`). * `delete` - rows removed from the table. Most topics may be scoped to a specific symbol using `topic:symbol` (for example `trade:XBTUSD`). A small set of topics never take a symbol (see the `subscriptionSubjects` list returned by `/api/v1/schema/websocketHelp`). Authentication for the private topics uses two custom headers (`api-expires` and `api-signature`) or the equivalent `api-expires` / `api-signature` / `api-key` query string parameters. The signature is `HMAC_SHA256(apiSecret, 'GET' + '/realtime' + apiExpires)`. Source of truth for the topic list: `https://www.bitmex.com/api/v1/schema/websocketHelp` and `https://www.bitmex.com/app/wsAPI`.

View Spec View on GitHub CryptocurrencyPublic APIsAsyncAPIWebhooksEvents

Channels

announcement
subscribe subscribeAnnouncement
Receive site-wide announcements.
Site-wide notices from BitMEX. Public, no symbol scoping.
chat
subscribe subscribeChat
Receive Trollbox chat messages.
BitMEX Trollbox chat messages. Public, no symbol scoping.
connected
subscribe subscribeConnected
Receive connected-users counts.
Statistics about currently connected users and bots. Public, no symbol scoping.
funding
subscribe subscribeFunding
Receive funding events.
Updates of funding rates for perpetual instruments. Scoped by symbol (for example `funding:XBTUSD`).
instrument
subscribe subscribeInstrument
Receive instrument ticker updates.
Instrument updates including price, volume and statistics. Scoped by symbol (for example `instrument:XBTUSD`).
insurance
subscribe subscribeInsurance
Receive insurance fund updates.
Updates to the BitMEX insurance fund balance per currency. Public, no symbol scoping.
liquidation
subscribe subscribeLiquidation
Receive liquidation events.
Stream of liquidation orders. Scoped by symbol (for example `liquidation:XBTUSD`).
orderBookL2
subscribe subscribeOrderBookL2
Receive full L2 order book updates.
Full level-2 order book. Each row is identified by `(symbol, id, side)`. Scoped by symbol (for example `orderBookL2:XBTUSD`).
orderBookL2_25
subscribe subscribeOrderBookL2_25
Receive top-25 L2 order book updates.
Top 25 levels of the level-2 order book per side. Scoped by symbol (for example `orderBookL2_25:XBTUSD`).
orderBook10
subscribe subscribeOrderBook10
Receive top-10 order book snapshots.
Top 10 levels of the order book, delivered as a pulsed full snapshot. Scoped by symbol (for example `orderBook10:XBTUSD`).
publicNotifications
subscribe subscribePublicNotifications
Receive public notifications.
Site-wide public notifications. Public, no symbol scoping.
quote
subscribe subscribeQuote
Receive top-of-book quote updates.
Top-of-book quote updates. Scoped by symbol (for example `quote:XBTUSD`).
quoteBin1m
subscribe subscribeQuoteBin1m
Receive 1-minute binned quotes.
1-minute binned quote OHLC-style snapshots. Scoped by symbol (for example `quoteBin1m:XBTUSD`).
quoteBin5m
subscribe subscribeQuoteBin5m
Receive 5-minute binned quotes.
5-minute binned quote snapshots. Scoped by symbol (for example `quoteBin5m:XBTUSD`).
quoteBin1h
subscribe subscribeQuoteBin1h
Receive 1-hour binned quotes.
1-hour binned quote snapshots. Scoped by symbol (for example `quoteBin1h:XBTUSD`).
quoteBin1d
subscribe subscribeQuoteBin1d
Receive 1-day binned quotes.
1-day binned quote snapshots. Scoped by symbol (for example `quoteBin1d:XBTUSD`).
settlement
subscribe subscribeSettlement
Receive instrument settlement events.
Instrument settlement events. Scoped by symbol (for example `settlement:XBTUSD`).
trade
subscribe subscribeTrade
Receive trade ticks.
Live trade ticks. Scoped by symbol (for example `trade:XBTUSD`).
tradeBin1m
subscribe subscribeTradeBin1m
Receive 1-minute trade bins.
1-minute binned OHLCV trade snapshots. Scoped by symbol (for example `tradeBin1m:XBTUSD`).
tradeBin5m
subscribe subscribeTradeBin5m
Receive 5-minute trade bins.
5-minute binned OHLCV trade snapshots. Scoped by symbol (for example `tradeBin5m:XBTUSD`).
tradeBin1h
subscribe subscribeTradeBin1h
Receive 1-hour trade bins.
1-hour binned OHLCV trade snapshots. Scoped by symbol (for example `tradeBin1h:XBTUSD`).
tradeBin1d
subscribe subscribeTradeBin1d
Receive 1-day trade bins.
1-day binned OHLCV trade snapshots. Scoped by symbol (for example `tradeBin1d:XBTUSD`).
affiliate
subscribe subscribeAffiliate
Receive affiliate metrics (auth required).
Affiliate program metrics for the authenticated account. Requires authentication. No symbol scoping.
execution
subscribe subscribeExecution
Receive order executions (auth required).
Order executions (fills) for the authenticated account. Requires authentication. May be scoped by symbol.
margin
subscribe subscribeMargin
Receive margin updates (auth required).
Margin balance updates for the authenticated account. Requires authentication. No symbol scoping.
order
subscribe subscribeOrder
Receive order updates (auth required).
Live order book updates for the authenticated account. Requires authentication. May be scoped by symbol.
position
subscribe subscribePosition
Receive position updates (auth required).
Position updates for the authenticated account. Requires authentication. May be scoped by symbol.
privateNotifications
subscribe subscribePrivateNotifications
Receive private notifications (auth required).
Private notifications targeted at the authenticated account. Requires authentication. No symbol scoping.
transact
subscribe subscribeTransact
Receive wallet transactions (auth required).
Wallet transactions (deposits, withdrawals, fees, settlements) for the authenticated account. Requires authentication. No symbol scoping.
wallet
subscribe subscribeWallet
Receive wallet balance updates (auth required).
Wallet balance updates for the authenticated account. Requires authentication. No symbol scoping.

Messages

SubscribeRequest
Subscribe / Unsubscribe envelope
Client-to-server control message used to subscribe to, unsubscribe from, or authenticate against topics.
WelcomeMessage
Server welcome message
Sent by the server immediately after connection.
SubscribeResponse
Subscribe acknowledgement
Server acknowledgement of a successful subscribe / unsubscribe.
ErrorMessage
Server error
Server-side error response.
AnnouncementMessage
announcement table message
ChatMessage
chat table message
ConnectedMessage
connected table message
FundingMessage
funding table message
InstrumentMessage
instrument table message
InsuranceMessage
insurance table message
LiquidationMessage
liquidation table message
OrderBookL2Message
orderBookL2 / orderBookL2_25 table message
OrderBook10Message
orderBook10 pulsed snapshot
PublicNotificationMessage
publicNotifications table message
QuoteMessage
quote / quoteBin* table message
SettlementMessage
settlement table message
TradeMessage
trade table message
TradeBinMessage
tradeBin1m / 5m / 1h / 1d table message
AffiliateMessage
affiliate table message
ExecutionMessage
execution table message
MarginMessage
margin table message
OrderMessage
order table message
PositionMessage
position table message
PrivateNotificationMessage
privateNotifications table message
TransactMessage
transact table message
WalletMessage
wallet table message

Servers

wss
production ws.bitmex.com/realtime
BitMEX production Realtime WebSocket endpoint. Full URL: `wss://ws.bitmex.com/realtime`. Subscriptions may be requested either via the `subscribe` query string parameter (comma-separated topic list) or via subsequent `{"op":"subscribe","args":[...]}` messages after the connection is established.

AsyncAPI Specification

Raw ↑
asyncapi: '2.6.0'
info:
  title: BitMEX Realtime WebSocket API
  version: '1.0.0'
  description: |
    AsyncAPI 2.6 specification for the BitMEX public Realtime WebSocket API.

    BitMEX exposes a single WebSocket endpoint at `wss://ws.bitmex.com/realtime`.
    Clients subscribe to one or more topics ("tables") and receive a stream of
    JSON messages. Each topic delivers messages with one of four `action` values:

      * `partial` - the initial full snapshot of the table for this subscription
                    along with the key fields used to identify rows on subsequent
                    updates.
      * `insert`  - new rows appended to the table.
      * `update`  - partial updates to existing rows (matched by `keys`).
      * `delete`  - rows removed from the table.

    Most topics may be scoped to a specific symbol using `topic:symbol`
    (for example `trade:XBTUSD`). A small set of topics never take a symbol
    (see the `subscriptionSubjects` list returned by
    `/api/v1/schema/websocketHelp`).

    Authentication for the private topics uses two custom headers
    (`api-expires` and `api-signature`) or the equivalent
    `api-expires` / `api-signature` / `api-key` query string parameters.
    The signature is `HMAC_SHA256(apiSecret, 'GET' + '/realtime' + apiExpires)`.

    Source of truth for the topic list:
    `https://www.bitmex.com/api/v1/schema/websocketHelp` and
    `https://www.bitmex.com/app/wsAPI`.
  contact:
    name: BitMEX API
    url: https://www.bitmex.com/app/wsAPI
  license:
    name: Proprietary
    url: https://www.bitmex.com/app/terms
  x-source: https://www.bitmex.com/api/v1/schema/websocketHelp

defaultContentType: application/json

servers:
  production:
    url: ws.bitmex.com/realtime
    protocol: wss
    description: |
      BitMEX production Realtime WebSocket endpoint.
      Full URL: `wss://ws.bitmex.com/realtime`.

      Subscriptions may be requested either via the `subscribe`
      query string parameter (comma-separated topic list) or via
      subsequent `{"op":"subscribe","args":[...]}` messages after
      the connection is established.
    security:
      - {}
      - apiSignature: []

channels:

  # ============================================================
  # Public topics
  # ============================================================

  announcement:
    description: Site-wide notices from BitMEX. Public, no symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeAnnouncement
      summary: Receive site-wide announcements.
      message:
        $ref: '#/components/messages/AnnouncementMessage'

  chat:
    description: BitMEX Trollbox chat messages. Public, no symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeChat
      summary: Receive Trollbox chat messages.
      message:
        $ref: '#/components/messages/ChatMessage'

  connected:
    description: |
      Statistics about currently connected users and bots.
      Public, no symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeConnected
      summary: Receive connected-users counts.
      message:
        $ref: '#/components/messages/ConnectedMessage'

  funding:
    description: |
      Updates of funding rates for perpetual instruments.
      Scoped by symbol (for example `funding:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeFunding
      summary: Receive funding events.
      message:
        $ref: '#/components/messages/FundingMessage'

  instrument:
    description: |
      Instrument updates including price, volume and statistics.
      Scoped by symbol (for example `instrument:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeInstrument
      summary: Receive instrument ticker updates.
      message:
        $ref: '#/components/messages/InstrumentMessage'

  insurance:
    description: |
      Updates to the BitMEX insurance fund balance per currency.
      Public, no symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeInsurance
      summary: Receive insurance fund updates.
      message:
        $ref: '#/components/messages/InsuranceMessage'

  liquidation:
    description: |
      Stream of liquidation orders. Scoped by symbol
      (for example `liquidation:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeLiquidation
      summary: Receive liquidation events.
      message:
        $ref: '#/components/messages/LiquidationMessage'

  orderBookL2:
    description: |
      Full level-2 order book. Each row is identified by
      `(symbol, id, side)`. Scoped by symbol
      (for example `orderBookL2:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeOrderBookL2
      summary: Receive full L2 order book updates.
      message:
        $ref: '#/components/messages/OrderBookL2Message'

  orderBookL2_25:
    description: |
      Top 25 levels of the level-2 order book per side.
      Scoped by symbol (for example `orderBookL2_25:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeOrderBookL2_25
      summary: Receive top-25 L2 order book updates.
      message:
        $ref: '#/components/messages/OrderBookL2Message'

  orderBook10:
    description: |
      Top 10 levels of the order book, delivered as a pulsed
      full snapshot. Scoped by symbol (for example
      `orderBook10:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeOrderBook10
      summary: Receive top-10 order book snapshots.
      message:
        $ref: '#/components/messages/OrderBook10Message'

  publicNotifications:
    description: |
      Site-wide public notifications. Public, no symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribePublicNotifications
      summary: Receive public notifications.
      message:
        $ref: '#/components/messages/PublicNotificationMessage'

  quote:
    description: |
      Top-of-book quote updates. Scoped by symbol
      (for example `quote:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeQuote
      summary: Receive top-of-book quote updates.
      message:
        $ref: '#/components/messages/QuoteMessage'

  quoteBin1m:
    description: |
      1-minute binned quote OHLC-style snapshots.
      Scoped by symbol (for example `quoteBin1m:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeQuoteBin1m
      summary: Receive 1-minute binned quotes.
      message:
        $ref: '#/components/messages/QuoteMessage'

  quoteBin5m:
    description: |
      5-minute binned quote snapshots.
      Scoped by symbol (for example `quoteBin5m:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeQuoteBin5m
      summary: Receive 5-minute binned quotes.
      message:
        $ref: '#/components/messages/QuoteMessage'

  quoteBin1h:
    description: |
      1-hour binned quote snapshots.
      Scoped by symbol (for example `quoteBin1h:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeQuoteBin1h
      summary: Receive 1-hour binned quotes.
      message:
        $ref: '#/components/messages/QuoteMessage'

  quoteBin1d:
    description: |
      1-day binned quote snapshots.
      Scoped by symbol (for example `quoteBin1d:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeQuoteBin1d
      summary: Receive 1-day binned quotes.
      message:
        $ref: '#/components/messages/QuoteMessage'

  settlement:
    description: |
      Instrument settlement events.
      Scoped by symbol (for example `settlement:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeSettlement
      summary: Receive instrument settlement events.
      message:
        $ref: '#/components/messages/SettlementMessage'

  trade:
    description: |
      Live trade ticks. Scoped by symbol
      (for example `trade:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeTrade
      summary: Receive trade ticks.
      message:
        $ref: '#/components/messages/TradeMessage'

  tradeBin1m:
    description: |
      1-minute binned OHLCV trade snapshots.
      Scoped by symbol (for example `tradeBin1m:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeTradeBin1m
      summary: Receive 1-minute trade bins.
      message:
        $ref: '#/components/messages/TradeBinMessage'

  tradeBin5m:
    description: |
      5-minute binned OHLCV trade snapshots.
      Scoped by symbol (for example `tradeBin5m:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeTradeBin5m
      summary: Receive 5-minute trade bins.
      message:
        $ref: '#/components/messages/TradeBinMessage'

  tradeBin1h:
    description: |
      1-hour binned OHLCV trade snapshots.
      Scoped by symbol (for example `tradeBin1h:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeTradeBin1h
      summary: Receive 1-hour trade bins.
      message:
        $ref: '#/components/messages/TradeBinMessage'

  tradeBin1d:
    description: |
      1-day binned OHLCV trade snapshots.
      Scoped by symbol (for example `tradeBin1d:XBTUSD`).
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeTradeBin1d
      summary: Receive 1-day trade bins.
      message:
        $ref: '#/components/messages/TradeBinMessage'

  # ============================================================
  # Authenticated topics
  # ============================================================

  affiliate:
    description: |
      Affiliate program metrics for the authenticated account.
      Requires authentication. No symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeAffiliate
      summary: Receive affiliate metrics (auth required).
      message:
        $ref: '#/components/messages/AffiliateMessage'

  execution:
    description: |
      Order executions (fills) for the authenticated account.
      Requires authentication. May be scoped by symbol.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeExecution
      summary: Receive order executions (auth required).
      message:
        $ref: '#/components/messages/ExecutionMessage'

  margin:
    description: |
      Margin balance updates for the authenticated account.
      Requires authentication. No symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeMargin
      summary: Receive margin updates (auth required).
      message:
        $ref: '#/components/messages/MarginMessage'

  order:
    description: |
      Live order book updates for the authenticated account.
      Requires authentication. May be scoped by symbol.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeOrder
      summary: Receive order updates (auth required).
      message:
        $ref: '#/components/messages/OrderMessage'

  position:
    description: |
      Position updates for the authenticated account.
      Requires authentication. May be scoped by symbol.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribePosition
      summary: Receive position updates (auth required).
      message:
        $ref: '#/components/messages/PositionMessage'

  privateNotifications:
    description: |
      Private notifications targeted at the authenticated account.
      Requires authentication. No symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribePrivateNotifications
      summary: Receive private notifications (auth required).
      message:
        $ref: '#/components/messages/PrivateNotificationMessage'

  transact:
    description: |
      Wallet transactions (deposits, withdrawals, fees, settlements)
      for the authenticated account. Requires authentication.
      No symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeTransact
      summary: Receive wallet transactions (auth required).
      message:
        $ref: '#/components/messages/TransactMessage'

  wallet:
    description: |
      Wallet balance updates for the authenticated account.
      Requires authentication. No symbol scoping.
    bindings:
      ws:
        bindingVersion: '0.1.0'
    subscribe:
      operationId: subscribeWallet
      summary: Receive wallet balance updates (auth required).
      message:
        $ref: '#/components/messages/WalletMessage'

components:

  securitySchemes:
    apiSignature:
      type: httpApiKey
      in: query
      name: api-signature
      description: |
        BitMEX request-signature authentication. Required for the
        authenticated topics (affiliate, execution, margin, order,
        position, privateNotifications, transact, wallet).

        Supply three query parameters when establishing the WebSocket
        connection, or the equivalent `api-key`, `api-expires` and
        `api-signature` HTTP headers:

          * `api-key` - your BitMEX API key id.
          * `api-expires` - integer UNIX epoch (seconds) when the
            signature expires. Recommended `now + 5`.
          * `api-signature` - lowercase hex
            `HMAC_SHA256(apiSecret, "GET" + "/realtime" + apiExpires)`.

        Alternative in-band auth is supported via the message
        `{"op":"authKeyExpires","args":[apiKey, apiExpires, signature]}`
        sent after the WebSocket connection is established.

  messages:

    SubscribeRequest:
      name: SubscribeRequest
      title: Subscribe / Unsubscribe envelope
      summary: |
        Client-to-server control message used to subscribe to,
        unsubscribe from, or authenticate against topics.
      contentType: application/json
      payload:
        $ref: '#/components/schemas/SubscribeRequest'

    WelcomeMessage:
      name: WelcomeMessage
      title: Server welcome message
      summary: Sent by the server immediately after connection.
      contentType: application/json
      payload:
        $ref: '#/components/schemas/Welcome'

    SubscribeResponse:
      name: SubscribeResponse
      title: Subscribe acknowledgement
      summary: Server acknowledgement of a successful subscribe / unsubscribe.
      contentType: application/json
      payload:
        $ref: '#/components/schemas/SubscribeResponse'

    ErrorMessage:
      name: ErrorMessage
      title: Server error
      summary: Server-side error response.
      contentType: application/json
      payload:
        $ref: '#/components/schemas/ErrorResponse'

    AnnouncementMessage:
      name: AnnouncementMessage
      title: announcement table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageAnnouncement'

    ChatMessage:
      name: ChatMessage
      title: chat table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageChat'

    ConnectedMessage:
      name: ConnectedMessage
      title: connected table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageConnected'

    FundingMessage:
      name: FundingMessage
      title: funding table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageFunding'

    InstrumentMessage:
      name: InstrumentMessage
      title: instrument table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageInstrument'

    InsuranceMessage:
      name: InsuranceMessage
      title: insurance table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageInsurance'

    LiquidationMessage:
      name: LiquidationMessage
      title: liquidation table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageLiquidation'

    OrderBookL2Message:
      name: OrderBookL2Message
      title: orderBookL2 / orderBookL2_25 table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageOrderBookL2'

    OrderBook10Message:
      name: OrderBook10Message
      title: orderBook10 pulsed snapshot
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageOrderBook10'

    PublicNotificationMessage:
      name: PublicNotificationMessage
      title: publicNotifications table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageGlobalNotification'

    QuoteMessage:
      name: QuoteMessage
      title: quote / quoteBin* table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageQuote'

    SettlementMessage:
      name: SettlementMessage
      title: settlement table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageSettlement'

    TradeMessage:
      name: TradeMessage
      title: trade table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageTrade'

    TradeBinMessage:
      name: TradeBinMessage
      title: tradeBin1m / 5m / 1h / 1d table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageTradeBin'

    AffiliateMessage:
      name: AffiliateMessage
      title: affiliate table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageAffiliate'

    ExecutionMessage:
      name: ExecutionMessage
      title: execution table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageExecution'

    MarginMessage:
      name: MarginMessage
      title: margin table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageMargin'

    OrderMessage:
      name: OrderMessage
      title: order table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageOrder'

    PositionMessage:
      name: PositionMessage
      title: position table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessagePosition'

    PrivateNotificationMessage:
      name: PrivateNotificationMessage
      title: privateNotifications table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageGlobalNotification'

    TransactMessage:
      name: TransactMessage
      title: transact table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageTransaction'

    WalletMessage:
      name: WalletMessage
      title: wallet table message
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TableMessageWallet'

  schemas:

    Action:
      type: string
      description: |
        BitMEX table action. `partial` arrives once at the start of
        a subscription with the full snapshot and `keys` array.
        Subsequent messages are `insert`, `update` or `delete` keyed
        by the fields in `keys`.
      enum: [partial, insert, update, delete]

    OperationName:
      type: string
      enum: [subscribe, unsubscribe, authKey, authKeyExpires, cancelAllAfter, ping]
      description: |
        Client operation names supported by the BitMEX WebSocket.
        `subscribe` / `unsubscribe` manage topics; `authKeyExpires` /
        `authKey` perform in-band authentication; `cancelAllAfter`
        sets a dead-man timer; `ping` is a keepalive.

    SubscribeRequest:
      type: object
      description: |
        Client-to-server envelope. Examples:

          * `{"op":"subscribe","args":["trade:XBTUSD","instrument:XBTUSD"]}`
          * `{"op":"unsubscribe","args":["trade:XBTUSD"]}`
          * `{"op":"authKeyExpires","args":["myKey",1518064238,"signature"]}`
      required: [op]
      properties:
        op:
          $ref: '#/components/schemas/OperationName'
        args:
          type: array
          description: |
            Operation arguments. For `subscribe` / `unsubscribe` this
            is an array of topic strings such as `"trade:XBTUSD"` or
            unscoped topic names such as `"announcement"`.
          items: {}

    Welcome:
      type: object
      description: |
        Welcome message sent by the server immediately after
        the WebSocket connection is established.
      properties:
        info:
          type: string
          description: Human-readable status string.
        version:
          type: string
          description: BitMEX engine build hash.
        timestamp:
          type: string
          format: date-time
        docs:
          type: string
          format: uri
        limit:
          type: object
          properties:
            remaining:
              type: integer

    SubscribeResponse:
      type: object
      description: |
        Acknowledgement returned when a subscribe / unsubscribe
        succeeds.
      properties:
        success:
          type: boolean
        subscribe:
          type: string
          description: The topic that was subscribed to.
        unsubscribe:
          type: string
          description: The topic that was unsubscribed from.
        request:
          $ref: '#/components/schemas/SubscribeRequest'

    ErrorResponse:
      type: object
      description: |
        Server error envelope. Returned for invalid messages
        such as unknown topics, malformed JSON, or auth failures.
      required: [status, error]
      properties:
        status:
          type: integer
          description: HTTP-style status code.
        error:
          type: string
          description: Human-readable error message.
        meta:
          type: object
        request:
          $ref: '#/components/schemas/SubscribeRequest'

    TableEnvelopeBase:
      type: object
      description: Common envelope for all table push messages.
      required: [table, action, data]
      properties:
        table:
          type: string
          description: The topic / table name (e.g. `trade`, `quote`).
        action:
          $ref: '#/components/schemas/Action'
        keys:
          type: array
          items:
            type: string
          description: |
            Field names that uniquely identify a row within the
            table. Present on `partial` snapshots.
        types:
          type: object
          additionalProperties:
            type: string
          description: Server-side field type map for the table.
        foreignKeys:
          type: object
          additionalProperties:
            type: string
        attributes:
          type: object
          additionalProperties:
            type: string
        filter:
          type: object
          description: Filter that scoped this subscription (e.g. `{"symbol":"XBTUSD"}`).

    # ------------------------------------------------------------
    # Row schemas (mirror BitMEX REST schemas)
    # ------------------------------------------------------------

    Announcement:
      type: object
      properties:
        id: { type: integer, format: int32 }
        link: { type: string }
        title: { type: string }
        content: { type: string }
        date: { type: string, format: date-time }
      required: [id]

    Chat:
      type: object
      properties:
        id: { type: integer, format: int32 }
        date: { type: string, format: date-time }
        user: { type: string }
        userColor: { type: string }
        message: { type: string }
        html: { type: string }
        channelID: { type: number, format: double }
      required: [id]

    ConnectedUsers:
      type: object
      properties:
        users: { type: integer }
        bots: { type: integer }

    Funding:
      type: object
      properties:
        timestamp: { type: string, format: date-time }
        symbol: { type: string }
        fundingInterval: { type: string, format: date-time }
        fundingRate: { type: number, format: double }
        fundingRateDaily: { type: number, format: double }
      required: [timestamp, symbol]

    Instrument:
      type: object
      properties:
        symbol: { type: string }
        rootSymbol: { type: string }
        instrumentID: { type: integer, format: int32 }
        state: { type: string }
        typ: { type: string }
        listing: { type: string, format: date-time }
        front: { type: string, format: date-time }
        expiry: { type: string, format: date-time }
        settle: { type: string, format: date-time }
        listedSettle: { type: string, format: date-time }
        positionCurrency: { type: string }
        underlying: { type: string }
        quoteCurrency: { type: string }
        underlyingSymbol: { type: string }
        reference: { type: string }
        referenceSymbol: { type: string }
        calcInterval: { type: string, format: date-time }
        publishInterval: { type: string, format: date-time }
        publishTime: { type: string, format: date-time }
        maxOrderQty: { type: integer, format: int64 }
        minPrice: { type: number, format: double }
        maxPrice: { type: number, format: double }
        lotSize: { type: integer, format: int64 }
        tickSize: { type: number, format: double }
        multiplier: { type: integer, format: int64 }
        settlCurrency: { type: string }
        underlyingToPositionMultiplier: { type: integer, format: int64 }
        underlyingToSettleMultiplier: { type: integer, format: int64 }
        quoteToSettleMultiplier: { type: integer, format: int64 }
        isQuanto: { type: boolean }
        isInverse: { type: boolean }
        initMargin: { type: number, format: double }
        maintMargin: { type: number, format: double }
        riskLimit: { type: integer, format: int64 }
        riskStep: { type: integer, format: int64 }
        limit: { type: number, format: double }
        taxed: { type: boolean }
        deleverage: { type: boolean }
        makerFee: { type: number, format: double }
        takerFee: { type: number, format: double }
        settlementFee: { type: number, format: double }
        fundingBaseSymbol: { type: string }
        fundingQuoteSymbol: { type: string }
        fundingPremiumSymbol: { type: string }
        fundingTimestamp: { type: string, format: date-time }
        fundingInterval: { type: string, format: date-time }
        fundingRate: { type: number, format: double }
        indicativeFundingRate: { type: number, format: double }
        rebalanceTimestamp: { type: string, format: date-time }
        rebalanceInterval: { type: string, format: date-time }
        launchingTimestamp: { type: string, format: date-time }
        prevClosePrice: { type: number, format: double }
        limitDownPrice: { type: number, format: double }
        limitUpPrice: { type: number, format: double }
        totalVolume: { type: integer, format: int64 }
        volume: { type: integer, format: int64 }
        volume24h: { type: integer, format: int64 }
        prevTotalTurnover: { type: integer, format: int64 }
        totalTurnover: { type: integer, format: int64 }
        turnover: { type: integer, format: int64 }
        turnover24h: { type: integer, format: int64 }
        homeNotional24h: { type: number, format: double }
        foreignNotional24h: { type: number, format: double }
        prevPrice24h: { type: number, format: double }
        vwap: { type: number, format: double }
        highPrice: { type: number, format: double }
        lowPrice: { type: number, format: double }
        lastPrice: { type: number, format: double }
        lastPriceProtected: { type: number, format: double }
        lastTickDirection: { type: string }
        lastChangePcnt: { type: number, format: double }
        bidPrice: { type: number, format: double }
        midPrice: { type: number, format: double }
        askPrice: { type: number, format: double }
        impactBidPrice: { type: number, format: double }
        impactMidPrice: { type: number, format: double }
        impactAskPrice: { type: number, format: double }
        hasLiquidity: { type: boolean }
        openInterest: { type: integer, format: int64 }
        openValue: { type: integer, format: int64 }
        fairMethod: { type: string }
        fairBasisRate: { type: number, format: double }
        fairBasis: { type: number, format: double }
        fairPrice: { type: number, format: double }
        markMethod: { type: string }
        markPrice: { type: number, format: double }
        referencePrice: { type: number, format: double }
        indicativeSettlePrice: { type: number, format: double }
        settledPriceAdjustmentRate: { type: number, format: double }
        settledPrice: { type: number, format: double }
        instantPnl: { type: boolean }
        minTick: { type: number, format: double }
        fundingBaseRate: { type: number, format: double }
        fundingQuoteRate: { type: number, format: double }
        farLegSymbol: { type: string }
        nearLegSymbol: { type: string }
        tags: { type: string }
        timestamp: { type: string, format: date-time }
      required: [symbol]

    Insurance:
      type: object
      properties:
        currency: { type: string }
        timestamp: { type: string, format: date-time }
        walletBalance: { type: integer, format: int64 }
      required: [currency, timestamp]

    Liquidation:
      type: object
      properties:
        orderID: { type: string, format: uuid }
        symbol: { type: string }
        side: { type: string }
        price: { type: number, format: double }
        leavesQty: { type: integer, format: int64 }
      required: [orderID]

    OrderBookL2:
      type: object
      properties:
        symbol: { type: string }
        id: { type: integer, format: int64 }
        side: { type: string }
        size: { type: integer, format: int64 }
        price: { type: number, format: double }
        pool: { type: string }
        timestamp: { type: string, format: date-time }
        transactTime: { type: string, format: date-time }
      required: [symbol, id, side]

    OrderBook10:
      type: object
      description: |
        Top-10 pulsed order book snapshot. `bids` and `asks`
        are arrays of `[price, size]` tuples sorted best-first.
      properties:
        symbol: { type: string }
        bids:
          type: array
          items:
            type: array
            items:
              type: number
            minItems: 2
            maxItems: 2
        asks:
          type: array
          items:
            type: array
            items:
              type: number
            minItems: 2
            maxItems: 2
        timestamp: { type: string, format: date-time }
      required: [symbol]

    Quote:
      type: object
      properties:
        timestamp: { type: string, format: date-time }
        symbol: { type: string }
        bidSize: { type: integer, format: int64 }
        bidPrice: { type: number, format: double }
        askPrice: { type: number, format: double }
        askSize: { type: integer, format: int64 }
        pool: { type: string }
      required: [timestamp]

    Settlement:
      type: object
      properties:
        timestamp: { type: string, format: date-time }
        symbol: { type: string }
        settlementType: { type: string }
        settledPrice: { type: number, format: double }
        optionStrikePrice: { type: number, format: double }
     

# --- truncated at 32 KB (52 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/bitmex/refs/heads/main/asyncapi/bitmex-asyncapi.yml