### Sample Response for Get All Watchlists Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example of the JSON response structure when retrieving watchlists. It includes details about user lists and system settings. ```JSON { "data": { "scanners_only": false, "show_scanners": false, "bulk_delete": false, "user_lists": [ { "is_open": false, "read_only": false, "name": "Test Watchlist", "modified": 1702581306241, "id": "1234", "type": "watchlist" } ] }, "action": "content", "MID": "1" } ``` -------------------------------- ### Get Portfolio Subaccounts (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to make a GET request to retrieve portfolio subaccounts. Ensure the 'requests' library is installed and baseUrl is correctly configured. ```python request_url = f"{baseUrl}/portfolio/subaccounts" requests.get(url=request_url) ``` -------------------------------- ### Example Subscription Response Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example of the response object returned when fetching the list of subscriptions. It details notification codes, modification availability, and descriptions. ```json [ { "FC": "M8", "H": 0, "A": 1, "FD": "Notify me when I establish position subject to US dividend tax withholding 871(m) rules.", "FN": "871(m) Trades" }, { "FC": "AA", "H": 0, "A": 1, "FD": "Notifications related to account activity such as funding, application, trading and market data permission status", "FN": "Account Activity" }, {...} ] ``` -------------------------------- ### Example Authorization URL Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example of the URL users are redirected to after logging in, containing the oauth_token and oauth_verifier query parameters. ```plaintext https://localhost:20000/?oauth_token=b9082d68cfef06b030de&oauth_verifier=0ffb93ab9aa0d2177cc2 ``` -------------------------------- ### Example Enable/Disable Subscription Response Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example of the response object returned after enabling or disabling a subscription. It indicates acknowledgment and processing time. ```json { "V": 1, "T": 10 } ``` -------------------------------- ### Check Java Installation Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Verify if Java Runtime Environment is installed and correctly configured by running this command in your terminal. An error indicates Java is not properly set up. ```bash java -version ``` -------------------------------- ### cURL Request for Market Data Snapshot Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Example of how to make a GET request to the market data snapshot endpoint using cURL. Ensure you replace {{baseUrl}} with your actual base URL. ```bash curl \ --url {{baseUrl}}/iserver/marketdata/snapshot?conids=265598,8314&fields=31,84,86 \ --request GET ``` -------------------------------- ### Example Contract Details Response Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example JSON response from the /iserver/secdef/info endpoint, providing details for a specific option contract. The 'conid' is crucial for subsequent requests. ```json [ { "conid": 654371995, "symbol": "SPX", "secType": "OPT", "exchange": "SMART", "listingExchange": null, "right": "P", "strike": 3975.0, "currency": "USD", "cusip": null, "coupon": "No Coupon", "desc1": "SPX", "desc2": "JAN 16 '25 3975 Put (AM)", "maturityDate": "20250116", "multiplier": "100", "tradingClass": "SPX", "validExchanges": "SMART,CBOE,IBUSOPT" } ] ``` -------------------------------- ### Python Request for Market Data Snapshot Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Example of how to construct a request URL and send a GET request to the market data snapshot endpoint using Python's requests library. Specify contract IDs (conids) and desired data fields. ```python request_url = f"{baseUrl}/iserver/marketdata/snapshot?conids=265598,8314&fields=31,84,86" requests.get(url=request_url) ``` -------------------------------- ### Currency Pairs Response Example Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Example JSON response structure for the currency pairs endpoint, showing available pairs for a target currency. ```JSON { "USD": [ { "symbol": "USD.SGD", "conid": 37928772, "ccyPair": "SGD" }, {"..."}, { "symbol": "USD.RUB", "conid": 28454968, "ccyPair": "RUB" } ] } ``` -------------------------------- ### Currency Exchange Rate Response Example Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Example JSON response for the currency exchange rate endpoint, providing the exchange rate for a given currency pair. ```JSON { "rate": 0.67005002 } ``` -------------------------------- ### Live Market Data Snapshot Response Example Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Example JSON response structure for the market data snapshot endpoint. It includes update timestamps, contract details, server identifiers, and requested field values. ```json [ { "_updated": 1702334859712, "conidEx": "265598", "conid": 265598, "server_id": "q1", "6119": "serverId", "31": "193.18", "84": "193.06", "86":"193.14", "6509": "RpB" } ] ``` -------------------------------- ### Retrieve Live Orders (GET Request) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use the GET /iserver/account/orders endpoint to retrieve a list of live orders. Ensure you have switched to the correct account using the /iserver/account endpoint first. ```http GET /iserver/account/orders ``` -------------------------------- ### Initialize Brokerage Session (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this snippet to initialize a brokerage session. Ensure 'publish' and 'compete' are set to True for immediate and prioritized connection. ```Python request_url = "{baseUrl}/iserver/auth/ssodh/init" json_content= {"publish":True,"compete":True} requests.post(url=request_url, json=json_content) ``` -------------------------------- ### Get Contract Rules (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to make a GET request to retrieve contract rules for a specified conid. Ensure you have the 'requests' library installed. ```python import requests url = "{{base-url}}/forecast/contract/rules?conid=767285167" payload = {} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Run Client Portal Gateway (Windows) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Launch the Client Portal Gateway on a Windows system using the provided batch script. Ensure you are in the gateway's directory and specify the configuration file. ```bash bin\run.bat root\conf.yaml ``` -------------------------------- ### Place Order with Python Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Example of placing an order using Python. This snippet demonstrates how to construct the JSON payload for an order, including details like account ID, order type, price, and trailing parameters. ```python request_url = f"{baseUrl}/iserver/account/U1234567/orders" json_content = { "orders": [ { "acctId": "U1234567", "conid": 265598, "conidex": "265598@SMART", "manualIndicator": True, "extOperator":"person1234", "secType": "265598@STK", "cOID": "AAPL-BUY-100", "parentId": None, "orderType": "TRAILLMT", "listingExchange": "NASDAQ", "isSingleGroup": false, "outsideRTH": true, "price": 185.50, "auxPrice": 183, "side": "BUY", "ticker": "AAPL", "tif": "GTC", "trailingAmt": 1.00, "trailingType": "amt", "referrer": "QuickTrade", "quantity": 100, } ] } ``` -------------------------------- ### Get Trading Schedule for AAPL (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Constructs the URL and makes a GET request to retrieve the trading schedule for a specific stock symbol. Ensure you have the 'requests' library installed. ```python request_url = f"{baseUrl}/trsrv/secdef//schedule?assetClass=STK&conid=265598&symbol=AAPL&exchange=ISLAND&exchangeFilter=ISLAND" requests.get(url=requests_url) ``` -------------------------------- ### Run Client Portal Gateway (Unix) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Launch the Client Portal Gateway on a Unix-based system using the provided shell script. Ensure you are in the gateway's directory and specify the configuration file. ```bash bin/run.sh root/conf.yaml ``` -------------------------------- ### Get Delivery Options Request (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to make a GET request to retrieve FYI delivery options. Ensure you have the 'requests' library installed and the base URL configured. ```python request_url = f"{baseUrl}/fyi/deliveryoptions" requests.get(url=request_url) ``` -------------------------------- ### POST /whatif Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Simulates an order placement for a given account. The request body structure is identical to the standard order placement endpoint. ```APIDOC ## POST /whatif ### Description Simulates an order placement for a given account. The request body structure is identical to the standard order placement endpoint. ### Method POST ### Endpoint /iserver/account/{accountId}/orders/whatif ### Parameters #### Path Parameters - **accountId** (string) - Required - The ID of the account for which to simulate the order. ### Request Body Refer to the 'Place Order' section for the structure of the request object. It includes fields such as `conid`, `orderType`, `price`, `side`, `tif`, and `quantity`. ### Request Example ```json { "orders": [ { "conid": 265598, "orderType": "LMT", "price": 200.25, "side": "BUY", "tif": "DAY", "quantity": 5 } ] } ``` ### Response #### Success Response (200) (Response structure is similar to the standard order placement response, indicating the simulated order details.) ``` -------------------------------- ### Response for Get Disclaimer Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Example JSON response when retrieving an FYI disclaimer. Contains the typecode and the disclaimer message. ```JSON { "FC": "SM", "DT": "This communication is provided for information purposes only and is not intended as a recommendation or a solicitation to buy, sell or hold any investment product. Customers are solely responsible for their own trading decisions." } ``` -------------------------------- ### Get All Watchlists (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to retrieve all user-created watchlists. Ensure you have the 'requests' library installed and the base URL configured. ```Python request_url = f"{baseUrl}/iserver/watchlist?SC=USER_WATCHLIST" requests.get(url=request_url) ``` -------------------------------- ### Get Trading Schedule (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to request the trading schedule for a specific contract. Ensure you have the 'requests' library installed. ```python request_url = f"{baseUrl}/contract/trading-schedule?conid=265598&exchange=ISLAND" requests.get(url=requests_url) ``` -------------------------------- ### Get Contract Trading Schedules (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to request trading schedules for a given contract ID. Ensure you have the 'requests' library installed. ```python import requests url = "{{base-url}}/forecast/contract/schedules?conid=767285167" payload = {} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Get Delivery Options Response Object Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example of the JSON response object returned when requesting delivery options. It indicates email status and lists enabled devices. ```json { "E": [ { "NM": "iPhone", "I": "apn://mtws@1234E5E67D8A9012EC3E45D6E7D89A01F2345CDBBB678B9BE0FB12345AF6D789", "UI": "apn://mtws@1234E5E67D8A9012EC3E45D6E7D89A01F2345CDBBB678B9BE0FB12345AF6D789", "A": 1 } ], "M": 1 } ``` -------------------------------- ### Constructing an Option Exercise Request Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example of constructing a user input request to exercise an option. It specifies the ID of the option, the desired user action ('submit'), and exercise parameters like 'make_final' and the quantity ('value'). ```json inp+exercise+{"action":"user_input","data":{"id":"5","user_action":"submit","exercise":{"allowed":"not_shown","make_final":true,"value":5}}} ``` -------------------------------- ### Get Forecast Contracts by Market (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to retrieve all forecast contracts for a given underlying market and exchange. Ensure you have the 'requests' library installed. ```Python import requests url = "{{base-url}}/forecast/contract/market?underlyingConid=766914406&exchange=FORECASTX" payload = {} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Get Future Contracts by Symbol (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to request future contracts for given symbols. Ensure you have the 'requests' library installed and 'baseUrl' defined. ```python request_url = f"{baseUrl}/trsrv/futures?symbols=ES,MES" requests.get(url=request_url) ``` -------------------------------- ### Retrieve Allocation Presets (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to fetch the current allocation preset configurations for your account. Ensure you have the 'requests' library installed. ```Python request_url = f"{{baseUrl}}/iserver/account/allocation/presets" requests.get(url=request_url) ``` -------------------------------- ### Python Request for All Conids Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to send a GET request to the /trsrv/all-conids endpoint. Specify the desired exchange in the URL. Ensure you have the 'requests' library installed. ```python request_url = f"{baseUrl}/trsrv/all-conids?exchange=AMEX" requests.get(url=request_url) ``` -------------------------------- ### Brokerage Session Initialization Response Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is an example response after initializing a brokerage session. It indicates authentication status, connection state, and server information. ```JSON { "authenticated": true, "competing": false, "connected": true, "message": "", "MAC": "98:F2:B3:23:BF:A0", "serverInfo": { "serverName": "JifN19053", "serverVersion": "Build 10.25.0p, Dec 5, 2023 5:48:12 PM" } } ``` -------------------------------- ### Python Request for Regulatory Snapshot Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to send a GET request to the regulatory snapshot endpoint. Ensure you have the 'requests' library installed. The conid parameter is required. ```python request_url = f"{{baseUrl}}/md/regsnapshot?conid=265598" requests.get(url=request_url) ``` -------------------------------- ### Position Data Example Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Shows a JSON array containing position data for multiple assets, including account ID, contract details, market value, and PnL. ```json [ { "acctId": "U1234567", "conid": 265598, "contractDesc": "AAPL", "position": 614.2639, "mktPrice": 197.3840027, "mktValue": 121245.87, "currency": "USD", "avgCost": 192.7477563, "avgPrice": 192.7477563, "realizedPnl": 0.0, "unrealizedPnl": 2847.88, "exchs": null, "expiry": null, "putOrCall": null, "multiplier": null, "strike": 0.0, "exerciseStyle": null, "conExchMap": [], "assetClass": "STK", "undConid": 0, "model": "" }, { "acctId": "U1234567", "conid": 8894, "contractDesc": "KO", "position": 11.0, "mktPrice": 59.2400017, "mktValue": 651.64, "currency": "USD", "avgCost": 61.9409091, "avgPrice": 61.9409091, "realizedPnl": 0.0, "unrealizedPnl": -29.71, "exchs": null, "expiry": null, "putOrCall": null, "multiplier": null, "strike": 0.0, "exerciseStyle": null, "conExchMap": [], "assetClass": "STK", "undConid": 0, "model": "" } ] ``` -------------------------------- ### Get Contract Info (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to request full contract details for a given conid. Ensure you have the 'requests' library installed and the base URL configured. ```python request_url = f"{{baseUrl}}/iserver/contract/265598/info" requests.get(url=request_url) ``` -------------------------------- ### Initialize Brokerage Session (cURL) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This cURL command initializes a brokerage session. It sends a POST request with session parameters to the specified URL. ```cURL curl \ --url {{baseUrl}}/iserver/auth/ssodh/init \ --request POST \ --header 'Content-Type:application/json' \ --data '{ "publish":true, "compete":true }' ``` -------------------------------- ### Get Alert Details (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to request details of a specific alert by its order ID. Ensure you have the 'requests' library installed and the 'baseUrl' variable defined. ```python request_url = f"{baseUrl}/iserver/account/alert/9876543210?type=Q" requests.get(url=request_url) ``` -------------------------------- ### Establish Websocket Connection (cURL) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This cURL command demonstrates how to establish a websocket connection to the Client Portal Gateway. It includes the necessary headers for upgrading the connection and the authentication cookie. ```bash curl -i -k -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "origin: interactivebrokers.github.io" --cookie "api=d21b8cf5ebc8ea01c6ce37c8125ec83f" wss://localhost:5000/v1/api/ws ``` -------------------------------- ### Get Portfolio Combo Positions (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to retrieve combo positions for a given account ID. Ensure you have the 'requests' library installed and the base URL configured. ```python request_url = f"{baseUrl}/portfolio/U1234567/combo/positions?nocache=true" requests.get(url=request_url) ``` -------------------------------- ### OAuth Parameters Example Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This JSON object contains a sample set of OAuth parameters required for API requests. Ensure all fields are correctly populated with your credentials and generated values. ```json { "diffie_hellman_challenge": "5356ee6f78fc204b22e2012636d23116e4158ee84aa4451c4a8d3f595ec83434497073e25697ab23cc912799dadeef39fe243d317f193659e488535a31dbcb814600ffad3fd76b076e7f1c54cf045395c1f01d982a358f3202dd6b546271498040f4687959b7b240bc6222902d24e1bf5de42ae0a46cc60f41f62a58d428932a92e5954e7980384a9e1e0b918a35f0a838e0c4c3d0cb32db759b5cbda371e035740d9c0030b1619b61e928b8d12ca141bd3fe74ac10a835382125a57837c84b5bd1873bd118f92657b8dd45e48652093e5c0c3a5dacfb4d140e5672ddc05eb1d90bc29c433e744ae8950e96590668a9b8503e596780b14852be639ce3b5ba2c0", "oauth_consumer_key": "TESTCONS", "oauth_token": "e84c11dc149cb96ee5bb", "oauth_signature_method": "RSA-SHA256", "oauth_signature": "czbA1dRKJSBdwn5GYxAJQCmCAqfZ6dyOa%2FgmuY%2F5Lhub64cSeQUzKp8vGrF6afnXhCiIXnHsCTONK7uNbRu2V%2FE%2FziQ57BWfbAEzH98kQdWAlWqqmaxXBzbg%2Fr1AZDRP%2FYWrEggNvJaHjbkWaotcrAWpsfxVLcdc3Sl7kXmbFYN0u20MjLUD7q5yDrJT5TXw9JC2xvFimJj65WxqyICZizQUUrg35KRQKaxytQFdwqf5RS6B65gmoi7gHXZcDu2zDWGhe67bZKV8myd0isIJZBs8a5alGd33n7Y1V7pv5Ux9hFOEHEBzSaE3kn9dqw%2Fp5w%2Fl%2F0xiOQGpXWvPRVA2uA%3D%3D", "oauth_timestamp": "1722886871", "oauth_nonce": "e8181dd345bcc1a7237df79cd1b59219", "realm": "test_realm" } ``` -------------------------------- ### Enable Flex Web Service Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Enables the Flex Web Service and saves credentials. This action provides a new 'Current Token' for subsequent requests. ```text Click the empty box next to Flex Web Service Status to enable the Flex Web Service, and then click “Save” to save your credentials. ``` -------------------------------- ### Retrieve Forecast Category Tree (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python script to make a GET request to the /forecast/category/tree endpoint. Ensure you have the 'requests' library installed. The response text will be printed to the console. ```python import requests url = "{{base-url}}/forecast/category/tree" payload = {} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Establish Websocket Connection (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This Python code snippet demonstrates how to establish a websocket connection using the `websocket-client` library. It includes the URL, event handlers, and the necessary cookie for authentication. ```python ws = websocket.WebSocketApp( url="wss://localhost:5000/v1/api/ws", on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close, cookie=f"api={sessionToken}" ) ws.run_forever() ``` -------------------------------- ### Retrieve Order Status (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to make a GET request to the order status endpoint. Replace '1234567890' with your actual order ID. Ensure you have the 'requests' library installed. ```Python request_url = f"{baseUrl}/iserver/account/order/status/1234567890" requests.get(url=request_url) ``` -------------------------------- ### Handle User Prompt with Options Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This JSON structure represents a user prompt with available actions. Use this to display warnings or confirmations to the user. ```json {"data":{"user_actions":[{"id":"continue","text":"Continue"},{"id":"cancel","text":"Cancel"}],"id":7,"text":"This exercise request will be final and irreversible. Once submitted, the option position and the stock position will update immediately.","title":"Warning"},"MID":"19","action":"prompt","topic":"inp+exercise"} ``` -------------------------------- ### Get Contract Details (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to retrieve contract rules for specific event binary options by providing the contract ID (conid). Ensure you have the 'requests' library installed. ```python import requests url = "{{base-url}}/forecast/contract/details?conid=767285167" payload = {} headers = {} response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Sample Portfolio Response Object Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This JSON object represents a sample response for portfolio data, including account details, contract information, and market values. ```json [ { "acctId": "U1234567", "conid": 265598, "contractDesc": "AAPL", "position": 614.2639, "mktPrice": 197.7639923, "mktValue": 121479.28, "currency": "USD", "avgCost": 192.7477563, "avgPrice": 192.7477563, "realizedPnl": 0.0, "unrealizedPnl": 3081.29, "exchs": null, "expiry": null, "putOrCall": null, "multiplier": null, "strike": 0.0, "exerciseStyle": null, "conExchMap": [], "assetClass": "STK", "undConid": 0, "model": "" } ] ``` -------------------------------- ### Python Request for Stocks by Symbol Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to construct the request URL and send a GET request to retrieve stock contracts for specified symbols. Ensure you have the 'requests' library installed. ```python request_url = f"{baseUrl}/trsrv/stocks?symbols=AAPL,IBKR" requests.get(url=request_url) ``` -------------------------------- ### Get Trades with Specific Number of Days (Python) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This Python snippet demonstrates how to call the trades endpoint, specifying the number of past days to retrieve trade data for. Ensure you have the 'requests' library installed. ```Python request_url = f"{baseUrl}/iserver/account/trades?days=3" requests.get(url=request_url) ``` -------------------------------- ### Initialize Brokerage Session Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 This is essential for using all endpoints besides /portfolio, including access to trading and market data. It initializes a brokerage session, which can optionally disconnect other sessions to prioritize this one. ```APIDOC ## POST /iserver/auth/ssodh/init ### Description Initializes a brokerage session. This is required for accessing trading and market data endpoints. The request can optionally disconnect other brokerage sessions to prioritize this connection. ### Method POST ### Endpoint /iserver/auth/ssodh/init ### Parameters #### Request Body - **publish** (Boolean) - Required - Determines if the request should be sent immediately. Users should always pass true. - **compete** (Boolean) - Required - Determines if other brokerage sessions should be disconnected to prioritize this connection. ### Request Example ```json { "publish": true, "compete": true } ``` ### Response #### Success Response (200) - **authenticated** (Boolean) - Returns whether your brokerage session is authenticated or not. - **competing** (Boolean) - Returns whether you have a competing brokerage session in another connection. - **connected** (Boolean) - Returns whether you are connected to the gateway, authenticated or not. - **message** (String) - If there is a message about your authenticate status, it will be returned here. Authenticated sessions return an empty string. - **MAC** (String) - IBKR MAC information. Internal use only. - **serverInfo** (Object) - **serverName** (String) - IBKR server information. Internal use only. - **serverVersion** (String) - IBKR version information. Internal use only. #### Response Example ```json { "authenticated": true, "competing": false, "connected": true, "message": "", "MAC": "98:F2:B3:23:BF:A0", "serverInfo": { "serverName": "JifN19053", "serverVersion": "Build 10.25.0p, Dec 5, 2023 5:48:12 PM" } } ``` ``` -------------------------------- ### Python Request for Strikes Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Use this Python snippet to construct and send a GET request to the /iserver/secdef/strikes endpoint. Ensure you have the 'requests' library installed. The 'baseUrl' variable should be set to your IBKR API base URL. ```python request_url = f"{baseUrl}/iserver/secdef/strikes?conid=265598§ype=OPT&month=JAN24&exchange=SMART" requests.get(url=request_url) ``` -------------------------------- ### Navigate to Client Portal Gateway Directory (Windows) Source: https://ibkrcampus.com/campus/ibkr-api-page/cpapi-v1 Change the current directory to the Client Portal Gateway's root folder on a Windows system. This is a prerequisite for running the gateway. ```bash cd C:/Users/Example/Downloads/clientportal.gw ```