Skip to content
ViprasolWE SOLVE INFINITYGet a quote
Back to Blog

Interactive Brokers API vs Alpaca: 2026 Developer Guide

Compare the Interactive Brokers API and Alpaca for automated trading: markets, connection, rate limits, data costs, paper trading and AI agent support.

Viprasol Tech Team
14 min read

Educational, not financial advice.

Interactive Brokers API vs Alpaca for Automated Trading (2026 Developer Guide)

TLDR

Pick the Interactive Brokers API if your bot needs futures, forex, bonds or non-US exchanges, or you want one account across 175+ markets, and you can run TWS or IB Gateway. Pick Alpaca if you trade US stocks, ETFs, options or crypto and want a plain REST API with API keys, free paper accounts and a ready MCP server for AI agents.

Every number below links to the broker's own documentation or press release, checked in December 2026. We do not quote commissions or latency, because those depend on account type, region and plan.

What is the difference between the IBKR API and Alpaca?

The Interactive Brokers API is a set of interfaces (the TWS socket API, a REST Web API and FIX) into a global multi-asset broker. Alpaca is an API-first US broker whose main product is a REST Trading API for US stocks, ETFs, options and crypto. IBKR gives you more markets; Alpaca gives you a simpler developer workflow.

IBKR's TWS API talks to a running copy of Trader Workstation (TWS) or IB Gateway. IBKR says it has "nearly full parity" with TWS, and that a feature missing from TWS is missing from the API too. The Web API uses HTTPS and JSON, and FIX is set up through IBKR's FIX team.

Alpaca's docs describe REST endpoints plus WebSocket and Server-Sent Events (SSE) streams: trading on api.alpaca.markets, paper trading on paper-api.alpaca.markets and market data on data.alpaca.markets. There is no desktop application to keep running. Do not confuse the Trading API with the Alpaca Broker API, which is for businesses building their own brokerage app. For your own bot, you want the Trading API.

Which markets and asset classes can each trade?

Interactive Brokers covers stocks, ETFs, options, futures, spot currencies, bonds, mutual funds, crypto and more across 175+ markets. Alpaca covers US-listed stocks and ETFs, US options and spot crypto. Alpaca's own docs list futures, FX and international equities as roadmap items, not live products.

IBKR's crypto page says execution and custody are provided by Paxos Trust Company or zerohash, depending on account type and residence. Interactive Brokers LLC is a member of NYSE, FINRA and SIPC and is regulated by the SEC and the CFTC. Alpaca's brokerage services are provided by Alpaca Securities LLC, a member of FINRA and SIPC. Its crypto docs list 20+ assets across 56 trading pairs, available in some US and some international jurisdictions, not all.

One regional catch: IBKR's API limitations page says Interactive Brokers Canada clients cannot use their own trading applications, including third-party API tools, to send orders for products on Canadian marketplaces.

How do you connect: TWS/IB Gateway vs REST

With IBKR's TWS API, your code opens a TCP socket to TWS or IB Gateway, which must be running and logged in. With Alpaca, your code sends HTTPS requests with API key headers and opens WebSocket streams for data and order updates. IBKR's REST Web API is the closest match to Alpaca, but it has its own session rules.

IBKR: TWS API through TWS or IB Gateway

IBKR says IB Gateway and TWS are identical from the API's point of view, and IB Gateway uses about 40% fewer resources. The key detail for automation: the user must type a username and password into a login window, and IBKR states that a headless session without a GUI is not supported. Plan for that, and for reconnect logic.

In the API settings you enable "ActiveX and Socket Clients", turn off "Read-Only API" to place orders, and check the socket port. IBKR's quick-start code uses port 4002 for an IB Gateway paper account; its connection examples use 7497 for TWS. Since TWS API 10.40, IBKR also ships a Python-only synchronous wrapper that returns values directly instead of through callbacks.

IBKR: Web API (REST)

The Web API is free for all IBKR clients. Individual accounts authenticate through the Client Portal Gateway, a small Java program that runs locally and handles the login. OAuth 1.0a is documented for advisors, brokers, funds and third-party developers, and OAuth 2.0 for advisor and broker accounts. So REST with a retail IBKR account still means running a gateway.

Alpaca: REST plus streams

Alpaca's Trading API authenticates with two HTTP headers, APCA-API-KEY-ID and APCA-API-SECRET-KEY. Live and paper accounts have separate keys, and the docs say you cannot use one for the other. Alpaca's OAuth 2.0 client-credentials flow is not yet available for the Trading API.

Rate limits and pacing

IBKR's TWS API allows your market data lines divided by two in requests per second: 50 per second at the default 100 lines. IBKR's Web API has a global limit of 10 requests per second per session. Alpaca's support page states 200 Trading API requests per minute per account, and market data limits depend on plan.

IBKR TWS API pacing

Clients with 200 market data lines, through commissions or a Quote Booster subscription, get 100 requests per second. Only the request that starts a data stream counts, not each tick. If "Reject messages above maximum allowed message rate" is enabled, TWS returns error code 100 and closes the API session after three violations; if disabled, TWS paces requests for you. Above 50 requests per second, IBKR points users to FIX: 250 messages per second through IB Gateway.

Historical bars of 30 seconds or less have extra rules. IBKR counts a pacing violation for identical requests within 15 seconds, six or more requests for the same contract, exchange and tick type within two seconds, or more than 60 requests in any ten-minute window. BID_ASK requests count twice, and IBKR says these limits cannot be changed.

IBKR Web API limits

On top of the 10 requests per second global limit, some endpoints are stricter: /iserver/marketdata/history allows 10 per second or 50 per minute, and /iserver/orders allows one request every 5 seconds. Going over returns HTTP 429, and IBKR says violating IP addresses can be put in a penalty box for 10 minutes.

Alpaca limits

Alpaca's support article says the Trading API is throttled at 200 requests per minute per account, returns HTTP 429 above that, and cannot be raised by users themselves. Historical market data calls are 200 per minute on the free Basic plan and 10,000 per minute on Algo Trader Plus. Broker API limits are set per partner and not published.

Market data: what you get and what it costs

IBKR requires a paid market data subscription for live data through the API; without one you can request free 15 to 20 minute delayed data. Alpaca's Basic plan is free with real-time IEX stock data and an indicative options feed. Algo Trader Plus costs $99 per month for all US stock exchanges and the OPRA options feed.

On IBKR you switch data types with reqMarketDataType: 1 live, 2 frozen, 3 delayed, 4 delayed frozen. Subscription prices vary by exchange and by professional status, so check them in your own account. Historical data has gaps that matter for backtests: no bars of 30 seconds or less older than six months, no expired options data, and expired futures only up to two years after expiry. IBKR calls itself "not a specialised market data provider".

On Alpaca's Basic plan, stock WebSocket streams are capped at 30 symbols and the most recent 15 minutes of historical data are restricted; Algo Trader Plus removes both limits. Stock history goes back to 2016 on both plans. IEX is one exchange, so free real-time quotes are not the full consolidated market. If your strategy depends on the national best bid and offer, budget for the paid plan.

Paper trading and testing

Alpaca gives anyone a free paper-only account with an email address, starting at $100,000 of simulated cash. IBKR opens a paper account only after your live account is approved and funded, and it mirrors your live permissions and data subscriptions. Both simulate fills from real market prices, and both warn that paper results differ from live.

Alpaca says paper trading does not model market impact, slippage due to latency, queue position for non-marketable limit orders, price improvement, regulatory fees or dividends. Options are enabled by default in paper, and paper-only accounts get IEX data only. IBKR notes that its paper environment uses more simulated technology than live, so execution can differ, and Web API users log in with a separate paper username.

A paper run checks your plumbing, not your edge. It shows whether order logic, reconnects and position tracking work, not whether the strategy makes money.

Using either with an AI agent (MCP)

Both brokers now support the Model Context Protocol (MCP). Alpaca publishes an MCP server that can place stock, options and crypto orders and defaults to paper trading. IBKR's AI Integration, opened to any MCP-compatible tool on 28 July 2026, analyses your account and drafts trade instructions that you review and submit yourself.

Alpaca's MCP server runs locally with Python 3.10+ and uvx, and works with Claude Desktop, Claude Code, Cursor, VS Code, Gemini CLI and other clients. It covers account data, orders (including brackets and multi-leg options), market data, news and watchlists. ALPACA_PAPER_TRADE defaults to true, and ALPACA_TOOLSETS lets you expose only some tools, such as a read-only set.

IBKR's press release says clients can now connect from tools such as Claude Code, Cursor, Perplexity and Windsurf, not only the ChatGPT, Claude and Grok marketplaces, using the connector URL https://api.ibkr.com/v1/api/mcp-public. In this release, the client reviews each drafted instruction and converts it to an order on an IBKR platform. Gemini support is listed as coming soon.

For a fully automated agent on IBKR, you build it yourself: the agent decides, and your own code places orders through the TWS API or Web API, with hard risk limits in between. That design is wise on either broker.

Python libraries (ib_async, alpaca-py)

For IBKR in Python, use IBKR's official ibapi package or the community ib_async library, which replaced the no-longer-updated ib_insync. For Alpaca, use the official alpaca-py SDK. On PyPI, both ib_async and alpaca-py require Python 3.10 or newer as of December 2026.

IBKR's docs say ib_insync is built on a legacy TWS API release, recommend ib_async (maintained by one of the original developers), and add that IBKR gives no coding help for either. ib_async keeps the ib_insync style, so most old code ports with an import change.

ib_async: connect and place a paper market order

Assumes IB Gateway is running, logged in to a paper account, with the API enabled on port 4002.

from ib_async import IB, Stock, MarketOrder

ib = IB()
ib.connect("127.0.0.1", 4002, clientId=1)  # IB Gateway paper port

contract = Stock("AAPL", "SMART", "USD")
ib.qualifyContracts(contract)

trade = ib.placeOrder(contract, MarketOrder("BUY", 1))
ib.sleep(2)  # let status updates arrive
print(trade.orderStatus.status)

ib.disconnect()

alpaca-py: connect and place a paper market order

Uses paper API keys from environment variables.

import os
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce

client = TradingClient(
    os.environ["ALPACA_API_KEY"],
    os.environ["ALPACA_SECRET_KEY"],
    paper=True,
)

order = client.submit_order(
    MarketOrderRequest(
        symbol="AAPL",
        qty=1,
        side=OrderSide.BUY,
        time_in_force=TimeInForce.DAY,
    )
)
print(order.id, order.status)

The IBKR version needs a running gateway, a contract IBKR resolves for you and an event loop for status updates. The Alpaca version is one authenticated HTTPS call.

Interactive Brokers API vs Alpaca: side-by-side

FeatureInteractive Brokers APIAlpaca Trading API
Markets175+ markets worldwideUS exchange-listed stocks and ETFs, US options, spot crypto
Asset classesStocks, ETFs, options, futures, spot currencies, bonds, mutual funds, crypto and moreStocks, ETFs, options (levels 0 to 3), crypto (20+ assets, 56 pairs); futures and FX on roadmap
RegulatorInteractive Brokers LLC: NYSE, FINRA, SIPC member; SEC and CFTC regulatedAlpaca Securities LLC: FINRA and SIPC member
Connection methodTWS API socket via TWS or IB Gateway; REST Web API; FIXREST, plus WebSocket and SSE streams
AuthGUI login to TWS/IB Gateway; Client Portal Gateway for individual Web API users; OAuth for institutionsAPI key ID and secret in HTTP headers; separate paper and live keys
Rate limitsTWS API: data lines divided by 2 per second (50/s default); Web API: 10 req/s plus per-endpoint limits; FIX via IB Gateway: 250 msg/sTrading API: 200 requests per minute per account; data: 200 or 10,000 historical calls per minute by plan
Paper tradingFree after a live account is approved and fundedFree paper-only account for anyone; $100k default balance
Market dataPaid subscription for live API data; free 15 to 20 minute delayed dataFree Basic (IEX real-time); Algo Trader Plus $99 per month (all US exchanges, OPRA)
MCP supportAI Integration: analysis and drafted instructions; client converts to ordersOfficial MCP server that can place orders; defaults to paper
Best forMulti-asset, global, futures and FX strategies; FIX-level order flowUS equity, options and crypto bots; fast prototyping; AI agent experiments

Which should you choose for your strategy?

Choose by what you trade first, then by how you want to run the bot. If any part of the strategy needs futures, forex, bonds or non-US exchanges, Alpaca cannot do it today, so the answer is IBKR. If everything is US stocks, options or crypto, Alpaca is usually the faster build and IBKR the broader long-term account.

Your situationBetter fitWhy
Futures or spot FXIBKRAlpaca lists futures and FX as roadmap items only
Non-US stocks or multi-currency portfolioIBKR175+ markets in one account
US stock or ETF bot, prototype stageAlpacaFree paper account, REST and API keys, no gateway to run
US options spreadsEitherAlpaca supports multi-leg options up to level 3; IBKR covers options on many exchanges
AI agent that places orders itselfAlpaca, or a custom IBKR buildAlpaca's MCP server can trade; IBKR's MCP drafts instructions for you to submit
Very high order ratesIBKR via FIXIBKR points users above 50 requests per second to FIX

If you are also weighing MT4 and MT5 brokers, our broker comparison for automated trading covers the wider field.

Common mistakes

Most failed IBKR and Alpaca bots break on plumbing, not strategy: dropped connections, rate limits, mixed-up keys or wrong data assumptions. Each mistake below maps to a documented limit covered earlier in this guide, so you can check your own code against the list before going live with real money.

  • Assuming IB Gateway can run headless. IBKR says a GUI-less session is not supported. Plan for a desktop session and reconnect handling.
  • Ignoring historical pacing. A loader firing hundreds of small-bar requests at IBKR will hit the 60-in-10-minutes rule. Cache data.
  • Treating IEX quotes as the full market. Alpaca's free real-time stock data comes from one exchange.
  • Mixing paper and live credentials. Keep them in separate config and log which environment you are in at startup.
  • Still using ib_insync. IBKR says it is no longer updated. Move to ib_async or ibapi.
  • No HTTP 429 handling. Back off and retry; IBKR's Web API can block your IP for 10 minutes.
  • Letting an AI agent trade with no limits. Put position, loss and order-count limits in code the agent cannot change, and start in paper.

Build it yourself or hire a developer

Build it yourself if your bot is one strategy on one broker and you are comfortable with Python, error handling and running a server. Hire a developer when you need reliable reconnects, several brokers, an AI agent with risk controls, or a system that must run unattended with real money.

The snippets above take minutes. Most of the real work is what happens when the gateway logs out at 3 a.m., an order partly fills, the data feed lags, or a rate limit hits mid-rebalance.

Need an IBKR bot that runs unattended? Viprasol Tech builds TWS API, IB Gateway and Web API integrations with reconnect handling, order state tracking and risk limits. See our Interactive Brokers API integration service. You get the full source code and 30 days of free bug fixes.

Trading on Alpaca, or more than one broker? We connect strategies to Alpaca, Interactive Brokers, crypto exchanges and other broker APIs, for stocks, options, futures, forex and crypto. Read about our trading API integration work. Projects start from $200 USD.

Want an AI agent on top of your broker? We build AI trading agents with the Claude API and MCP, with hard risk limits in code and paper testing first. See AI trading agent development, or tell us about your project. We build and test the software; we never promise trading profits.

Frequently Asked Questions

Is the Interactive Brokers API free?

IBKR says its Web API trading features are free for all IBKR clients, and the TWS API download is free. Live market data through the API needs paid subscriptions, and normal trading costs apply.

Is Alpaca's API free?

A paper account, the Trading API and the Basic data plan cost nothing. Algo Trader Plus costs $99 per month for full US stock exchange coverage and OPRA options data.

Can I trade futures or forex with Alpaca?

Not as of December 2026. Alpaca's docs list futures, FX and international equities as roadmap items. Of the two, only IBKR offers futures and spot currencies through its API.

Do I need TWS running to use the IBKR API?

For the TWS API, yes: TWS or IB Gateway must be running and logged in. Individual Web API users normally authenticate through the Client Portal Gateway, which also runs locally.

What happened to ib_insync?

IBKR says ib_insync is built on a legacy TWS API release and is no longer updated, and points users to ib_async. IBKR does not provide coding support for either package.

Can an AI agent place trades on Interactive Brokers through MCP?

Through IBKR's AI Integration, the AI drafts instructions and the client converts each one into an order. A fully automated agent on IBKR needs custom code using the TWS API or Web API.

Which is better for a beginner building a trading bot?

For US stocks, options or crypto, Alpaca is simpler to start: a free paper account, API keys and REST calls. If you know you need futures, FX or global markets, start on IBKR's paper account to avoid a rewrite.

Sources

Interactive Brokers APIAlpaca APIalgorithmic tradingtrading botsib_asyncalpaca-pyMCPbroker API comparison
Share this article:

About the Author

V

Viprasol Tech Team

Custom Software Development Specialists

The Viprasol Tech team specialises in algorithmic trading software, AI agent systems, and SaaS development.

MT4/MT5 EA DevelopmentAI Agent SystemsSaaS DevelopmentAlgorithmic Trading

Ready to Automate Your Trading?

Discuss a custom Expert Advisor with defined strategy rules, risk controls and a testing plan.

We reply within 24 hours, Monday to Saturday. WhatsApp is fastest.

Viprasol · Trading Software

Need a custom EA or trading bot built?

We build MT4/MT5 Expert Advisors around your strategy, broker and risk requirements. Each project has an agreed scope, testing plan and individual quote.

EA Studio: a single EA at a fixed price (opens in a new tab)