IG — Best Python API for Most Traders

Trustpilot Score:3.9·Checked March 2026

IG’s REST API is the best-documented broker API I’ve worked with. The Swagger/OpenAPI documentation covers every endpoint with examples, and the community-maintained trading_ig Python library wraps the raw API calls into clean, Pythonic methods. Lightstreamer provides real-time price streaming without constant polling — essential for any strategy that needs live price data.

IG demo account deposit funds page for API testing with spread betting
IG demo account for API development

Pros

  • Best API documentation of any UK broker
  • Lightstreamer for real-time price streaming
  • Community trading_ig library simplifies development
  • Spread betting via API (tax-free automated trading)
  • 17,000+ instruments accessible via API
  • FCA regulated (FRN 195355), £0 minimum deposit

Cons

  • Trading rate limit of 15 requests/minute limits high-frequency strategies
  • Lightstreamer setup is more complex than simple REST polling

What Does IG API Access Cost?

API access is free with any IG account. No additional fees, no premium tier required. Your trading costs are the same as manual trading: spread-only for spread bets (EUR/USD from 0.6 pips), commission-based for share CFDs. There are no per-API-call charges.

What’s Development Like?

IG major FX pairs list showing platform navigation and data points
IG platform data accessible via Python API

I had a working script that authenticated, pulled live GBP/USD prices, and placed a demo order within 45 minutes. The trading_ig library handles session management, token refresh, and Lightstreamer connection. The demo account mirrors the live API exactly, so you can test extensively before risking capital. See our full IG review for broader platform details.

Who Should Use IG’s API?

Python developers who want to automate spread betting or CFD trading with a well-documented, community-supported API. The 15-request/minute trading limit rules out true high-frequency strategies, but it’s ample for strategies that check prices every few seconds and trade a handful of times per day.

Spread bets and CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 68% of retail investor accounts lose money when trading spread bets and CFDs with this provider. You should consider whether you understand how spread bets and CFDs work, and whether you can afford to take the high risk of losing your money.

Capital.com — Simplest API for Python Beginners

Trustpilot Score:4.6·Checked March 2026

Capital.com’s REST API is the simplest to get started with. Authentication uses an API key and password — no OAuth flow, no token management. The trade-off is no real-time streaming: you must poll for price updates, which introduces latency and counts against your rate limit. For strategies that check prices every 5–10 seconds rather than tick-by-tick, this is adequate.

Capital.com forex watchlist with AUD/USD chart in dark mode
Capital.com platform with API-accessible data

Pros

  • Simplest authentication of any broker API
  • Clean JSON responses, easy to parse
  • Spread betting available via API
  • £20 minimum deposit
  • FCA regulated (FRN 793714)

Cons

  • No real-time streaming — polling only
  • No official Python library
  • No MT5 support
  • Documentation is less detailed than IG’s

What Does Capital.com API Access Cost?

Free with any account. All trading costs are built into the spread (EUR/USD from 0.6 pips). No commission, no API fees. The £20 minimum deposit is the lowest barrier to entry for API trading among UK brokers.

What’s Development Like?

I had a working authentication and price-pull script in 20 minutes using only the requests library. No third-party wrapper needed. The simplicity is the selling point. For a first API project, Capital.com’s API removes friction and lets you focus on learning REST concepts rather than fighting authentication flows.

Who Should Use Capital.com’s API?

Python beginners building their first trading bot. The API is straightforward enough to learn REST concepts without getting bogged down in OAuth tokens or streaming protocols. Once you outgrow it, graduate to IG’s API for streaming data and a larger market range.

Spread bets and CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 62% of retail investor accounts lose money when trading spread bets and CFDs with this provider. You should consider whether you understand how spread bets and CFDs work and whether you can afford to take the high risk of losing your money.

Forex.com — Best for REST API with Execution Transparency

Trustpilot Score:4.6·Checked March 2026

Forex.com offers a REST API similar in structure to IG’s, plus the option to connect Python to MT5 for streaming data. The broker publishes quarterly execution statistics, so you can verify that API orders receive the same fill quality as manual orders. Note: Forex.com does not offer spread betting in the UK — all trades are CFDs, making profits subject to Capital Gains Tax.

Pros

  • REST API with clear documentation
  • MT5 connection available for streaming via Python
  • Published execution quality statistics
  • ~50 ms execution speed
  • FCA regulated (FRN 446717)

Cons

  • No spread betting — CFDs only (taxable)
  • No official Python library
  • Smaller community than IG’s API

What Does Forex.com API Access Cost?

Free with any account. Standard account: zero commission, spreads from 1.0 pip. Commission account: from £5 round-turn with spreads from 0.2 pips. For algo trading, the commission account gives you tighter raw spreads, which matters when your strategy is running dozens of trades per day.

What’s Development Like?

The REST API is clean and follows standard patterns. Authentication uses a simple username/password flow. I had a working script in about 35 minutes. For real-time streaming, you’d connect to MT5 using the MetaTrader5 Python package, which adds complexity but gives you tick-level data.

Who Should Use Forex.com’s API?

Developers who value execution transparency and want published proof of fill quality. The lack of spread betting is a significant downside for UK tax purposes. If tax efficiency matters, IG or Capital.com are better choices. For further reading on automation approaches, see our MT4 automation guide.

CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 76% of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you understand how CFDs work, and whether you can afford to take the high risk of losing your money.

Interactive Brokers — Most Powerful API (Steepest Learning Curve)

Trustpilot Score:3.5·Checked March 2026

IBKR offers two API paths: the TWS API (socket-based, requires TWS running locally) and the newer Client Portal REST API (web-based, lighter). The TWS API via the ib_insync Python library is the most capable broker API available — you can do things no other retail API supports, like algorithmic order types, real-time portfolio Greeks, and multi-leg options orders. The cost is genuine complexity.

IBKR choose account type page for API trading setup
IBKR account setup for API access

Pros

  • Most powerful retail broker API available
  • ib_insync library is excellent and well-maintained
  • Real-time streaming via TWS socket
  • DMA with Smart Order Routing
  • Access to 150+ exchanges globally
  • FCA regulated (FRN 208159)

Cons

  • TWS must be running locally (or IB Gateway)
  • Complex setup — took me 2+ hours for first working script
  • No spread betting
  • Market data subscriptions cost extra

What Does IBKR API Access Cost?

API access is free. Trading commissions start from 0.05% with a £1 minimum on UK shares. You pay separately for market data subscriptions. The Client Portal API is free but limited in functionality compared to the TWS API. For serious development, you’ll use the TWS API, which requires TWS or IB Gateway running continuously.

What’s Development Like?

It took me over two hours to get my first working script — significantly longer than any other broker. The ib_insync library transforms the callback-heavy TWS API into async/await Python, which helps enormously. Once set up, the capabilities are unmatched: live streaming, historical data, complex order types, portfolio management, and options analytics all from Python.

Who Should Use IBKR’s API?

Experienced developers building sophisticated multi-asset trading systems. If your strategy involves options, futures, or cross-exchange arbitrage, IBKR is the only realistic choice. For straightforward forex or index CFD automation, IG is faster to implement and offers spread betting tax advantages.

62.5% of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you can afford to take the high risk of losing your money.

Which API Should a Python Beginner Start With?

Capital.com if you want the absolute simplest start. IG if you want something you won’t outgrow in six months.

Capital.com’s API requires only the requests library and basic HTTP knowledge. You can authenticate and pull prices in 10 lines of code. It’s ideal for learning REST concepts and building confidence before tackling streaming data or complex authentication.

IG’s API is a better long-term investment. The trading_ig library handles authentication and streaming for you, the documentation is thorough, and you have access to 17,000+ markets. The learning curve is steeper than Capital.com but shallower than IBKR. Most Python trading developers I know started with IG and never needed to switch.

For broader context on automated trading approaches, see our guides on building a trading bot and AI trading robots. For MT4-specific automation, read our Expert Advisors guide.

Broker API architecture diagram showing how Python connects to trading platforms via REST and WebSocket
How Python connects to broker APIs: REST and WebSocket architecture
Python API onboarding time comparison showing setup complexity across IG, Capital.com, and Interactive Brokers
API onboarding time: how long it takes to go from signup to first automated trade

Working Python Code Example – IG API Authentication & Price Pull

This script authenticates with IG’s REST API, pulls the current GBP/USD price, and prints it. It runs on Python 3.8+ with only the requests library (no trading_ig required). Replace the placeholder credentials with your IG demo account details.

import requests

# IG Demo API credentials (replace with your own)
API_KEY = "your-api-key-here"
USERNAME = "your-username"
PASSWORD = "your-password"

# Authentication
session = requests.Session()
session.headers.update({
    "X-IG-API-KEY": API_KEY,
    "Content-Type": "application/json; charset=UTF-8",
    "Accept": "application/json; charset=UTF-8",
    "Version": "2"
})

auth_payload = {
    "identifier": USERNAME,
    "password": PASSWORD
}

auth_url = "https://demo-api.ig.com/gateway/deal/session"
auth_response = session.post(auth_url, json=auth_payload)

if auth_response.status_code != 200:
    print(f"Auth failed: {auth_response.status_code}")
    exit()

# Extract tokens from response headers
cst = auth_response.headers.get("CST")
x_security_token = auth_response.headers.get("X-SECURITY-TOKEN")

session.headers.update({
    "CST": cst,
    "X-SECURITY-TOKEN": x_security_token
})

print("Authenticated successfully.")

# Pull GBP/USD price
market_url = "https://demo-api.ig.com/gateway/deal/markets/CS.D.GBPUSD.TODAY.IP"
market_response = session.get(market_url)
market_data = market_response.json()

bid = market_data["snapshot"]["bid"]
offer = market_data["snapshot"]["offer"]
spread = round(offer - bid, 4)

print(f"GBP/USD - Bid: {bid}, Offer: {offer}, Spread: {spread}")

# Clean up session
session.delete(auth_url)
print("Session closed.")

This is a starting point, not a production system. For live trading, you would add error handling, rate-limit management, and the Lightstreamer connection for real-time price streaming. The trading_ig library handles all of this automatically if you prefer a higher-level interface.

Frequently Asked Questions

Is IG’s API free to use?

Yes. API access is included with any IG account at no extra cost. There are no per-request charges. Your trading costs (spreads and commissions) are the same as manual trading.

Can I automate spread betting with Python?

Yes, through IG or Capital.com. Both offer spread betting via their APIs. Spread betting profits are tax-free for most UK residents, making these the most tax-efficient options for automated trading. Forex.com and Interactive Brokers do not offer spread betting.

Do I need a VPS to run a Python trading bot?

For strategies that need to run 24/5, yes. A cloud VPS (AWS, DigitalOcean, or similar) from roughly £5/month gives your bot reliable uptime without keeping your home computer running. For strategies that only trade during specific hours, your local machine may be sufficient.

Which Python libraries do I need?

At minimum: requests for REST API calls and pandas for data handling. For IG specifically, trading_ig simplifies authentication and streaming. For IBKR, ib_insync is essential. For backtesting, backtrader or vectorbt are popular choices.

What are the rate limits for broker APIs?

IG allows roughly 60 non-trading requests per minute and 15 trading requests per minute. Capital.com allows about 10 requests per second. IBKR’s TWS API allows 50 messages per second. These limits rule out true high-frequency trading but are ample for strategies that trade a few times per hour.

Can I use the IG API with a demo account?

Yes. IG provides a full demo API environment at demo-api.ig.com that mirrors the live API. You can develop and test your entire system on demo before switching to the live endpoint. All four brokers listed here offer demo API access.

References

  1. IG REST API Documentation – labs.ig.com/rest-trading-api-reference
  2. Capital.com API Documentation – open-api.capital.com
  3. Interactive Brokers API Guide – interactivebrokers.github.io/tws-api
  4. FCA Financial Services Register – register.fca.org.uk
  5. trading_ig Python Library – github.com/ig-python/trading-ig