IBKR API without TWS: headless IB Gateway options
You cannot skip IBKR's gateway software as a retail user, but you can skip the full TWS window. IB Gateway, IBC and Docker images cover the socket API; the Client Portal Gateway covers the Web API. Daily restarts and 2FA are the constraints you design around.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
Steps
IB Gateway instead of TWS
IBKR says IB Gateway is a lighter application using about 40% fewer resources than TWS. The TWS API needs one of the two running, and IBKR says a session without a login window is not supported: the user types the username and password by hand. IBKR's older setup guide gives TWS default ports of 7496 live and 7497 paper. This site also holds 4001 live and 4002 paper for IB Gateway, which were not found on the IBKR pages read on 12 October 2026.
interactivebrokers.comchecked
Plan for the daily restart
IBKR says both TWS and IB Gateway were designed to be restarted daily, and from version 974 both have an autorestart setting so the daily restart needs no manual step. With it on, IBKR says either can run from Sunday to Sunday, and credentials are needed again after the Saturday night server reset.
interactivebrokers.comchecked
Plan for the weekly login
IBKR says the weekly authentication cycle starts every Monday. A Soft token=0 login failure means you need to log in by hand again.
interactivebrokers.comchecked
IBC automates the login
IBC fills in credentials, handles TWS dialogs, restarts daily without re-authentication and can retry IBKR Mobile 2FA if you miss the alert. It runs on Windows, macOS and Linux under GPL 3. The repository was archived on 1 Sep 2026, so it is now read-only.
github.comchecked
Docker: ib-gateway-docker
The community gnzsnz/ib-gateway-docker image bundles IB Gateway, IBC, Xvfb, VNC and socat. It reads TWS_USERID and TWS_PASSWORD or TWS_PASSWORD_FILE (Docker secrets), with TRADING_MODE paper or live, READ_ONLY_API, TWOFA_TIMEOUT_ACTION and AUTO_RESTART_TIME. Its example compose file uses ghcr.io/gnzsnz/ib-gateway:stable, READ_ONLY_API yes or no, and binds the API ports to 127.0.0.1 only.
github.comchecked
Client Portal Web API gateway
For the Web API, retail users run the Java Client Portal Gateway and must log in through a browser on the same machine; IBKR says API calls must also come from that machine, and that it does not support automating the login. 2FA is required for all IBKR users. This site held Java 8 update 192 or later as the minimum: the pages read on 12 October 2026 ask only for a working Java, so that version is not repeated as current.
interactivebrokers.comchecked
Web API sessions drop at midnight
IBKR says Web API clients see disconnects at midnight in their connecting region. Call /tickle about every 60 seconds to keep a session alive, and remember one brokerage session per username across TWS, Client Portal and mobile.
interactivebrokers.comchecked
IBeam for headless Web API logins
The community IBeam tool injects credentials into the Client Portal Gateway and keeps it running without a display, as the voyz/ibeam Docker image. Its README warns that storing credentials is a security risk and suggests paper credentials.
github.comchecked
Keep it on paper and read only first
Every tool above needs your IBKR password somewhere on disk. Start with paper credentials, keep the API port on localhost, and leave Read-Only API on until you have watched the setup survive a restart.
github.comchecked
Sources
- IBKR TWS API documentation, the IB Gatewaychecked
- IBKR Web API documentation, limitations of the Client Portal Gatewaychecked
- GitHub: IbcAlpha/IBCchecked
- GitHub: gnzsnz/ib-gateway-docker (community)checked
- GitHub: Voyz/ibeam (community)checked
- IBKR TWS API documentation, daily and weekly reauthenticationchecked
- IBKR Web API v1.0 documentation, regular server maintenancechecked
- IBKR Web API v1.0 documentation, supported two factor authenticationchecked
- IBKR Web API v1.0 documentation, ping the serverchecked
- IBKR Web API documentation, managing multiple sessionschecked
- TWS API guide: initial setup (legacy docs)checked