Poloniex · AsyncAPI Specification

Poloniex WebSocket API

Version 1.0.0

AsyncAPI 2.6 description of the Poloniex public, private (spot) and futures (v3) WebSocket interfaces. All channels and message field names are derived from Poloniex's official Java and Python SDKs published at https://github.com/poloniex/polo-sdk-java and https://github.com/poloniex/polo-sdk-python, which the Poloniex API docs site (https://api-docs.poloniex.com) links to as the authoritative reference implementations. Connections are kept alive by sending {"event":"ping"} every few seconds; the server responds with {"event":"pong"}. Subscriptions use the envelope {"event":"subscribe","channel":[],"symbols":[...]} and private channels require an additional auth subscribe with an HMAC SHA256 signature over `GET\n/ws\nsignTimestamp=`.

View Spec View on GitHub CryptocurrencyPublic APIsAsyncAPIWebhooksEvents

Channels

spot/candles
publish spotCandlesSubscribeRequest
Subscribe to candlestick channel
Candlestick (kline) updates for a symbol at a given interval. The `` placeholder must be one of: candles_minute_1, candles_minute_5, candles_minute_10, candles_minute_15, candles_minute_30, candles_hour_1, candles_hour_2, candles_hour_4, candles_hour_6, candles_hour_12, candles_day_1, candles_day_3, candles_week_1, candles_month_1. Source: polo-sdk-java spot/common/CandlestickChannels.java.
spot/trades
publish spotTradesSubscribeRequest
Subscribe to trades channel
Recent trade prints for one or more symbols.
spot/ticker
publish spotTickerSubscribeRequest
Subscribe to ticker channel
Rolling 24h ticker updates for one or more symbols.
spot/book
publish spotBookSubscribeRequest
Subscribe to book channel
Top of book / aggregated order book snapshots and updates.
spot/book_lv2
publish spotBookLv2SubscribeRequest
Subscribe to book_lv2 channel
Level 2 incremental order book updates (snapshot + diffs).
spot/symbols
publish spotSymbolsSubscribeRequest
Subscribe to symbols channel
Symbol metadata stream (trade limits, state, margin info).
spot/currencies
publish spotCurrenciesSubscribeRequest
Subscribe to currencies channel
Currency metadata stream (network fees, wallet state).
spot/exchange
publish spotExchangeSubscribeRequest
Subscribe to exchange channel
Exchange operating mode flags (maintenance, post-only).
spot/auth
publish spotAuthRequest
Authenticate the spot private session
Authentication subscribe envelope sent after connecting to the spot private endpoint. The `params.signature` is base64(HMAC_SHA256(secret, "GET\n/ws\nsignTimestamp=")).
spot/orders
publish spotOrdersSubscribeRequest
Subscribe to orders channel
Order lifecycle events (place, trade, canceled) for the account.
spot/balances
publish spotBalancesSubscribeRequest
Subscribe to balances channel
Account balance change events.
spot/createOrder
publish spotCreateOrder
Submit a create-order command
Place an order through the websocket session.
spot/cancelOrders
publish spotCancelOrders
Submit a cancel-orders command
Cancel one or more orders by id or client order id.
spot/cancelAllOrders
publish spotCancelAllOrders
Submit a cancel-all-orders command
Cancel all open orders for the account.
heartbeat
publish heartbeatPing
Send heartbeat ping
Client-side ping every few seconds; the server replies with {"event":"pong"}. The Poloniex Java SDK constants pin the exact JSON payloads.
futures/symbol
publish futuresSymbolSubscribeRequest
Subscribe to futures symbol channel
Product (contract) metadata stream for a futures symbol.
futures/book
publish futuresBookSubscribeRequest
Subscribe to futures book channel
Futures order book snapshots and updates.
futures/book_lv2
publish futuresBookLv2SubscribeRequest
Subscribe to futures book_lv2 channel
Futures level 2 incremental order book updates.
futures/candles
publish futuresCandlesSubscribeRequest
Subscribe to futures candles channel
Futures candlestick updates. The `` placeholder must be one of: candles_minute_1, candles_minute_5, candles_minute_10, candles_minute_15, candles_minute_30, candles_hour_1, hour_2, hour_4, hour_6, hour_12, candles_day_1, candles_day_3, candles_week_1, candles_month_1. Source: polo-sdk-java future/common/CandlesChannels.java.
futures/tickers
publish futuresTickersSubscribeRequest
Subscribe to futures tickers channel
Futures rolling 24h ticker updates.
futures/trades
publish futuresTradesSubscribeRequest
Subscribe to futures trades channel
Futures trade prints stream.
futures/index_price
publish futuresIndexPriceSubscribeRequest
Subscribe to index_price channel
Futures index price stream.
futures/mark_price
publish futuresMarkPriceSubscribeRequest
Subscribe to mark_price channel
Futures mark price stream.
futures/index_price_candles
publish futuresIndexPriceCandlesSubscribeRequest
Subscribe to index_candles_ channel
Futures index-price kline updates. Channel names follow the pattern index_candles_ (e.g. index_candles_minute_1). Source: polo-sdk-python futures/ws/client_public.py subscribe_to_IndexPriceKlineData.
futures/mark_price_candles
publish futuresMarkPriceCandlesSubscribeRequest
Subscribe to mark_price_candles_ channel
Futures mark-price kline updates. Channel names follow the pattern mark_price_candles_ (e.g. mark_price_candles_minute_1). Source: polo-sdk-python futures/ws/client_public.py subscribe_to_MarkPriceKlineData.
futures/funding_rate
publish futuresFundingRateSubscribeRequest
Subscribe to funding_rate channel
Futures funding rate stream.
futures/auth
publish futuresAuthRequest
Authenticate the futures private session
Authentication subscribe envelope for the futures private endpoint. The signature is identical to the spot case: base64(HMAC_SHA256(secret, "GET\n/ws\nsignTimestamp=")).
futures/positions
publish futuresPositionsSubscribeRequest
Subscribe to positions channel
Open positions stream for the futures account.
futures/orders
publish futuresOrdersSubscribeRequest
Subscribe to futures orders channel
Futures order lifecycle stream.
futures/trade
publish futuresTradeSubscribeRequest
Subscribe to futures trade channel
Futures own-trade execution stream.
futures/account
publish futuresAccountSubscribeRequest
Subscribe to futures account channel
Futures account change stream (equity, margin, PnL).

Messages

SubscribeEnvelope
Subscribe envelope
Subscribe (or unsubscribe) to one or more channels.
SubscribeEnvelopeNoSymbols
Subscribe envelope without symbols
Some account-wide channels (e.g. balances) take no symbols list.
AuthSubscribeEnvelope
Auth subscribe envelope
Authenticate a private session by subscribing to the `auth` channel.
AuthAck
Auth acknowledgement
Ping
Heartbeat ping
Pong
Heartbeat pong
CandlestickEvent
Candlestick event
TradeEvent
Trade event
TickerEvent
Ticker event
BookEvent
Order book event
BookLv2Event
Level 2 order book event
SymbolEvent
Symbol metadata event
CurrenciesEvent
Currency metadata event
ExchangeEvent
Exchange mode event
OrderEvent
Order lifecycle event
BalanceEvent
Balance change event
CreateOrderRequest
Create order command
CancelOrdersRequest
Cancel orders command
CancelAllOrdersRequest
Cancel all orders command
FuturesProductInfoEvent
Futures product info event
FuturesOrderBookEvent
Futures order book event
FuturesOrderBookV2Event
Futures level 2 order book event
FuturesKlineEvent
Futures kline event
FuturesTickersEvent
Futures tickers event
FuturesTradingInfoEvent
Futures trade event
FuturesIndexPriceEvent
Futures index price event
FuturesMarkPriceEvent
Futures mark price event
FuturesFundingRateEvent
Futures funding rate event
FuturesPositionsEvent
Futures positions event
FuturesOrdersEvent
Futures orders event
FuturesTradeEvent
Futures trade event (own executions)
FuturesAccountChangeEvent
Futures account change event

Servers

wss
spot-public ws.poloniex.com/ws/public
Spot public market data channels. Source: poloniex/polo-sdk-java README ("Production | Public | wss://ws.poloniex.com/ws/public").
wss
spot-private ws.poloniex.com/ws/private
Spot authenticated user-data channels. Source: poloniex/polo-sdk-java README ("Production | Authenticated | wss://ws.poloniex.com/ws/private").
wss
futures-public ws.poloniex.com/ws/v3/public
Futures (v3) public market data channels. Source: poloniex/polo-sdk-java FuturePoloPublicWebsocketTest references wss://ws.poloniex.com/ws/v3/public.
wss
futures-private ws.poloniex.com/ws/v3/private
Futures (v3) authenticated user-data channels. Source: poloniex/polo-sdk-java FuturePoloPrivateWebsocketTest references wss://ws.poloniex.com/ws/v3/private/.

AsyncAPI Specification

Raw ↑
asyncapi: '2.6.0'
info:
  title: Poloniex WebSocket API
  version: '1.0.0'
  description: >
    AsyncAPI 2.6 description of the Poloniex public, private (spot) and futures
    (v3) WebSocket interfaces. All channels and message field names are derived
    from Poloniex's official Java and Python SDKs published at
    https://github.com/poloniex/polo-sdk-java and
    https://github.com/poloniex/polo-sdk-python, which the Poloniex API docs
    site (https://api-docs.poloniex.com) links to as the authoritative
    reference implementations.

    Connections are kept alive by sending {"event":"ping"} every few seconds;
    the server responds with {"event":"pong"}. Subscriptions use the envelope
    {"event":"subscribe","channel":[<channel>],"symbols":[<symbol>...]} and
    private channels require an additional auth subscribe with an HMAC SHA256
    signature over `GET\n/ws\nsignTimestamp=<ms>`.
  contact:
    name: Poloniex API
    url: https://api-docs.poloniex.com
  license:
    name: Poloniex Terms of Service
    url: https://poloniex.com/legal/

servers:
  spot-public:
    url: ws.poloniex.com/ws/public
    protocol: wss
    description: >
      Spot public market data channels. Source: poloniex/polo-sdk-java README
      ("Production | Public | wss://ws.poloniex.com/ws/public").
  spot-private:
    url: ws.poloniex.com/ws/private
    protocol: wss
    description: >
      Spot authenticated user-data channels. Source: poloniex/polo-sdk-java
      README ("Production | Authenticated | wss://ws.poloniex.com/ws/private").
    security:
      - poloniexHmac: []
  futures-public:
    url: ws.poloniex.com/ws/v3/public
    protocol: wss
    description: >
      Futures (v3) public market data channels. Source: poloniex/polo-sdk-java
      FuturePoloPublicWebsocketTest references
      wss://ws.poloniex.com/ws/v3/public.
  futures-private:
    url: ws.poloniex.com/ws/v3/private
    protocol: wss
    description: >
      Futures (v3) authenticated user-data channels. Source:
      poloniex/polo-sdk-java FuturePoloPrivateWebsocketTest references
      wss://ws.poloniex.com/ws/v3/private/.
    security:
      - poloniexHmac: []

defaultContentType: application/json

channels:

  # ---------------------------------------------------------------------------
  # Spot public market data channels
  # Source: polo-sdk-python spot/ws/client_public.py and
  # polo-sdk-java spot common/PoloApiConstants.java
  # ---------------------------------------------------------------------------

  spot/candles:
    description: >
      Candlestick (kline) updates for a symbol at a given interval. The
      `<interval>` placeholder must be one of:
      candles_minute_1, candles_minute_5, candles_minute_10, candles_minute_15,
      candles_minute_30, candles_hour_1, candles_hour_2, candles_hour_4,
      candles_hour_6, candles_hour_12, candles_day_1, candles_day_3,
      candles_week_1, candles_month_1. Source:
      polo-sdk-java spot/common/CandlestickChannels.java.
    servers:
      - spot-public
    subscribe:
      operationId: spotCandlesSubscribe
      summary: Receive candlestick updates
      message:
        $ref: '#/components/messages/CandlestickEvent'
    publish:
      operationId: spotCandlesSubscribeRequest
      summary: Subscribe to candlestick channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/trades:
    description: Recent trade prints for one or more symbols.
    servers:
      - spot-public
    subscribe:
      operationId: spotTradesSubscribe
      summary: Receive trade prints
      message:
        $ref: '#/components/messages/TradeEvent'
    publish:
      operationId: spotTradesSubscribeRequest
      summary: Subscribe to trades channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/ticker:
    description: Rolling 24h ticker updates for one or more symbols.
    servers:
      - spot-public
    subscribe:
      operationId: spotTickerSubscribe
      summary: Receive ticker updates
      message:
        $ref: '#/components/messages/TickerEvent'
    publish:
      operationId: spotTickerSubscribeRequest
      summary: Subscribe to ticker channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/book:
    description: Top of book / aggregated order book snapshots and updates.
    servers:
      - spot-public
    subscribe:
      operationId: spotBookSubscribe
      summary: Receive order book updates
      message:
        $ref: '#/components/messages/BookEvent'
    publish:
      operationId: spotBookSubscribeRequest
      summary: Subscribe to book channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/book_lv2:
    description: Level 2 incremental order book updates (snapshot + diffs).
    servers:
      - spot-public
    subscribe:
      operationId: spotBookLv2Subscribe
      summary: Receive level 2 order book updates
      message:
        $ref: '#/components/messages/BookLv2Event'
    publish:
      operationId: spotBookLv2SubscribeRequest
      summary: Subscribe to book_lv2 channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/symbols:
    description: Symbol metadata stream (trade limits, state, margin info).
    servers:
      - spot-public
    subscribe:
      operationId: spotSymbolsSubscribe
      summary: Receive symbol metadata updates
      message:
        $ref: '#/components/messages/SymbolEvent'
    publish:
      operationId: spotSymbolsSubscribeRequest
      summary: Subscribe to symbols channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/currencies:
    description: Currency metadata stream (network fees, wallet state).
    servers:
      - spot-public
    subscribe:
      operationId: spotCurrenciesSubscribe
      summary: Receive currency metadata updates
      message:
        $ref: '#/components/messages/CurrenciesEvent'
    publish:
      operationId: spotCurrenciesSubscribeRequest
      summary: Subscribe to currencies channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/exchange:
    description: Exchange operating mode flags (maintenance, post-only).
    servers:
      - spot-public
    subscribe:
      operationId: spotExchangeSubscribe
      summary: Receive exchange mode updates
      message:
        $ref: '#/components/messages/ExchangeEvent'
    publish:
      operationId: spotExchangeSubscribeRequest
      summary: Subscribe to exchange channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  # ---------------------------------------------------------------------------
  # Spot private (authenticated) channels
  # Source: polo-sdk-python spot/ws/client_authenticated.py
  # ---------------------------------------------------------------------------

  spot/auth:
    description: >
      Authentication subscribe envelope sent after connecting to the spot
      private endpoint. The `params.signature` is base64(HMAC_SHA256(secret,
      "GET\n/ws\nsignTimestamp=<ms>")).
    servers:
      - spot-private
    publish:
      operationId: spotAuthRequest
      summary: Authenticate the spot private session
      message:
        $ref: '#/components/messages/AuthSubscribeEnvelope'
    subscribe:
      operationId: spotAuthAck
      summary: Receive auth acknowledgement
      message:
        $ref: '#/components/messages/AuthAck'

  spot/orders:
    description: Order lifecycle events (place, trade, canceled) for the account.
    servers:
      - spot-private
    subscribe:
      operationId: spotOrdersSubscribe
      summary: Receive order events
      message:
        $ref: '#/components/messages/OrderEvent'
    publish:
      operationId: spotOrdersSubscribeRequest
      summary: Subscribe to orders channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  spot/balances:
    description: Account balance change events.
    servers:
      - spot-private
    subscribe:
      operationId: spotBalancesSubscribe
      summary: Receive balance updates
      message:
        $ref: '#/components/messages/BalanceEvent'
    publish:
      operationId: spotBalancesSubscribeRequest
      summary: Subscribe to balances channel
      message:
        $ref: '#/components/messages/SubscribeEnvelopeNoSymbols'

  spot/createOrder:
    description: Place an order through the websocket session.
    servers:
      - spot-private
    publish:
      operationId: spotCreateOrder
      summary: Submit a create-order command
      message:
        $ref: '#/components/messages/CreateOrderRequest'

  spot/cancelOrders:
    description: Cancel one or more orders by id or client order id.
    servers:
      - spot-private
    publish:
      operationId: spotCancelOrders
      summary: Submit a cancel-orders command
      message:
        $ref: '#/components/messages/CancelOrdersRequest'

  spot/cancelAllOrders:
    description: Cancel all open orders for the account.
    servers:
      - spot-private
    publish:
      operationId: spotCancelAllOrders
      summary: Submit a cancel-all-orders command
      message:
        $ref: '#/components/messages/CancelAllOrdersRequest'

  # ---------------------------------------------------------------------------
  # Heartbeat (applies to every endpoint above)
  # Source: polo-sdk-python ws/client_base.py (_ping) and
  # polo-sdk-java PoloApiConstants EVENT_PING / EVENT_PONG.
  # ---------------------------------------------------------------------------

  heartbeat:
    description: >
      Client-side ping every few seconds; the server replies with
      {"event":"pong"}. The Poloniex Java SDK constants pin the exact JSON
      payloads.
    publish:
      operationId: heartbeatPing
      summary: Send heartbeat ping
      message:
        $ref: '#/components/messages/Ping'
    subscribe:
      operationId: heartbeatPong
      summary: Receive heartbeat pong
      message:
        $ref: '#/components/messages/Pong'

  # ---------------------------------------------------------------------------
  # Futures v3 public channels
  # Source: polo-sdk-python futures/ws/client_public.py and
  # polo-sdk-java future/common/PoloApiConstants.java
  # ---------------------------------------------------------------------------

  futures/symbol:
    description: Product (contract) metadata stream for a futures symbol.
    servers:
      - futures-public
    subscribe:
      operationId: futuresSymbolSubscribe
      summary: Receive futures product info
      message:
        $ref: '#/components/messages/FuturesProductInfoEvent'
    publish:
      operationId: futuresSymbolSubscribeRequest
      summary: Subscribe to futures symbol channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/book:
    description: Futures order book snapshots and updates.
    servers:
      - futures-public
    subscribe:
      operationId: futuresBookSubscribe
      summary: Receive futures order book updates
      message:
        $ref: '#/components/messages/FuturesOrderBookEvent'
    publish:
      operationId: futuresBookSubscribeRequest
      summary: Subscribe to futures book channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/book_lv2:
    description: Futures level 2 incremental order book updates.
    servers:
      - futures-public
    subscribe:
      operationId: futuresBookLv2Subscribe
      summary: Receive futures level 2 book updates
      message:
        $ref: '#/components/messages/FuturesOrderBookV2Event'
    publish:
      operationId: futuresBookLv2SubscribeRequest
      summary: Subscribe to futures book_lv2 channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/candles:
    description: >
      Futures candlestick updates. The `<interval>` placeholder must be one of:
      candles_minute_1, candles_minute_5, candles_minute_10, candles_minute_15,
      candles_minute_30, candles_hour_1, hour_2, hour_4, hour_6, hour_12,
      candles_day_1, candles_day_3, candles_week_1, candles_month_1. Source:
      polo-sdk-java future/common/CandlesChannels.java.
    servers:
      - futures-public
    subscribe:
      operationId: futuresCandlesSubscribe
      summary: Receive futures candlestick updates
      message:
        $ref: '#/components/messages/FuturesKlineEvent'
    publish:
      operationId: futuresCandlesSubscribeRequest
      summary: Subscribe to futures candles channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/tickers:
    description: Futures rolling 24h ticker updates.
    servers:
      - futures-public
    subscribe:
      operationId: futuresTickersSubscribe
      summary: Receive futures ticker updates
      message:
        $ref: '#/components/messages/FuturesTickersEvent'
    publish:
      operationId: futuresTickersSubscribeRequest
      summary: Subscribe to futures tickers channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/trades:
    description: Futures trade prints stream.
    servers:
      - futures-public
    subscribe:
      operationId: futuresTradesSubscribe
      summary: Receive futures trades
      message:
        $ref: '#/components/messages/FuturesTradingInfoEvent'
    publish:
      operationId: futuresTradesSubscribeRequest
      summary: Subscribe to futures trades channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/index_price:
    description: Futures index price stream.
    servers:
      - futures-public
    subscribe:
      operationId: futuresIndexPriceSubscribe
      summary: Receive index price updates
      message:
        $ref: '#/components/messages/FuturesIndexPriceEvent'
    publish:
      operationId: futuresIndexPriceSubscribeRequest
      summary: Subscribe to index_price channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/mark_price:
    description: Futures mark price stream.
    servers:
      - futures-public
    subscribe:
      operationId: futuresMarkPriceSubscribe
      summary: Receive mark price updates
      message:
        $ref: '#/components/messages/FuturesMarkPriceEvent'
    publish:
      operationId: futuresMarkPriceSubscribeRequest
      summary: Subscribe to mark_price channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/index_price_candles:
    description: >
      Futures index-price kline updates. Channel names follow the pattern
      index_candles_<interval> (e.g. index_candles_minute_1). Source:
      polo-sdk-python futures/ws/client_public.py
      subscribe_to_IndexPriceKlineData.
    servers:
      - futures-public
    subscribe:
      operationId: futuresIndexPriceCandlesSubscribe
      summary: Receive index-price kline updates
      message:
        $ref: '#/components/messages/FuturesKlineEvent'
    publish:
      operationId: futuresIndexPriceCandlesSubscribeRequest
      summary: Subscribe to index_candles_<interval> channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/mark_price_candles:
    description: >
      Futures mark-price kline updates. Channel names follow the pattern
      mark_price_candles_<interval> (e.g. mark_price_candles_minute_1).
      Source: polo-sdk-python futures/ws/client_public.py
      subscribe_to_MarkPriceKlineData.
    servers:
      - futures-public
    subscribe:
      operationId: futuresMarkPriceCandlesSubscribe
      summary: Receive mark-price kline updates
      message:
        $ref: '#/components/messages/FuturesKlineEvent'
    publish:
      operationId: futuresMarkPriceCandlesSubscribeRequest
      summary: Subscribe to mark_price_candles_<interval> channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/funding_rate:
    description: Futures funding rate stream.
    servers:
      - futures-public
    subscribe:
      operationId: futuresFundingRateSubscribe
      summary: Receive funding rate updates
      message:
        $ref: '#/components/messages/FuturesFundingRateEvent'
    publish:
      operationId: futuresFundingRateSubscribeRequest
      summary: Subscribe to funding_rate channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  # ---------------------------------------------------------------------------
  # Futures v3 private (authenticated) channels
  # Source: polo-sdk-python futures/ws/client_authenticated.py
  # ---------------------------------------------------------------------------

  futures/auth:
    description: >
      Authentication subscribe envelope for the futures private endpoint. The
      signature is identical to the spot case: base64(HMAC_SHA256(secret,
      "GET\n/ws\nsignTimestamp=<ms>")).
    servers:
      - futures-private
    publish:
      operationId: futuresAuthRequest
      summary: Authenticate the futures private session
      message:
        $ref: '#/components/messages/AuthSubscribeEnvelope'
    subscribe:
      operationId: futuresAuthAck
      summary: Receive auth acknowledgement
      message:
        $ref: '#/components/messages/AuthAck'

  futures/positions:
    description: Open positions stream for the futures account.
    servers:
      - futures-private
    subscribe:
      operationId: futuresPositionsSubscribe
      summary: Receive position updates
      message:
        $ref: '#/components/messages/FuturesPositionsEvent'
    publish:
      operationId: futuresPositionsSubscribeRequest
      summary: Subscribe to positions channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/orders:
    description: Futures order lifecycle stream.
    servers:
      - futures-private
    subscribe:
      operationId: futuresOrdersSubscribe
      summary: Receive futures order events
      message:
        $ref: '#/components/messages/FuturesOrdersEvent'
    publish:
      operationId: futuresOrdersSubscribeRequest
      summary: Subscribe to futures orders channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/trade:
    description: Futures own-trade execution stream.
    servers:
      - futures-private
    subscribe:
      operationId: futuresTradeSubscribe
      summary: Receive own-trade executions
      message:
        $ref: '#/components/messages/FuturesTradeEvent'
    publish:
      operationId: futuresTradeSubscribeRequest
      summary: Subscribe to futures trade channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

  futures/account:
    description: Futures account change stream (equity, margin, PnL).
    servers:
      - futures-private
    subscribe:
      operationId: futuresAccountSubscribe
      summary: Receive futures account changes
      message:
        $ref: '#/components/messages/FuturesAccountChangeEvent'
    publish:
      operationId: futuresAccountSubscribeRequest
      summary: Subscribe to futures account channel
      message:
        $ref: '#/components/messages/SubscribeEnvelope'

components:

  securitySchemes:
    poloniexHmac:
      type: symmetricEncryption
      description: >
        After opening the private websocket, send a subscribe message on the
        `auth` channel with params {key, signTimestamp, signature} where
        signature = base64(HMAC_SHA256(apiSecret, "GET\n/ws\nsignTimestamp=<ms>")).
        Both spot and futures private endpoints share this scheme. Source:
        polo-sdk-python ws/client_authenticated.py _authenticate /
        _get_signature.

  messages:

    SubscribeEnvelope:
      name: SubscribeEnvelope
      title: Subscribe envelope
      summary: Subscribe (or unsubscribe) to one or more channels.
      contentType: application/json
      payload:
        type: object
        required:
          - event
          - channel
        properties:
          event:
            type: string
            enum: [subscribe, unsubscribe]
            description: subscribe / unsubscribe action.
          channel:
            type: array
            items:
              type: string
            description: Channel names (e.g. ["candles_minute_1"], ["book_lv2"]).
          symbols:
            type: array
            items:
              type: string
            description: Symbols to subscribe to. Use ["all"] for the wildcard.
      examples:
        - name: subscribeBookLv2
          payload:
            event: subscribe
            channel: [book_lv2]
            symbols: [BTC_USDT]

    SubscribeEnvelopeNoSymbols:
      name: SubscribeEnvelopeNoSymbols
      title: Subscribe envelope without symbols
      summary: Some account-wide channels (e.g. balances) take no symbols list.
      contentType: application/json
      payload:
        type: object
        required:
          - event
          - channel
        properties:
          event:
            type: string
            enum: [subscribe, unsubscribe]
          channel:
            type: array
            items:
              type: string

    AuthSubscribeEnvelope:
      name: AuthSubscribeEnvelope
      title: Auth subscribe envelope
      summary: Authenticate a private session by subscribing to the `auth` channel.
      contentType: application/json
      payload:
        type: object
        required:
          - event
          - channel
          - params
        properties:
          event:
            type: string
            enum: [subscribe]
          channel:
            type: array
            items:
              type: string
              enum: [auth]
          params:
            type: object
            required:
              - key
              - signTimestamp
              - signature
            properties:
              key:
                type: string
                description: API key.
              signTimestamp:
                type: integer
                format: int64
                description: Unix timestamp in milliseconds.
              signature:
                type: string
                description: >
                  base64(HMAC_SHA256(apiSecret, "GET\n/ws\nsignTimestamp=<ms>")).
      examples:
        - name: authExample
          payload:
            event: subscribe
            channel: [auth]
            params:
              key: my-api-key
              signTimestamp: 1716998400000
              signature: 6n2Q...base64...

    AuthAck:
      name: AuthAck
      title: Auth acknowledgement
      contentType: application/json
      payload:
        type: object
        properties:
          event:
            type: string
          channel:
            type: string
          data:
            type: object
            properties:
              success:
                type: boolean
              message:
                type: string

    Ping:
      name: Ping
      title: Heartbeat ping
      contentType: application/json
      payload:
        type: object
        properties:
          event:
            type: string
            enum: [ping]

    Pong:
      name: Pong
      title: Heartbeat pong
      contentType: application/json
      payload:
        type: object
        properties:
          event:
            type: string
            enum: [pong]

    # -------------------------------------------------------------------------
    # Spot public event payloads (wrapped in PoloEvent envelope)
    # -------------------------------------------------------------------------

    CandlestickEvent:
      name: CandlestickEvent
      title: Candlestick event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Candlestick'

    TradeEvent:
      name: TradeEvent
      title: Trade event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Trade'

    TickerEvent:
      name: TickerEvent
      title: Ticker event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Ticker'

    BookEvent:
      name: BookEvent
      title: Order book event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Book'

    BookLv2Event:
      name: BookLv2Event
      title: Level 2 order book event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_BookLv2'

    SymbolEvent:
      name: SymbolEvent
      title: Symbol metadata event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Symbol'

    CurrenciesEvent:
      name: CurrenciesEvent
      title: Currency metadata event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Currencies'

    ExchangeEvent:
      name: ExchangeEvent
      title: Exchange mode event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Exchange'

    # -------------------------------------------------------------------------
    # Spot private event payloads
    # -------------------------------------------------------------------------

    OrderEvent:
      name: OrderEvent
      title: Order lifecycle event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Order'

    BalanceEvent:
      name: BalanceEvent
      title: Balance change event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_Balance'

    CreateOrderRequest:
      name: CreateOrderRequest
      title: Create order command
      contentType: application/json
      payload:
        type: object
        required:
          - event
          - params
        properties:
          id:
            type: string
            description: Optional client-side correlation id.
          event:
            type: string
            enum: [createOrder]
          params:
            type: object
            properties:
              symbol:
                type: string
              type:
                type: string
                enum: [MARKET, LIMIT, LIMIT_MAKER]
              quantity:
                type: string
              side:
                type: string
                enum: [BUY, SELL]
              price:
                type: string
              timeInForce:
                type: string
                enum: [GTC, IOC, FOK]
              clientOrderId:
                type: string

    CancelOrdersRequest:
      name: CancelOrdersRequest
      title: Cancel orders command
      contentType: application/json
      payload:
        type: object
        required:
          - event
          - params
        properties:
          id:
            type: string
          event:
            type: string
            enum: [cancelOrders]
          params:
            type: object
            properties:
              orderIds:
                type: array
                items:
                  type: string
              clientOrderIds:
                type: array
                items:
                  type: string

    CancelAllOrdersRequest:
      name: CancelAllOrdersRequest
      title: Cancel all orders command
      contentType: application/json
      payload:
        type: object
        required:
          - event
        properties:
          id:
            type: string
          event:
            type: string
            enum: [cancelAllOrders]
          params:
            type: object

    # -------------------------------------------------------------------------
    # Futures public event payloads
    # -------------------------------------------------------------------------

    FuturesProductInfoEvent:
      name: FuturesProductInfoEvent
      title: Futures product info event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesProductInfo'

    FuturesOrderBookEvent:
      name: FuturesOrderBookEvent
      title: Futures order book event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesOrderBook'

    FuturesOrderBookV2Event:
      name: FuturesOrderBookV2Event
      title: Futures level 2 order book event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesOrderBookV2'

    FuturesKlineEvent:
      name: FuturesKlineEvent
      title: Futures kline event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesKline'

    FuturesTickersEvent:
      name: FuturesTickersEvent
      title: Futures tickers event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesTickers'

    FuturesTradingInfoEvent:
      name: FuturesTradingInfoEvent
      title: Futures trade event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesTradingInfo'

    FuturesIndexPriceEvent:
      name: FuturesIndexPriceEvent
      title: Futures index price event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesIndexPrice'

    FuturesMarkPriceEvent:
      name: FuturesMarkPriceEvent
      title: Futures mark price event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesMarkPrice'

    FuturesFundingRateEvent:
      name: FuturesFundingRateEvent
      title: Futures funding rate event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesFundingRate'

    # -------------------------------------------------------------------------
    # Futures private event payloads
    # -------------------------------------------------------------------------

    FuturesPositionsEvent:
      name: FuturesPositionsEvent
      title: Futures positions event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesPositions'

    FuturesOrdersEvent:
      name: FuturesOrdersEvent
      title: Futures orders event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesOrders'

    FuturesTradeEvent:
      name: FuturesTradeEvent
      title: Futures trade event (own executions)
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesTrade'

    FuturesAccountChangeEvent:
      name: FuturesAccountChangeEvent
      title: Futures account change event
      contentType: application/json
      payload:
        $ref: '#/components/schemas/PoloEnvelope_FuturesAccountChange'

  schemas:

    # -------------------------------------------------------------------------
    # Generic envelope (spot uses PoloEvent<T>; futures uses the same shape)
    # Source: polo-sdk-java spot/model/event/spot/PoloEvent.java
    # -------------------------------------------------------------------------

    PoloEnvelopeBase:
      type: object
      properties:
        event:
          type: string
          description: Server-side event type (e.g. subscribe, message, error).
        channel:
          type: string
          description: Channel that produced the data.
        symbols:
          type: array
          items:
            type: string
        action:
          type: string
          enum: [snapshot, update]
        message:
          type: string

    PoloEnvelope_Candlestick:
      allOf:
        - $ref: '#/components/schemas/PoloEnvelopeBase'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/CandlestickData'

    PoloEnvelope_Trade:
      allOf:
        - $ref: '#/components/schemas/PoloEnvelopeBase'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/TradeData'

    PoloEnvelope_Ticker:
      allOf:
        - $ref: '#/components/schemas/PoloEnvelopeBase'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/TickerData'

    PoloEnvelope_Book:
      allOf:
        - $ref: '#/components/schemas/PoloEnvelopeBase'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/BookData'

    PoloEnvelope_BookLv2:
      allOf:
        - $ref: '#/components/schemas/PoloEnvel

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