areed1192
interactive-brokers-api
Python

A python application used to interact with the Interactive Brokers REST API.

Last updated May 18, 2026
100
Stars
44
Forks
3
Issues
0
Stars/day
Attention Score
46
Language breakdown
Python 100.0%
โ–ธ Files click to expand
README

Interactive Brokers Client Portal API

Python PyPI License: MIT

An unofficial Python client for the Interactive Brokers Client Portal Web API. Manage trades, pull historical and real-time data, manage accounts, create and modify orders โ€” all from Python.

Table of Contents

Features

| Service | Property | Description | | ------------------ | ------------------------------- | ------------------------------------------------------------------ | | Authentication | ibc_client.authentication | Login, logout, session keep-alive, SSO validation | | Accounts | ibc_client.accounts | Account listing and server PnL | | Portfolio | ibcclient.portfolioaccounts | Positions, ledger, allocation, sub-accounts | | Orders | ibc_client.orders | Place, modify, cancel, bracket, and what-if orders | | Trades | ibc_client.trades | Query executed trades | | Market Data | ibcclient.marketdata | Snapshots, historical bars, subscriptions | | Contracts | ibc_client.contracts | Search stocks/futures/options, security definitions, trading rules | | Alerts | ibc_client.alerts | Create, activate, delete, and query alerts | | Scanners | ibc_client.scanners | Market scanner parameters and execution | | PnL | ibc_client.pnl | Real-time profit and loss | | FYI | ibc_client.fyi | Notifications, delivery options, disclaimers | | Portfolio Analysis | ibcclient.portfolioanalysis | Performance summaries and transaction history | | Customer | ibc_client.customers | Customer info | | Data | ibcclient.dataservices | News, calendar, and research data |

Requirements

  • Python 3.10+
  • An Interactive Brokers account (paper or live)
  • Java 8 update 192 or higher (OpenJDK 11+ also works)
  • The Client Portal Gateway (downloaded automatically on first use)

Installation

Install from PyPI:

pip install ibc-api

Or install in development mode from source:

git clone https://github.com/areed1192/interactive-brokers-api.git
cd interactive-brokers-api
pip install -e ".[dev]"

Quick Start

from ibc import InteractiveBrokersClient

Initialize the client.

ibc_client = InteractiveBrokersClient( account_number="U1234567", )

Authenticate (opens browser for gateway login).

ibcclient.authentication.waitfor_login()

Grab a market data snapshot.

snapshot = ibcclient.marketdata.snapshot(contract_ids=["265598"]) print(snapshot)

Search for a contract.

results = ibcclient.contracts.searchsymbol(symbol="AAPL") print(results)

Place an order.

order = { "conid": 265598, "orderType": "LMT", "price": 150.00, "side": "BUY", "quantity": 1, "tif": "DAY", } response = ibcclient.orders.placeorder( accountid=ibcclient.account_number, order=order ) print(response)

See the samples/ directory for more complete examples.

SSL Certificates

The Client Portal Gateway uses a self-signed SSL certificate on localhost:5000. Your browser will warn about an insecure connection when you open the login page โ€” this is expected. The connection is only "insecure" between your code and your own machine; requests from the gateway to Interactive Brokers are fully encrypted.

This library defaults to verify_ssl=False and suppresses the corresponding urllib3 warnings, which is the standard approach for localhost gateway usage.

The verify_ssl parameter accepts three kinds of values:

| Value | Meaning | | -------------------------- | -------------------------------------------------------------------------------- | | False (default) | Skip SSL verification entirely โ€” standard for the self-signed localhost gateway. | | True | Verify using the default CA bundle (Python's certifi). | | "/path/to/ca-bundle.crt" | Verify using a custom CA certificate file or directory. |

# Default โ€” skip verification (localhost self-signed cert)
ibcclient = InteractiveBrokersClient(accountnumber="U1234567")

Verify with a custom CA cert

ibc_client = InteractiveBrokersClient( account_number="U1234567", verify_ssl="/etc/ssl/certs/my-ib-gateway-ca.crt", )

If you want stricter local SSL verification, you can replace the gateway's keystore and pass verify_ssl=True or a path to your custom CA cert:

  • Generate a self-signed certificate and import it into a Java KeyStore (requires keytool from your
Java installation):
keytool -genkey -keyalg RSA -alias selfsigned -keystore my.jks -storepass mypassword -validity 730 -keysize 2048
  • Replace ibc/resources/clientportal.beta.gw/root/vertx.jks with your new my.jks file and update
sslPwd in root/conf.yaml to match your store password.
  • Export the certificate to PEM format and pass the path as verify_ssl:
ibc_client = InteractiveBrokersClient(
       account_number="U1234567",
       verify_ssl="/path/to/my-gateway-ca.pem",
   )

Alternatively, pass verify_ssl=True if you have added the certificate to your OS trust store or Python's certifi bundle.

For most users, the default verify_ssl=False is the correct choice.

Documentation and Resources

Support These Projects

Patreon: Help support this project and future projects by donating to my Patreon Page. I'm always looking to add more content for individuals like yourself, unfortunately some of the APIs I would require me to pay monthly fees.

YouTube: If you'd like to watch more of my content, feel free to visit my YouTube channel Sigma Coding.

ยฉ 2026 GitRepoTrend ยท areed1192/interactive-brokers-api ยท Updated daily from GitHub