Close Navigation
Learn more about IBKR accounts

Introduction to the TWS Excel API & Initial Setup

Lesson 1 of 6

Duration 5:49
Level Beginner

To watch this video you must accept functional cookies.

Prerequisites

Microsoft Office Excel (Windows Only)

Java Runtime Environment (JRE)

Before we begin, there are some prerequisites the TWS API requires. For example, if are looking to use our excel APIs, you would need Java and a Windows copy of Microsoft Excel installed.

Overview of the TWS API

The Interactive Brokers’ TWS APIs allows other applications and programs to work with the Trader Workstation (TWS) or IB Gateway. Trader Workstation is our flagship trading platform and IB Gateway is the lightweight version without any of the manual trading features.

In this course, we will cover connecting Microsoft Excel to TWS so we can retrieve market data, place orders, view account and portfolio data and much more! We’ll explore a sample spreadsheet that has been created by IBKR to highlight the functionality of the Excel TWS API. You can reference the sample spreadsheet as we show you examples in this course. We’ll also cover making an API request, such as retrieving market data, using a blank Excel spreadsheet. This way you’ll know how to connect your existing spreadsheet with TWS.

Let’s briefly cover the TWS API a bit more in depth, and its capabilities.

Downloading and installing TWS

Before we get started, make sure you have TWS or IB Gateway installed, If you don’t, you can head over to our website, ibkr.com, select “Log In” in the upper right hand corner of the page and from the drop down menu, select Trader Workstation or API: IB Gateway.

They can also be found on our main website, under the menu Trading, then Platforms.

In addition, there are some prerequisites the TWS API requires. For example, if are looking to use our excel APIs, you would need Java and a Windows copy of Microsoft Excel installed.

The latest version of our Excel APIs are supported with both 32-bit and 64-bit Operating Systems. However, they are not compatible with the Mac Operating System. Our website will automatically provide a download version but you may choose a different version if you’d like.

Installing the TWS API

To obtain all the components required to use the Excel APIs, including sample sheets and source code, on our website, you may navigate to ibkr.com and access the menus at the top and select Trading > APIs and select Download and Resources.

Our APIs are provided with a Non-Commercial license agreement. You may download either the stable or latest version.

Note, the Excel APIs are only supported for the windows operating system.  The most up-to-date version of Interactive Brokers API source code is hosted on Github as a private repository. We refer to this as our “beta client” although it doesn’t use formal release numbers as do our “Latest” and “Stable” API versions.

This code is frequently updated with new features and functionality, and periodically the API source code in this private repository is published as a new version of API Latest. Users can gain access to the Github repository to view the current Beta API source code as well as to contribute suggestions and source code.

Our goal in allowing our users to contribute is to improve the reliability and versatility of the API for everyone.  Review this page if you’d like to access and contribute to the API Beta version.

After successfully installing, you will find the API samples and components installed on the same drive as the operating system which is usually the c drive.

  • Here you’ll see the folders samples, source, source, and tests.
  • The source folder contains the necessary files to create your own API application, and in essence define the available messages the API can send and receive.
  • In this course, we will discuss the content from the samples folder, which contains the sample spreadsheets for DDE, ActiveX, and RTD inside the “Excel” folder.
  • The DdeSocketBridge folder inside samples contains the batch file necessary to run the new DDE sample. We’ll cover this more later. Also note, the tests folder contains the library TwsLib.dll , which is used by the ActiveX sample.

Configuring TWS Settings for API

TWS is required to be open on your computer to integrate with Excel. Just double click on the Trader Workstation desktop icon to launch and log into TWS.

Now that TWS is running, let’s enable the API functionality. Go to the menu at the top of TWS and select Edit > Global Configuration > API > Settings, and then check the box on the left Enable ActiveX and Socket Clients.

By default, the sample sheet that we’ll use port 7496 so you’ll see that set here. When done click on Apply and then click on Ok.

Now that we have TWS configured, the next video in this course will go over using Excel RTD, which stands for real time data. Hope you can join us!

Additional links:

TWS API Software

API Users Guide

API Release Notes – Production

API Beta Release Notes

Join The Conversation

For specific platform feedback and suggestions, please submit it directly to our team using these instructions.

If you have an account-specific question or concern, please reach out to Client Services.

We encourage you to look through our FAQs before posting. Your question may already be covered!

25 thoughts on “Introduction to the TWS Excel API & Initial Setup”

  • TWS User

    There is no obvious path to the next video with how to set up excel.

    • Interactive Brokers

      Hello, thank you for reaching out. If you scroll back to the top of the page, on the right-hand side by the number 2, you can access the next course. It is called “Using RealTimeData (RTD) server for Excel” where more instructions will be provided to set up excel. We hope this helps.

  • Ettore

    How can I access the account data (positions, margins used, Open P/L, etc.) using RTD?

  • ramazan sari

    Hello
    I subscribed to capitalize ai.
    but can not connect to ibkr via capitalize ai
    ‘the embedded token is already used’ message is coming
    how can fix this problem

  • chen r

    i using Api excel. and trying to take the “OptionImpliedVol” of some option and make on my excel a RTD chart that moving and show the changing of the OptionImpliedVol, by using this link:=RTD(“tws.twsrtdserverctrl”,,”TMF//OPT/20240517/P/45/USD”,”OptionImpliedVol”)

    but i don’t know how to make the RTD chart with that data, maybe need extra file or software?

    • Interactive Brokers

      Hello, thanks for asking. You are welcome to implement Excel’s chart system directly; however, Interactive Brokers does not support customized implementations such as charting through Excel. As a result, Interactive Brokers API Support would be unable to assist you in this endeavor. If you are in need of additional support, please create a web ticket for this inquiry; we have a category specifically for “API.” One of our API experts will be happy to guide you! https://www.interactivebrokers.com/sso/resolver?action=NEW_TICKET

  • Miguel B.

    Hi, I’ve just downloaded the last API version and playing with the Excel RTD example file. While it works for Europe market it doesn’t for US ones. I’ve got the message “Request Market Data is not subscribed. Displaying delayed market data”. After checking my Market Data Subscription setting, both markets are fee waived.
    Any help will be much appreciated.

  • David

    Does TWS API (RTD) work on excel 365?

    • Interactive Brokers

      Thank you for asking. Excel RTD is compatible with the desktop installation of Office 365. This will not be compatible with web pages of office 365. If you have any additional questions, please create a web ticket for this inquiry. We have a category specifically for “API.” One of our API experts will be happy to guide you! http://spr.ly/IBKR_ClientServicesCampus

  • Andrew chan

    Can I open the interactive broker independently If a connect intactive broker to multicharts

    • Interactive Brokers

      Hello Andrew, thank you for your question. Can you please provide more details on what you are trying to accomplish?

      If you open an IBKR account, you should be able to access it independently as well as through supported third-party integrations. You can review some of our available integrations on our website: https://spr.ly/IBKR_3rdPartyCampus

      • Andrew Chan

        I plan to IBKR as my broker and use the the datafeed of IBKR to intergrated with my algorithmic trading in multicharts. Am I able to open IBKR independently as wellas using the datafeed to multicharts ?

  • Andrew chan

    Where to I trade FOREX option at IBKR ??

    • Interactive Brokers

      Hello Andrew. Please review our available products and exchanges on our website: https://spr.ly/IBKR_ProductsExchangesCampus

      You must request trading permissions to trade specific products. IBKR grants permissions based on your financial profile (e.g. age, liquid net worth, investment objectives, product knowledge and prior trading experience) and sometimes where you are located. Please note that we cannot disclose the requirements needed for specific trading permissions.

      • Anonymous

        HI there, Thanks fr your quick response. Is there any CFD Froex option at IBKR ?

  • Andrew Chan

    HI there, Is there any CFD Froex option at IBKR ?

  • Andrew chan

    Appreciates it if you could tell the symbol for a MSFT 31 Mar 2025 380.5 put.

  • Anonymous

    under the API settings it says that it is not provided for account supporting commission free trading. How can I gain access ?

    • Interactive Brokers

      Hello, thank you for reaching out. The IBKR API is not available to IBKR Lite accounts. If you are logged into an IBKR Lite account through an API, when you submit an order you will be given an error message “You are not allowed to trade on IBKR-LITE account.” To get API access, please follow the instructions provided in this FAQ: https://www.interactivebrokers.com/faq?id=629299016

      You will need to open an additional account, which is an IBKR Pro account. Please review this FAQ for instructions to open an additional account: https://www.interactivebrokers.com/faq?id=200724565

Leave a Reply

Disclosure: Interactive Brokers

The analysis in this material is provided for information only and is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad-based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation by IBKR to buy, sell or hold such investments. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

The views and opinions expressed herein are those of the author and do not necessarily reflect the views of Interactive Brokers, its affiliates, or its employees.

Disclosure: API Examples Discussed

Throughout the lesson, please keep in mind that the examples discussed are purely for technical demonstration purposes, and do not constitute trading advice. Also, it is important to remember that placing trades in a paper account is recommended before any live trading.

IBKR Campus Newsletters

This website uses cookies to collect usage information in order to offer a better browsing experience. By browsing this site or by clicking on the "ACCEPT COOKIES" button you accept our Cookie Policy.