Broker API HubMenu

IG streaming with Python

IG's prices do not stream over its REST API. They stream over the streaming connection, and the endpoint you connect to is not in the documentation: it comes back in the body of your login response.

Independent and unofficialLast reviewed

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Carried over from an earlier version of this site. The links below are the sources it was written from, but its statements have not been re-read at source since the date shown, so check anything you rely on.

What you need to know before you write a line

A vendor push protocol, not a WebSocket of IG's own. IG's own page lists REST and streaming for standard users, with FIX reserved for institutional clients.

Source: How to use IG API checked 18 Sep 2026

POST /session returns lightstreamerEndpoint alongside your account details. You connect to the host in that field, not to a fixed address, and it differs between demo and live.

Source: IG Group Java sample client checked 18 Sep 2026

The same CST and X-SECURITY-TOKEN the session call returns. The streaming user is your IG account identifier and the password carries both tokens.

Source: Streaming API guide, IG Labs checked 12 Oct 2026

Up to 40 simultaneous subscriptions per connection by default. IG warns on the same page that opening multiple connections to exceed that number risks having your API permissions revoked. Design for 40, not for a workaround.

Source: Streaming API guide, IG Labs checked 12 Oct 2026

trading-ig, the community wrapper at ig-python/trading-ig, includes a streaming service over the streaming client. Version 0.0.25 (25 Aug 2026) needs Python 3.10 or later, is BSD-3-Clause and is marked Alpha on PyPI. It has 374 stars and is still being pushed.

Source: GitHub: ig-python/trading-ig checked 19 Sep 2026

trading-ig is the only serious IG wrapper in any language that is still maintained, and it is community run in spare time. IG's own Java, C# and JavaScript samples have been deprecated since August 2024. Plan for the possibility that nobody maintains your streaming layer.

Source: GitHub: IG-Group/ig-webapi-java-sample checked 18 Sep 2026

The code

Demo host only, and the credentials are read from environment variables you set yourself. The login step is ours. The streaming step uses the interface trading-ig 0.0.25 actually exposes: Subscription, SubscriptionListener and ItemUpdate are imported from the lightstreamer.client package, which trading-ig pins as lightstreamer-client-lib==1.0.3; the listener is an object implementing onItemUpdate rather than a callable; and the subscription is registered through IGStreamService.subscribe. There is no trading_ig.lightstreamer module. That shape was read on 19 Sep 2026 from sample/stream_ig.py and trading_ig/stream.py in the ig-python/trading-ig repository and from the trading-ig 0.0.25 metadata on PyPI. We have not run this script, so it is a starting point and not a tested one. The epic and the field names are IG names and yours will differ.

# IG streaming from Python. DEMO ONLY, and nothing here places a trade.
# Step 1 uses requests, because the streaming host is not in the documentation:
# it comes back in the body of POST /session.
import os

import requests
from lightstreamer.client import ItemUpdate, Subscription, SubscriptionListener
from trading_ig import IGService, IGStreamService

BASE = "https://demo-api.ig.com/gateway/deal"  # demo host, not live

resp = requests.post(
    BASE + "/session",
    headers={
        "X-IG-API-KEY": os.environ["IG_API_KEY"],
        "VERSION": "2",
        "Content-Type": "application/json; charset=UTF-8",
        "Accept": "application/json; charset=UTF-8",
    },
    json={"identifier": os.environ["IG_IDENTIFIER"], "password": os.environ["IG_PASSWORD"]},
    timeout=10,
)
resp.raise_for_status()
print("Stream host:", resp.json()["lightstreamerEndpoint"])  # never hard-code this

# Step 2: trading-ig does the streaming handshake with the same credentials.
service = IGService(
    os.environ["IG_IDENTIFIER"],
    os.environ["IG_PASSWORD"],
    os.environ["IG_API_KEY"],
    "DEMO",
)
stream = IGStreamService(service)
stream.create_session()

# The streaming client takes a listener object, not a callable.
class PriceListener(SubscriptionListener):
    def onItemUpdate(self, update: ItemUpdate):
        print(
            update.getItemName(),
            update.getValue("UPDATE_TIME"),
            update.getValue("BID"),
            update.getValue("OFFER"),
            update.getValue("MARKET_STATE"),
        )

    def onSubscriptionError(self, code, message):
        print("Subscription error", code, message)


# Design for 40 subscriptions on this one connection. IG states that opening extra
# connections to get past that cap breaches its terms.
subscription = Subscription(
    mode="MERGE",
    items=["MARKET:CS.D.EURUSD.CFD.IP"],
    fields=["UPDATE_TIME", "BID", "OFFER", "MARKET_STATE"],
)
subscription.addListener(PriceListener())
stream.subscribe(subscription)

try:
    input("Streaming. Press Enter to stop.\n")
finally:
    stream.disconnect()

What catches people first

Where to go next

The 40 subscription cap, and an older forum reading

IG's Streaming API Guide, read in a browser on 12 Oct 2026, names Lightstreamer throughout and gives up to 40 simultaneous subscriptions per connection by default, each subscription holding a list of items of one type. IG's FAQ, read the same day, gives 40 concurrent subscriptions and says to manage the limit by unsubscribing and subscribing as needed.

labs.ig.com/node/28, a forum thread whose content dates back to 2014, was read on 2 Oct 2026 and said the cap counts market items rather than tables. That is not how the guide words it. On 12 Oct 2026 the thread showed an out of service notice in a browser, so it could not be read again. It is a forum post, not a reference page; where the two differ, the guide is IG's own documentation.

Sources: Streaming API guide, IG Labs · IG Labs FAQ · checked 12 Oct 2026. labs.ig.com/node/28 · last read 2 Oct 2026

Independent and unofficial. Not affiliated with, endorsed by or operated by any firm named here.

Sections