Individual · Advisors · InstitutionsLog InOpen Account
繁中 / EN
Interactive Brokers
Contact

PRODUCTS / API

IBKR APIA practical integration overview

IBKR offers three API products, not one: Web API, FIX, and TWS API. Pick the wrong interface and permissions, data, and error handling all follow the wrong path.

Web API · REST / WebSocketFIX · institutional routingTWS API · desktop / Gateway

Choose the interface: three different jobs

These are not old and new versions. They are different access models for different workflows.

DimensionWeb APIFIXTWS API
ConnectionREST + WebSocketFIX session over VPN, extranet, or cross-connectConnects to TWS or IB Gateway
Best forNew apps, account management, funding, reportsInstitutional speed and order routingDesktop integration and existing TWS workflows
Account openingSupportedNot the primary useNot the primary use
Real-time dataWebSocketSession and permission dependentTWS subscription dependent
LanguagesAny HTTP clientFIX engine / custom sessionC++, C#, Java, Python, ActiveX, RTD, DDE
Integration costLower for new projectsHigher; network and compliance workMedium; TWS or Gateway must run
Decision rule

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

Retail, day, and algo tradersWeb API or TWS API for automated orders, monitoring, and strategies; paper first.
Institutions: prop, hedge funds, asset managersSpeed, drop copy, risk, and reporting; usually FIX or Web API.
Enterprises: IBs, RIAs, banksAccount opening, funding, reporting, and multi-account structures; Web API matters most.
Third-party developersEmbed trading, analytics, tax, or portfolio features into your own product; confirm licensing and data scope.

Capability matrix: do not assume parity

CapabilityWeb APIFIXTWS API
Place / modify ordersYesYesYes
Advanced order typesYesSession dependentYes
Accounts and positionsYesLimitedYes
Funding / transfersYes (institutional)Not primaryNot primary
Reports / taxYesLimitedYes
Snapshots / streaming / historyYesYesYes
NewsYesArrangement dependentYes
Multi-account / advisorYesArrangement dependentLimited

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

  1. An IBKR accountIndividual, institutional, or enterprise; available APIs differ.
  2. API permissionApply in account settings; access is not automatic.
  3. IP allowlistOnly your server IP. Dynamic IPs cause frequent disconnects.
  4. Market-data permissionsReal-time, depth, and history may require separate subscriptions.
  5. 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

CaseHandleDo not
DisconnectReconnect, query order state, fill gapsResend everything blindly
Duplicate ordersClient order IDs, dedupe, idempotencyUse timestamps as the only key
Partial fillsRemaining quantity, modify or cancelAssume a single fill
Rejects / timeoutsError codes, retry caps, alertsRetry forever
Rate limitsBackoff, queue, daily capsBurst through limits
Permission errorsCheck product, market, data subscriptionsTreat as a network error
Before go-live

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.

ItemPaperLive
FillInstant, completePartial, queued, gapped
SlippageSmallLiquidity dependent
DataOften delayedSubscription required
UseFlow and errorsExecution 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.