Choose the interface: three different jobs
These are not old and new versions. They are different access models for different workflows.
| Dimension | Web API | FIX | TWS API |
|---|---|---|---|
| Connection | REST + WebSocket | FIX session over VPN, extranet, or cross-connect | Connects to TWS or IB Gateway |
| Best for | New apps, account management, funding, reports | Institutional speed and order routing | Desktop integration and existing TWS workflows |
| Account opening | Supported | Not the primary use | Not the primary use |
| Real-time data | WebSocket | Session and permission dependent | TWS subscription dependent |
| Languages | Any HTTP client | FIX engine / custom session | C++, C#, Java, Python, ActiveX, RTD, DDE |
| Integration cost | Lower for new projects | Higher; network and compliance work | Medium; TWS or Gateway must run |
New app, account, funding, reports: start with Web API. Institutional speed and routing: FIX. Existing TWS workflow or desktop libraries: TWS API.
Four user types, four paths
Capability matrix: do not assume parity
| Capability | Web API | FIX | TWS API |
|---|---|---|---|
| Place / modify orders | Yes | Yes | Yes |
| Advanced order types | Yes | Session dependent | Yes |
| Accounts and positions | Yes | Limited | Yes |
| Funding / transfers | Yes (institutional) | Not primary | Not primary |
| Reports / tax | Yes | Limited | Yes |
| Snapshots / streaming / history | Yes | Yes | Yes |
| News | Yes | Arrangement dependent | Yes |
| Multi-account / advisor | Yes | Arrangement dependent | Limited |
This is directional, not a guarantee. Actual features depend on account type, region, permissions, and subscriptions. Check the current API documentation before integrating.
Five prerequisites before code
- An IBKR accountIndividual, institutional, or enterprise; available APIs differ.
- API permissionApply in account settings; access is not automatic.
- IP allowlistOnly your server IP. Dynamic IPs cause frequent disconnects.
- Market-data permissionsReal-time, depth, and history may require separate subscriptions.
- Paper testingTest place, modify, cancel, reconnect, and error paths before small live trades.
What each interface looks like
Web API: HTTP + WebSocket
POST /v1/api/iserver/account/{accountId}/orders
Authorization: Bearer <access_token>
Content-Type: application/json
{
"conid": 265598,
"orderType": "LMT",
"side": "BUY",
"quantity": 10,
"price": 186.20,
"tif": "DAY"
}
REST handles orders, queries, accounts, and reports; WebSocket streams market data and notifications. The hard part is token refresh, reconnect, and duplicate prevention, not memorising endpoints.
TWS API: connect to TWS / IB Gateway
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
app = EClient(EWrapper())
app.connect("127.0.0.1", 7497, clientId=1)
app.reqMarketDataType(3) # delayed
# paper first, then small live
TWS API connects over a local socket. You gain existing desktop features and language libraries, but must keep TWS running and manage version compatibility.
FIX: sessions and tags
35=D | 11=ORDER-001 | 55=AAPL | 54=1 | 38=100 | 40=2 | 44=186.20 | 59=0
FIX carries orders as tags. Institutions care about session quality, sequence numbers, resend, drop copy, and network redundancy, not just one order message.
Error handling matters more than the order call
| Case | Handle | Do not |
|---|---|---|
| Disconnect | Reconnect, query order state, fill gaps | Resend everything blindly |
| Duplicate orders | Client order IDs, dedupe, idempotency | Use timestamps as the only key |
| Partial fills | Remaining quantity, modify or cancel | Assume a single fill |
| Rejects / timeouts | Error codes, retry caps, alerts | Retry forever |
| Rate limits | Backoff, queue, daily caps | Burst through limits |
| Permission errors | Check product, market, data subscriptions | Treat as a network error |
Set per-order and daily caps, maximum position, disconnect alerts, and a manual kill switch. Code errors are more common than market errors.
Costs and data: the API is not a free pipe
API access itself is usually not separately charged, but commissions, market-data subscriptions, depth, history, and institutional services may be. Separate three layers:
- Trading: commission, minimums, exchange fees.
- Data: real-time, depth, history, news.
- Infrastructure: server, static IP, monitoring, redundancy.
Authentication and session lifetime
Credentials expire: Web API sessions renew, FIX sessions reset daily, TWS API follows the local login. Renew before expiry, once, and queue the rest.
Rate limits and pacing
Request rate, sessions, history quota, and order rate are separate ceilings; queue with jittered backoff and capped retries.
Paper versus live
Paper proves the plumbing, not the fills.
| Item | Paper | Live |
|---|---|---|
| Fill | Instant, complete | Partial, queued, gapped |
| Slippage | Small | Liquidity dependent |
| Data | Often delayed | Subscription required |
| Use | Flow and errors | Execution quality |
Mixed architectures
Most desks run two interfaces; pick one owner of order state and log which interface acknowledged each order.
Deployment and uptime
Static egress IP, a supervised process, a daily re-login, and locked library versions.
Security boundaries
Credentials stay server-side in a secret store; scope permissions, cap order size, rotate keys.
Observability signals
Watch heartbeat, auth failures, latency, queue depth, and position drift; stop trading when reconciliation breaks.
Running cost
Split fixed costs (server, static IP, monitoring) from variable ones (data, commissions).
Migration path
Move in stages: shadow reads, dual reporting, cutover, retirement, each with a rehearsed rollback.
FAQ
Do I need separate API approval?
Yes. API permission, IP allowlisting, and data subscriptions are separate from opening an account.
Web API or TWS API?
New apps and account/funding workflows: Web API. Existing TWS workflows or desktop libraries: TWS API.
Is FIX for individuals?
Generally not. FIX requires networking, session management, and institutional operations.
Can I use Python?
Yes. TWS API has Python libraries; Web API works with any HTTP-capable language.
Paper or live first?
Paper. Test orders, modifications, cancels, reconnects, and error branches before small live trades.
Is market data extra?
Real-time and depth usually require subscriptions; delayed data may be free or cheaper.
Can I use multiple APIs?
Yes, but keep permissions, data, and risk controls consistent to avoid duplicate orders.
Are there rate limits?
Yes, by interface and account. Design backoff and queues rather than burst retries.
Sources and date
IBKR API product page, Web API / FIX / TWS API documentation, Traders Academy API courses, IBKR Quant Blog, and public fee schedules. Reviewed and rewritten: 2026-11. Features, permissions, and fees can change; confirm with current documentation and account settings.