IBKR Trading Web API¶
Source: https://www.interactivebrokers.com/campus/ibkr-api-page/web-api-trading/ Last Updated: 2026-02-26
Table of Contents¶
- Getting Started
- Trading Access
- API Support
- Usage and Availability
- Trading Sessions
- Instrument Discovery
- Market Data
- Orders
- Portfolio and Positions
- FYIs and Alerts
Getting Started¶
Clients with **fully open and funded accounts**may use the Web API's Trading features to trade their accounts immediately, without any onboarding or approval process.
The Web API's Trading functionality is accessible via several authentication methods:
- OAuth 2.0 (beta)
- OAuth 1.0a
- SSO (for Financial Advisors and Introducing Brokers)
- Client Portal Gateway (for individual clients)
Trading Access¶
For Organizations¶
Enterprise and Institutional clients have several authorization methods:
| Method | First-Party | Third-Party | Features |
|---|---|---|---|
| OAuth 2.0 (beta) | Yes | Yes | Account management + Trading |
| OAuth 1.0a | Yes | Yes | Trading only |
| SSO | Yes | No | Account management + Trading |
For Individuals¶
Trading requires:
- IBKR username and password
- **IBKR Pro**account type (fully open and funded)
- Can access both live and simulated paper accounts
For Third Parties¶
Third-party developers (vendors with no formal relationship to IB clients):
- Must receive Compliance approval
- Only OAuth 1.0a is currently available
- Onboarding process takes approximately**8-14 weeks**
API Support¶
Contact options:
- Create a Support Ticket
- Chat Live with API Support
- Get Help by Phone
Troubleshooting checklist before contacting support:
- Does the issue persist in other platforms (TWS, Client Portal)?
- When was the issue first observed?
- Do similar requests yield expected responses?
- Did the request include all required parameters?
Usage and Availability¶
Scheduled Server Maintenance¶
The Web API is accessible 24 hours a day during weekdays, with maintenance only on Saturday evenings.
Brokerage functionality (/iserver endpoints) is briefly unavailable each evening:
| Region | Maintenance Onset |
|---|---|
| North America (NY, Chicago) | 01:00 US/Eastern |
| Europe | 01:00 CEST |
| Asia | 01:00 HKT |
Pacing Limitations¶
***Global rate limit**: 50 requests per second per authenticated username
***CP Gateway users**: 10 requests per second
When rate limits are exceeded, the API returns 429 Too Many Requests. Violator IPs may be penalized for 10 minutes.
Per-Endpoint Request Rate Limits¶
| Endpoint | Method | Limit |
|---|---|---|
/iserver/marketdata/snapshot | GET | 10 req/s |
/iserver/scanner/params | GET | 1 req/15 min |
/iserver/scanner/run | POST | 1 req/sec |
/iserver/trades | GET | 1 req/5 sec |
/iserver/orders | GET | 1 req/5 sec |
/portfolio/accounts | GET | 1 req/5 sec |
/pa/performance | POST | 1 req/15 min |
Trading Sessions¶
A **brokerage session**is associated with an IB username and permits access to:
- Trading functionality
- Market data consumption
- All
/iserverendpoints
A single username can only have**one brokerage session active at a time**across all IB platforms.
Session Types¶
1.Read-Only Session- Required for any Web API request, permits access to non-/iserver endpoints 2.Brokerage Session- Established after read-only, permits trading and market data via /iserver endpoints
Instrument Discovery¶
The Web API requires IB's**Contract ID (conid)** to uniquely specify instruments.
Contract IDs for Equities¶
Response:{
"AAPL": [
{
"name": "APPLE INC",
"assetClass": "STK",
"contracts": [
{
"conid": 265598,
"exchange": "NASDAQ",
"isUS": true
}
]
}
]
}
Contract IDs for Futures¶
Finding Options Chains¶
***Step 1**: Get underlier conid and contract months
***Step 2**: Get valid strike values
Response:***Step 3**: Get option contract conids
Finding Event Contracts¶
Event Contracts are modeled as options (ForecastEx) or futures options (CME Group).
CME Group Workflow¶
Then filter bytradingClass prefix "EC" for Event Contracts. ForecastEx Workflow¶
GET /iserver/secdef/search?symbol=FF
GET /iserver/secdef/strikes?conid={index_conid}&exchange=FORECASTX§ype=OPT&month=SEP24
GET /iserver/secdef/info?conid={index_conid}&exchange=FORECASTX§ype=OPT&month=SEP24&strike=3.125
Market Data¶
Top-of-Book Snapshots¶
Required:
- Contract ID (
conid) - Field identifiers for desired data points
- Username with market data subscriptions
-
Brokerage session
-
Pre-flight request (must be made first to start streaming):
[
{
"31": "168.42",
"84": "168.41",
"85": "600",
"86": "168.42",
"88": "1,300",
"7059": "100",
"conid": 265598
}
]
***Common field tags**: - 31 - Last price - 84 - Bid - 85 - Bid size - 86 - Ask - 88 - Ask size - 7059 - Volume
Streaming Top-of-Book Data¶
Via WebSocket:
Example: Cancel stream:Orders¶
New Order¶
***Required values**: - Account ID - Contract ID (conid) - Order type (orderType) - Side (BUY or SELL) - Time in force (tif) - Quantity
[
{
"conid": 265598,
"side": "BUY",
"orderType": "LMT",
"price": 165,
"quantity": 100,
"tif": "DAY"
}
]
Order Reply Messages¶
Some orders require confirmation before execution:
[
{
"id": "07a13a5a-4a48-44a5-bb25-5ab37b79186c",
"message": ["Order price exceeds constraint. Are you sure?"],
"messageIds": ["o163"]
}
]
Order Reply Suppression¶
Suppress specific message types for the session:
Reset suppression:Modifying Orders¶
***Important**: Must include ALL original order attributes with modified values:
Canceling Orders¶
Response:Bracket Orders¶
Submit parent and child orders together:
{
"orders": [
{
"acctId": "U1234567",
"conid": 265598,
"cOID": "Parent",
"orderType": "MKT",
"side": "Buy",
"quantity": 50
},
{
"acctId": "U1234567",
"conid": 265598,
"orderType": "STP",
"side": "Sell",
"price": 157.30,
"quantity": 50,
"parentId": "Parent"
},
{
"acctId": "U1234567",
"conid": 265598,
"orderType": "LMT",
"side": "Sell",
"price": 157.00,
"quantity": 50,
"parentId": "Parent"
}
]
}
Combo/Spread Orders¶
Use conidex field instead of conid:
Format: {spread_conid};;;{leg_conid1}/{ratio},{leg_conid2}/{ratio}
***Currency Spread ConIDs**: | Currency | Spread ConID | |----------|--------------| | USD | 28812380 | | EUR | 61227069 | | GBP | 58666491 | | JPY | 61227069 | | CAD | 61227082 | | AUD | 61227077 |
Example for US stock combo:
Monitoring Live Orders¶
Portfolio and Positions¶
Querying Accounts¶
For tiered accounts (FA, IBroker):Querying Currency Balances¶
Response includes per-currency:- Settled cash
- Cash balance
- Net liquidation value
- Unrealized P&L
- Realized P&L
Querying Equity and Margin¶
Returns equity and margin values for:- Entire U-account (aggregate)
- Regulatory segments (securities vs commodities)
FYIs and Alerts¶
Types of Notifications¶
- FYIs- Portfolio notifications and disclaimers
- Alerts- Mobile trading alerts
- Bulletins - System announcements
Get Unread Count¶
Response:Get All Notifications¶
Response fields:R- Read status (0 = unread)MS- TitleFC- FYI codeID- Unique identifierMD- HTML-formatted message