AsyncAPI definition for the Interactive Brokers (IBKR) Client Portal Web API streaming WebSocket endpoint. The Client Portal API exposes a single WebSocket endpoint at `/v1/api/ws` over which clients subscribe to and receive market data, order updates, trades, profit-and-loss, market depth, historical bars, notifications, bulletins, account updates, and connectivity messages. Source: Interactive Brokers Client Portal API documentation (https://interactivebrokers.github.io/cpwebapi/, section "Websockets"). Message wire format is text. Solicited (client-to-server) messages use the form `TOPIC+{ARGUMENTS}` where TOPIC is a short three-character code that begins with `s` to subscribe and `u` to unsubscribe, and ARGUMENTS is a JSON object (possibly empty `{}`). Unsolicited (server-to-client) messages are JSON objects with a `topic` field identifying the stream.
Streaming, top-of-book (level 1) market data for a single contract. Subscribe message is `smd+conId+{"fields":[...]}` where `conId` is the IBKR contract identifier and `fields` is an array of market data field identifiers (see `/iserver/marketdata/snapshot` for the field reference). Contracts use SMART routing by default; specify `conId@EXCHANGE` to route a specific exchange. Unsubscribe with `umd+conId+{}`.
umd+{conId}
publishunsubscribeMarketData
Unsubscribe from streaming market data
Unsubscribe from streaming market data for a single contract.
smh+{conId}
publishsubscribeHistorical
Subscribe to streaming historical bars
Streaming historical market data bars for a single contract. Subscribe with `smh+conId+{...}` where the JSON arguments may include `exchange`, `period` (e.g. `1d`, `2h`, `30min`), `bar` (bar size e.g. `5min`, `1h`, `1d`), `outsideRTH` (boolean), `source` (`midpoint|trades|bid_ask|bid| ask`), and `format` (e.g. `%o/%c/%h/%l/%v`). A maximum of 5 concurrent historical data subscriptions is permitted. Unsubscribe with `umh+serverId` using the `serverId` returned in the response.
umh+{serverId}
publishunsubscribeHistorical
Unsubscribe from historical bars
Unsubscribe from a historical data subscription using its server-assigned id.
sbd+{acctId}+{conId}+{exchange}
publishsubscribeBookDepth
Subscribe to market depth (deep book)
Subscribe to deep book (market depth) data. Sent as `sbd+{acctId}+{conId}+{exchange}` where `exchange` is optional; if omitted all available deep exchanges are assumed. Requires a valid market data subscription. Unsubscribe with `ubd+{acctId}`.
ubd+{acctId}
publishunsubscribeBookDepth
Unsubscribe from market depth
Unsubscribe from market depth for the specified account.
sor
publishsubscribeLiveOrders
Subscribe to live order updates
Subscribe to live order updates. Sent as `sor+{}`. Once subscribed, the server relays incremental changes to working orders (status changes, partial fills, etc.). Use `/iserver/account/orders` to fetch the initial day's orders before subscribing. Unsubscribe with `uor+{}`.
uor
publishunsubscribeLiveOrders
Unsubscribe from live order updates
Unsubscribe from live order updates.
str
publishsubscribeTrades
Subscribe to trade history and live trade updates
Subscribe to trades for the current and previous six trading days. Sent as `str+{}`. Optional arguments: `realtimeUpdatesOnly` (boolean) to stream only new trades, and `days` (integer 1-7) to bound historical trade depth. Unsubscribe with `utr`.
utr
publishunsubscribeTrades
Unsubscribe from trades
Unsubscribe from trade updates.
spl
publishsubscribePnl
Subscribe to profit-and-loss updates
Subscribe to profit-and-loss updates for existing positions. Sent as `spl+{}`. Daily PnL (`dpl`) and unrealized PnL (`upl`) are returned per account partition. Updates are typically delivered at approximately 1Hz during market hours but vary with market activity. Unsubscribe with `upl+{}`.
upl
publishunsubscribePnl
Unsubscribe from profit-and-loss updates
Unsubscribe from profit-and-loss updates.
tic
publishpingSession
Ping the session
Ping the session to keep `/iserver` and `/ccp` endpoints alive. Sent as `tic` (no arguments). IBKR advises pinging at least once per minute. A periodic call to the REST `/tickle` endpoint is still required for session maintenance.
system
subscribeonSystem
Receive system / heartbeat messages
Unsolicited system connection messages. On initial connect the topic `system` echoes back the authenticated username; every ~10 seconds a heartbeat with a unix-millisecond timestamp is sent.
sts
subscribeonAuthStatus
Receive authentication status messages
Unsolicited authentication status messages. Sent on initial connect and whenever the session authentication status changes (for example, when a competing session is detected).
ntf
subscribeonNotification
Receive notifications
Unsolicited notification messages for brief trading-activity related notices.
blt
subscribeonBulletin
Receive bulletins
Unsolicited bulletin messages for urgent communications such as exchange issues, system problems, and other trading information.
act
subscribeonAccount
Receive account updates
Unsolicited account updates. An initial message is sent on connect with details about all brokerage accounts the logged-in user has access to; supplemental messages are sent whenever account details change.
Messages
✉
SubscribeMarketData
smd+conId+{fields}
Subscribe to streaming market data for a contract.
✉
UnsubscribeMarketData
umd+conId+{}
✉
MarketDataTick
Market data tick
Streaming top-of-book tick for the subscribed contract.
✉
SubscribeHistorical
smh+conId+{params}
✉
UnsubscribeHistorical
umh+serverId
✉
HistoricalBars
Historical bar response
✉
SubscribeBookDepth
sbd+acctId+conId+exchange
✉
UnsubscribeBookDepth
ubd+acctId
✉
BookDepth
Market depth update
✉
SubscribeLiveOrders
sor+{}
✉
UnsubscribeLiveOrders
uor+{}
✉
LiveOrders
Live order update
✉
SubscribeTrades
str+{}
✉
UnsubscribeTrades
utr
✉
Trades
Trade message
✉
SubscribePnl
spl+{}
✉
UnsubscribePnl
upl+{}
✉
Pnl
Profit-and-loss update
✉
PingSession
tic
✉
System
System / heartbeat message
✉
AuthStatus
Authentication status (sts)
✉
Notification
Notification (ntf)
✉
Bulletin
Bulletin (blt)
✉
Account
Account updates (act)
Servers
wss
productionapi.ibkr.com/v1/api/ws
Production Client Portal WebSocket endpoint. Authentication is performed with the session cookie obtained from a prior authenticated REST request to the Client Portal API (typically `/tickle` returns the `sessionId`). Browsers attach the session cookie automatically; non-browser clients should send an initial JSON message of the form `{"session":""}` after the socket opens.
wss
gatewaylocalhost:5000/v1/api/ws
Local Client Portal Gateway WebSocket endpoint (default port 5000). This is the endpoint used by clients running the IBKR client portal gateway locally. Authentication uses the gateway session cookie or the same `{"session":""}` initial message.