This is a proxy server with POST /v1/api/login
API for the Interactive Brokers Client Portal API. Because the official server has no a simple login
api, it's hard to run as a headless service.
Ref: Why can't automated login
- This server offer a
POST /v1/api/login
api to login to the official server. - When
login
called, it will open the original login page by chromedp and automated fill the username and password (config by environment variables) - Then IB will send a push to your 2FA device, then you can confirm the login. So you have to enable a Two Factor Authentication (2FA) device. iPhone or Android
- After login, you can simple use this server as the official server, because it will proxy all the requests to the official server.
- Install Go
- Download clientportal.gw.zip or you can use the one in this repo. I will update it periodically. Unzip it to
clientportal.gw
folder or somewhere else. - Run
go run ./cmd/server
orgo build ./cmd/server
and run./server
- You can simple pull image by
docker pull ppaanngggg/ib-cp-server
- Or you can build it by
docker build -t ib-cp-server .
- Run it by
docker run -d --name=ib-cp-server -p 8000:8000 -e IB_USERNAME=your_username -e IB_PASSWORD=your_password ppaanngggg/ib-cp-server
IB_USERNAME
: Your IB Account usernameIB_PASSWORD
: Your IB Account passwordIB_EMBEDDED
: If you want main program help you to start the official server, set it totrue
. Default isture
IB_EXEC_DIR
: ifIB_EMBEDDED
istrue
, you can set this to the folder ofclientportal.gw
folder. Default is./clientportal.gw
IB_URL
: If you start the official server by yourself, you can set this to the url of the official server. Default ishttps://localhost:5000
SERVER_HOST
: The host of this server. Default is0.0.0.0
SERVER_PORT
: The port of this server. Default is8000
SERVER_TIMEOUT
: Request timeout. Default is60s