Interactive Brokers Trading APIs

Execute trades directly against Interactive Brokers using your bearer token. These endpoints cover previewing an order's margin impact, submitting it, and checking its execution status.

Authentication

All requests require the Interactive Brokers bearer token, obtained from the Bearer Token API:

Authorization: Bearer <BEARER_TOKEN>

Getting Contract IDs (CONID)

Before placing orders, you need the Contract ID (CONID) for each security. IBKR provides a CSV file with contract IDs for fractional share trading.

Download: IBKR Fractional Shares CSV

File Format:

#SYMBOL,MAIN_EXCHANGE,DESCRIPTION,IB_CONTRACT_ID,SCHEDULED_INELIGIBILTY_DATE
AAP,NYSE,ADVANCE AUTO PARTS INC,4027,
ABM,NYSE,ABM INDUSTRIES INC,4050,
ABT,NYSE,ABBOTT LABORATORIES .,4065,
ADC,NYSE,AGREE REALTY CORP,4151,

Usage:

1. Download the CSV file 2. Parse it to create a symbol → IB_CONTRACT_ID mapping 3. Use the IB_CONTRACT_ID in your order requests

Multiple records may exist for a single ticker on different exchanges — filter by valid exchanges (NYSE, NASDAQ, ARCA, AMEX, BATS) to ensure you get the correct contract ID.

javascript
const fs = require("fs");
const csv = require("csv-parser");

const symbolToConid = {};
const validExchanges = new Set(["NYSE", "NASDAQ", "ARCA", "AMEX", "BATS"]);

fs.createReadStream("fracshare_stk.csv")
  .pipe(csv())
  .on("data", (row) => {
    if (validExchanges.has(row.MAIN_EXCHANGE)) {
      symbolToConid[row["#SYMBOL"]] = row.IB_CONTRACT_ID;
    }
  })
  .on("end", () => {
    console.log("ABT Contract ID:", symbolToConid["ABT"]); // 4065
  });

1. Preview Order

POST https://api.ibkr.com/v1/api/iserver/account/{accountId}/orders/whatif

Simulate an order execution without placing it. Returns order validation results, margin requirements, commission estimates, and price impact analysis.

IBKR Documentation

Parameters:

ParameterTypeRequiredDescription
`conid`integerYesContract ID of security
`orderType`stringYes`MKT` (market) or `LMT` (limit)
`side`stringYes`BUY` or `SELL`
`tif`stringYesTime in force: `DAY`, `GTC`, etc.
`ticker`stringYesStock ticker symbol
`acctId`stringYesAccount ID
`cashQty`numberConditionalAmount in dollars (for BUY orders)
`quantity`numberConditionalShare quantity (for SELL or LMT orders)
`price`numberConditionalLimit price (for LMT orders)

2. Submit Order

POST https://api.ibkr.com/v1/api/iserver/account/{accountId}/orders

Execute a real order on the market. Requires an authenticated, connected session and sufficient margin.

IBKR Documentation

Notes:

  • Order must pass validation — use Preview Order first
  • Session must be authenticated and connected, see IBKR Session Management
  • Orders execute based on current market conditions

3. Order Status

GET https://api.ibkr.com/v1/api/iserver/account/order/status/{orderId}

Retrieve the current status, execution details, and any fills for a placed order.

IBKR Documentation

Status Values:

StatusMeaning
`Submitted`Order accepted but not yet executed
`Filled`Order completely filled
`Partially Filled`Order partially filled, may fill more
`Cancelled`Order cancelled
`Rejected`Order rejected by exchange
Example

Usage Example

Preview an order, submit it, then poll its status:

javascript
const IBKR_BASE_PATH = "https://api.ibkr.com";

// 1. Preview order first
const previewResponse = await fetch(
  `${IBKR_BASE_PATH}/v1/api/iserver/account/U25076105/orders/whatif`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${bearerToken}`,
      "Content-Type": "application/json",
      "User-Agent": "Your Application/1.0",
    },
    body: JSON.stringify({
      orders: [
        {
          conid: 265598,
          orderType: "MKT",
          side: "BUY",
          tif: "DAY",
          ticker: "AAPL",
          acctId: "U25076105",
          cashQty: 1000,
        },
      ],
      outsideRegularHours: false,
    }),
  },
);

// 2. If preview successful, place order
const orderResponse = await fetch(
  `${IBKR_BASE_PATH}/v1/api/iserver/account/U25076105/orders`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${bearerToken}`,
      "Content-Type": "application/json",
      "User-Agent": "Your Application/1.0",
    },
    body: JSON.stringify({
      orders: [
        {
          conid: 265598,
          orderType: "MKT",
          side: "BUY",
          tif: "DAY",
          ticker: "AAPL",
          acctId: "U25076105",
          cashQty: 1000,
        },
      ],
      outsideRegularHours: false,
    }),
  },
);

const { order_id } = await orderResponse.json();

// 3. Check order status
const statusResponse = await fetch(
  `${IBKR_BASE_PATH}/v1/api/iserver/account/order/status/${order_id}`,
  {
    headers: {
      Authorization: `Bearer ${bearerToken}`,
      "User-Agent": "Your Application/1.0",
    },
  },
);

For a full working script that also handles authentication and session setup, see the Complete Flow Example.

Request

Response

Was this page helpful?

PiTrade

PiTrade gives investors in over 190 countries access to the U.S. stock market through real, transparent portfolios you can build yourself or invest in Strategizer Portfolios. As an SEC-registered investment adviser, powered by Interactive Brokers, PiTrade makes investing more transparent and accessible.

This content is provided for informational purposes only and is not intended as and may not be relied on in any manner as investment advice, a recommendation of any interest in any security offered herein. All investments involve risk, including the possible loss of principal. Past performance does not guarantee future results, and investors should consider their own investment goals, risk tolerance, and financial situation before investing. The information contained herein is subject to change.

The platform "PiTrade" is operated by Pioneer Advisory LLC, a subsidiary of Pioneer Investing Inc. which holds ownership rights related hereto.

Advisory services are provided by Pioneer Advisory LLC, an SEC-registered investment adviser.

Brokerage and clearing services are provided by Interactive Brokers LLC, a SEC-registered broker-dealer, member FINRA/SIPC, to retail customers for US-listed, registered securities and ETFs on a self-directed basis.

The registrations and memberships above in no way imply that the SEC, FINRA, or SIPC has endorsed the entities, products or services discussed herein.

Interactive Brokers LLC is a registered Broker-Dealer, Futures Commission Merchant and Forex Dealer Member, regulated by the U.S. Securities and Exchange Commission (SEC), the Commodity Futures Trading Commission (CFTC) and the National Futures Association (NFA), and is a member of the Financial Industry Regulatory Authority (FINRA) and several other self-regulatory organizations. Interactive Brokers does not endorse or recommend any introducing brokers, third-party financial advisors or hedge funds, including Pioneer Advisory LLC. Interactive Brokers provides execution and clearing services to customers. None of the information contained herein constitutes a recommendation, offer, or solicitation of an offer by Interactive Brokers to buy, sell or hold any security, financial product or instrument or to engage in any specific investment strategy. Interactive Brokers makes no representation, and assumes no liability to the accuracy or completeness of the information provided on this website.

For more information regarding Interactive Brokers, please visit www.interactivebrokers.com

© 2026 Pioneer Investing Inc. All Rights Reserved.