IBKR API Documentation
This site is a practical, code-level and operations-level reference for Interactive Brokers APIs. Current coverage focuses on the socket-based TWS API and ib_async 2.1.0, the package version used when this documentation was generated.
It answers three different questions without mixing them together:
- What does the Python library do? The generated
ib_asyncreference inventories signatures, defaults, fields, events, and public methods from the installed package. - What does TWS or IB Gateway do? The guides explain server-side subscriptions, order ownership, history boundaries, nightly resets, pacing, and permissions.
- What must a production application do? The operations chapters cover persistence, idempotency, recovery, observability, and safe reconciliation.
Production workflow
Follow this path in order; the sidebar's previous/next links preserve the same sequence.
- Connect and determine readiness.
- Discover accounts and account scope.
- Qualify a contract.
- Request live or delayed market data.
- Request bounded historical data.
- Construct and preview an order.
- Place, observe, modify, and cancel a paper order.
- Record statuses, then executions, fills, and commissions.
- Disconnect or restart with a durable handoff.
- Reconnect and reconcile durable state.
For supporting material, see FA configuration and allocation ownership, the async state model, TWS API order types, and the generated ib_async 2.1.0 reference.
Four boundaries to remember
ib_async is not a database. Its live collections are an in-memory projection assembled from callbacks. TWS/IB Gateway is not the IBKR backend; it is the authenticated intermediary to which the Python socket connects. The API is not an entitlement bypass; market data and trading permissions still apply. Finally, no API call provides an unlimited audit trail: persist durable identifiers and events in your own store.
Terminology
| Term | Meaning |
|---|---|
| TWS API | IBKR's stateful socket protocol exposed by Trader Workstation and IB Gateway. |
| TWS/IBG | Either Trader Workstation or IB Gateway. Their API behavior is mostly shared. |
ib_async | Python asyncio client that implements the IB wire protocol and maintains synchronized Python objects. |
| client ID | Integer identity of one API connection. It scopes order IDs, ownership, and callback visibility. |
| order ID | Connection/client-scoped mutable-order identifier. It is not a durable global key. |
permanent ID (permId) | Account-level order identifier assigned by IBKR; better for cross-session correlation. |
execution ID (execId) | Identifier for a fill/execution; use it for fill deduplication. Corrections may use related IDs. |
| request ID | Correlation identifier for a request/response stream. IB allocates these for you. |
Source policy
Behavioral claims link to current IBKR Campus TWS API documentation or the official legacy reference where the Campus page does not expose a stable section URL. Exchange support, product eligibility, server versions, and order availability change; confirm them in TWS Contract Details and IBKR's current order matrix before trading.
This documentation is technical documentation, not investment advice. Always validate order behavior in a paper account and use whatIfOrder where supported.