An easy-to-use local web API for accessing Interactive Brokers (IBKR) using ib_insync. Designed for end users to run a standalone executable (ibkr-web-api.exe) and interact with their local IB TWS or IB Gateway instance via HTTP calls.
- ✅ Single-file executable for Windows users:
ibkr-web-api.exe - 🧠 Configuration via external
config.yml - 🔌 Connects directly to a local TWS or Gateway instance
- 🌐 Exposes a RESTful FastAPI server to query IBKR-TWS data.
- 🔐 Intended for local use only (due to TWS dependency)
Download the latest release from the GitHub Releases page.
Create a config.yml file in the same folder or any path of your choice. You can pass its path via command-line argument.
Example:
ib:
host: localhost
port: 7497
logging:
level: DEBUG
fastapi:
title: IBKR Web API
description: RESTful API for accessing Interactive Brokers historical market data
version: "1.0"
docs_url: /docs
redoc_url: /redoc
openapi_url: /openapi.json
debug: false
allow_origins: ["*"]
uvicorn:
host: "127.0.0.1"
port: 8000Ensure your IB TWS or IB Gateway is running locally on the specified port (default: 7497).
Then, launch the API server:
ibkr-web-api.exe --config path\to\your\config.ymlIf --config is omitted, it will use the specified default config.
Once running, access the API via browser or HTTP client:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
- This app is intended to run on the same machine as your IBKR TWS/Gateway.
- It is not designed to be publicly hosted — all communication is assumed to be local (
localhost). - All data comes via your authenticated TWS-IBKR session.
If you're a developer and prefer running from source:
git clone https://github.com/danielgmorena/ibkr-web-api.git
cd ibkr-web-api
poetry install
poetry run uvicorn app.main:app --reloadContributions are welcome!
You can extend this project by wrapping more ib_insync functionality as API endpoints. New endpoints should be placed under the app/api/ directory.
Before submitting a pull request, make sure your code is:
- ✅ Type-safe via
mypy - ✅ Linted via
ruff - ✅ Tested with
pytestand includes coverage
To add support for a new IBKR data method:
- Create a file under
app/api/(e.g.app/api/open_orders.py) - Register the router in
app/main.pyor similar - Write tests under
tests/ - Run:
mypy app
ruff check .
pytest .Then open a pull request! 🚀