Connection Guide
If you require brokerage functionality, you will need to establish a brokerage session prior to opening a websocket, just as is required before making requests to /iserver endpoints. Please see Authentication for more details.
Request Session Information
First make request the /tickle endpoint and save the returned session value.
Retrieve the Session Token
We are then specifically interested in the “session” value in the response as we can pass this to our websocket for confirming our sessionId.
Establishing the Websocket
Client Portal Gateway
When connecting with the Client Portal Gateway, users must submit the upgrade request to wss://localhost:5000/v1/api/ws. The cookie header must include the session token from step 2, like api={"d21b8cf5ebc8ea01c6ce37c8125ec83f"}
Python
Establishing the Websocket with OAuth 1.0a
The process for those authenticating with OAuth 1.0a is similar with a few select changes. Upgrade requests should be directed to wss://api.ibkr.com/v1/api/ws. And in addition to the API cookie, you must also include the "oauth_token" query param which should be set to the user’s access token value.
Python
Establishing the Websocket with OAuth 2.0
OAuth 2.0 follows an identical process while leveraging the bearer token. Upgrade requests should be directed to wss://api.ibkr.com/v1/api/ws. And in addition to the API cookie, you must also include the "bearer_token" query param which should be set to the user’s bearer token value.
Python
Send a Websocket Topic
After establishing your session, await the Authentication Status response with topic `“sts” to indicate the websocket connection has been successfully established.
The Python example below decodes the binary response to UTF-8 before converting the content to a JSON object. This allows the user to decode the message to check for the "sts" topic before sending our Order Updates request.

