Home › Guides

Give an AI agent IBKR paper trading access (TWS API or Web API)

✓ Written from official docs · checked 2026-10-17

Point your own agent or bot at an Interactive Brokers paper account instead of live money: paper logins, API settings, ports and a read-only switch. Steps from IBKR's API docs.

Tools in this guide

Safety scores are calculated from our listing facts. They aren't a ranking, and affiliate links never affect them. How it works

1. Get paper credentials

IBKR paper accounts belong to an approved IBKR Pro account and have their own username and password, separate from your live login. Your agent should only ever get the paper login.

2. Pick the API: TWS API or Web API

TWS API: your agent's code connects to Trader Workstation or IB Gateway running on your machine. Web API: your agent calls REST endpoints through the Client Portal Gateway. Both work with paper accounts.

3. TWS or IB Gateway: log in to paper and enable the API

  1. Start TWS or IB Gateway and log in with the paper username.
  2. In TWS, open the API settings and tick Enable ActiveX and Socket Clients (IB Gateway has it on by default).
  3. Keep Read-Only API ticked until you actually want the agent to place paper orders. It allows data and account reads but blocks orders.
  4. Keep connections local: allow only 127.0.0.1 as a trusted IP.

4. Connect the agent to the paper port

Default paper ports are 7497 for TWS and 4002 for IB Gateway (live is 7496 and 4001). Have your agent connect to 127.0.0.1 on the paper port, for example app.connect("127.0.0.1", 7497, 0) with the official ibapi client. A wrong port is the most common way to hit the live account by accident.

5. Or the Web API: log in to the gateway with paper credentials

Run the Client Portal Gateway, sign in with your paper username, then initialise the brokerage session with POST /v1/api/iserver/auth/ssodh/init before calling trading endpoints.

6. Verify it's paper before any order

Have the agent fetch account details and check that it's the paper account before it sends an order. Keep "Read-Only API" on while you test prompts and tools.

FAQ

What about IBKR's own MCP connector?

IBKR's AI Integration (MCP) is a different route: per our listing, the AI drafts order instructions and you place each one yourself on an IBKR platform. This guide is for agents or bots you run yourself through the TWS API or Web API.

Do I need a funded live account?

IBKR says paper accounts come with an approved IBKR Pro account. Check IBKR's current requirements before you plan around it.

Sources

Not financial advice. Trading involves risk; test on paper first.

Related guides

Get the weekly AI-trading stack update

New MCP servers, broker and data API changes, and safety notes. One email a week, unsubscribe anytime.