Asset Classes

Free investment financial education

Language

Multilingual content from IBKR

Close Navigation
Learn more about IBKR accounts

What is the TWS API?

Lesson 1 of 11
Duration 3:54
Level Intermediate
Close Navigation

Welcome to this short course on programming using the Python TWS API.

Prerequisites for this course:

  • Windows, Linux, or Mac OS computer with a Graphical User Interface and Python 3.3 or higher installed.
  • Familiarity with Python programming.
  • The TWS API utilizes socket programming, multiple threads, and other concepts which it is recommended to be familiar with beforehand. If not, it is suggested to first try an Introduction to Python course which covers these topics.

Intended Audience

  • Programmers with experience in Python who are interested in building custom applications.

IBKR  Platforms

  • Trader Workstation (TWS) is a Java-based application which can run on any major desktop operating system supporting a graphical user interface, such as Windows, Linux, or MacOS. For security reasons, TWS is designed to require the end user to manually enter credentials into the user interface.
  • Client Portal, which is a web-based platform for trading and other account functions,
  • IBKR mobile, the mobile trading app for Apple and Android smartphones.

In addition to using IBKR’s trading software, there are several ways by which custom or 3rd party trading applications can place orders to IBKR accounts. One common means of connection available for all clients is the TWS API. Other connections include the WEB API and FIX/CTCI connections.

The API offerings are detailed on our website, Interactivebrokers.com, under Trading and APIs.

The Trader Workstation API is an open-source interface to TWS which can be used by custom or 3rd party applications to automate TWS functionality, including but not limited to:

  • Order placement
  • Receiving account values
  • Receiving portfolio data
  • Receiving market data
  • Querying financial instrument details

It is important to keep in mind that the TWS API itself does not provide new functionality unavailable in TWS, but rather provides the ability to automate some actions within TWS from external software.

The source code for the TWS API is provided under a non-commercial license agreement from https://interactivebrokers.github.io/ and can be used by a programmer to write a custom application that connects to TWS.

Since this code is entirely in general programming languages such as Python, Java, C#, and C++, the intended audience for the source code are experienced third party programmers with a background in one of these languages.

To develop applications which do not fit under the default non-commercial license agreement, a commercial license agreement is available on request. More than 100+ applications compatible with the TWS API have been developed by third party developers, and many are advertised on the Investors Marketplace on the Interactive Brokers website.

TWS API Overview

TWS API Documentation

Join The Conversation

If you have a general question, it may already be covered in our FAQs. If you have an account-specific question or concern, please reach out to Client Services.

2 thoughts on “What is the TWS API?”

  • Abel brioso

    i am trying to run my algo stock scalping strategy, coded in python (is written as a fully autonomous scalping stock scriprt, with 5 minute intervals and with a couple of market indicators. it connects and disconnects quickly. gathers the data but it does not excute trades. only last week i was able to trade a couple of times in papaer trading mode, but it has not wroked ever since.

    • Interactive Brokers

      Hi, thank you for reaching out. 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

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.