# IBKR paper trading API: connect an AI agent or bot safely

> Connect an AI agent or bot to an Interactive Brokers paper account: paper login, TWS or Web API, ports 7497 and 4002, read-only mode and a pre-order check.

Canonical: https://tradingagentstack.com/guides/ibkr-paper-trading-api-for-ai-agents/

1. [Home](https://tradingagentstack.com/)

2. [Guides](https://tradingagentstack.com/guides/)

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

By [Ahsen Rajab (@Satovinci)](https://tradingagentstack.com/about/)

✓ Written from official docs · checked 2026-11-30

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.

## Key facts

Updated Nov 30, 2026 · every fact links its source · [how we check](https://tradingagentstack.com/methodology/)

- **Live vs paper:** live and paper ([interactivebrokers.com](https://www.interactivebrokers.com/docs/tws-api/doc/pacing-limitations/introduction) · Nov 27, 2026)

- **Safety score 41%** (partial): Can trade unattended. ([how it's scored](https://tradingagentstack.com/safety-score/) · Nov 27, 2026)

- **IBKR Paper Trading Account:** paper account reached with the Paper toggle at login using your live credentials (secondary users get separate paper credentials); usable with TWS API and IBKR's MCP… Safety score 90%. ([interactivebrokers.com](https://www.interactivebrokers.com/campus/trading-lessons/how-to-open-an-ibkr-paper-trading-account/) · Nov 25, 2026)

- **Interactive Brokers AI Integration (MCP):** hosted at api.ibkr.com/v1/api/mcp-public; IBKR login, single-account authorization… Safety score 71%. ([interactivebrokers.com](https://www.interactivebrokers.com/en/general/about/mediaRelations/7-28-26.php) · Nov 30, 2026)

**Tools in this guide**
- [Interactive Brokers API](https://tradingagentstack.com/tool/interactive-brokers-api/) [Safety 41% (partial)](https://tradingagentstack.com/safety-score/)

- [IBKR Paper Trading Account](https://tradingagentstack.com/tool/ibkr-paper-trading-account/) [Safety 90%](https://tradingagentstack.com/safety-score/)

- [Interactive Brokers AI Integration (MCP)](https://tradingagentstack.com/tool/interactive-brokers-ai-integration-mcp/) [Safety 71% (partial)](https://tradingagentstack.com/safety-score/)

Safety scores are calculated from our listing facts. They aren't a ranking, and affiliate links never affect them. [How it works](https://tradingagentstack.com/safety-score/)

## 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

- [IBKR: Paper trading account](https://www.interactivebrokers.com/campus/glossary-terms/paper-trading-account/)

- [IBKR Web API: Using a paper account](https://www.interactivebrokers.com/docs/web-api/authentication/paper.md)

- [IBKR TWS API: Initial setup](https://interactivebrokers.github.io/tws-api/initial_setup.html)

- [IBKR Campus: Installing and configuring TWS for the API](https://www.interactivebrokers.com/campus/trading-lessons/installing-configuring-tws-for-the-api/)

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

## Related guides

- [How to connect Claude to Alpaca via MCP](https://tradingagentstack.com/guides/connect-claude-to-alpaca-mcp/)

- [How to connect Claude (or any MCP client) to Interactive Brokers](https://tradingagentstack.com/guides/connect-claude-to-ibkr-mcp/)

- [How to connect Claude to the tastytrade MCP server](https://tradingagentstack.com/guides/connect-claude-to-tastytrade-mcp/)

- [How to connect Claude (and other AI agents) to the Robinhood Trading MCP](https://tradingagentstack.com/guides/connect-claude-to-robinhood-mcp/)

- [How to connect Claude to TradeStation MCP](https://tradingagentstack.com/guides/connect-claude-to-tradestation-mcp/)

- [How to connect Claude (and other AI apps) to the Public hosted MCP server](https://tradingagentstack.com/guides/connect-claude-to-public-mcp/)

- [Connect ChatGPT, Cursor or Claude Code to Interactive Brokers (IBKR MCP)](https://tradingagentstack.com/guides/ibkr-mcp-chatgpt-cursor-claude-code/)

- [How to connect Claude, ChatGPT or Cursor to the Tradier MCP server (paper first)](https://tradingagentstack.com/guides/connect-claude-to-tradier-mcp/)

- [How to connect Claude or Cursor to the moomoo MCP server (OAuth scopes explained)](https://tradingagentstack.com/guides/connect-claude-to-moomoo-mcp/)

- [Set up a 3Commas or Bitsgap bot with a safe exchange API key (no withdrawals, IP whitelist)](https://tradingagentstack.com/guides/safe-exchange-api-key-3commas-bitsgap/)

- [Run Freqtrade in dry-run mode (paper trading with a simulated wallet)](https://tradingagentstack.com/guides/freqtrade-dry-run/)

[Need a custom AI trading agent built? Broker or exchange integration, MCP setup, Polymarket/Kalshi bots, safety guardrails, VPS deployment. →](https://tradingagentstack.com/go/build?from=/guides/ibkr-paper-trading-api-for-ai-agents/&cta=generic-guide)

Building an agent on this? When it trades a public account on Hyperliquid or Polymarket, [get its track record verified](https://tradingagentstack.com/get-your-ai-agent-verified/): we check it from public data on the spot, then list it with a signed record. See [the AI trading bot leaderboard](https://tradingagentstack.com/ai-trading-leaderboard/), and how the agents already out there are doing in the [AI trading bot statistics](https://tradingagentstack.com/ai-trading-bot-statistics/).

## For agents

- [When to use this site, and the page index](https://tradingagentstack.com/llms.txt)
- [Sitemap](https://tradingagentstack.com/sitemap.xml)
- [Contact](https://tradingagentstack.com/contact/)
- [MCP server](https://tradingagentstack.com/mcp/)
- [MCP discovery](https://tradingagentstack.com/.well-known/mcp)
