Get News for a Ticker with the IBKR API

This example shows how to get News items for a stock given its ticker symbol using the Interactive Brokers (IBKR) API in Python.

The API distinguishes Historical News from streaming, real-time news.
This post is about historical news, i.e. a list of dates sorted by time.
This is different from subscribing to News ticks and listening for new news events.

Note that we need to get the Contract ID for the ticker symbol first.
The Contract ID (conId) is stored inside the IBapi object for later use.

This is done in contractDetails().

The default, freely available news sources in the API are:

  • Briefing.com General Market Columns (BRFG)
  • Briefing.com Analyst Actions (BRFUPDN)
  • Dow Jones Newsletters (DJNL)

If you are subscribed to more news sources, they can be included in the API results given the proper codes.

Some other things to note:

  • The API returns headlines with extra metadata such as language inside braces ({…}). We filter these out using a regular expression as there does not seem to be any way to omit them from the results.
  • IBKR Trader Workstation (TWS) is assumed to be running on localhost.

Complete script:

import re
import threading
import time

from datetime import datetime, timedelta

from ibapi.client import EClient, Contract
from ibapi.contract import ContractDetails
from ibapi.wrapper import EWrapper

# Extend IBKR scanner base class.
class IBapi(EClient, EWrapper):
  def __init__(self):
    EClient.__init__(self, self)

  def contractDetails(self, reqId: int, contractDetails: ContractDetails):
    print(f"Ticker: {contractDetails.contract.symbol}, conId: {contractDetails.contract.conId}")
    self.conId = contractDetails.contract.conId

  def historicalNews(self, requestId, timeStamp, providerCode, articleId, headline):
    print(timeStamp + " " + self.cleanHeadline(headline))

  # Remove metadata often included in the headline within "{...}", sometimes with "!".
  def cleanHeadline(self, headline):
    return re.sub("\{.*?}!?", "", headline)

# Main script.
TWS_HOST = "127.0.0.1"
TWS_PORT = 7497
CLIENT_ID = 12345

ticker = input("Ticker symbol: ")

ibApi = IBapi()
ibApi.connect(TWS_HOST, TWS_PORT, CLIENT_ID)
threading.Thread(target=ibApi.run).start()
time.sleep(5) # Allow time for subscription.

# Contract object for the stock.
contract = Contract()
contract.symbol = ticker
contract.secType = "STK" # Stocks.
contract.exchange = "SMART"
contract.currency = "USD"

ibApi.reqContractDetails(
  reqId=101,
  contract=contract
)

time.sleep(3) # Allow time to get contract details.

PROVIDERS = "BRFG+BRFUPDN+DJNL" # Briefing.com, Dow Jones Newsletters.
TOTAL_RESULTS = 15
LOOKBACK_DAYS = 10 # Num days from now to oldest news.
DATE_FORMAT = "%Y%m%d %H:%M:%S"

currentDatetime = datetime.now()
currentDatetimeFormatted = currentDatetime.strftime(DATE_FORMAT)

tenDaysAgo = currentDatetime - timedelta(days=LOOKBACK_DAYS)
tenDaysAgoFormatted = tenDaysAgo.strftime(DATE_FORMAT)

ibApi.reqHistoricalNews(
  reqId=102,
  conId=ibApi.conId, # Contract ID for ticker.
  providerCodes=PROVIDERS,
  startDateTime=tenDaysAgoFormatted,
  endDateTime=currentDatetimeFormatted,
  totalResults=TOTAL_RESULTS,
  historicalNewsOptions=[]
)

time.sleep(1)
ibApi.disconnect()

Example run:

Ticker symbol: TSLA
Ticker: TSLA, conId: 76792991
2025-10-02 14:19:54.0 Tesla cruises past Q3 delivery estimates, but tax credit pull-forward clouds Q4 outlook
2025-09-30 14:59:17.0 Canaccord Genuity reiterated Tesla (TSLA) coverage with Buy and target $490
2025-09-26 11:49:39.0 Deutsche Bank reiterated Tesla (TSLA) coverage with Buy and target $435
2025-09-23 11:51:14.0 Mizuho reiterated Tesla (TSLA) coverage with Outperform and target $450
2025-09-22 12:57:41.0 Piper Sandler reiterated Tesla (TSLA) coverage with Overweight and target $500
2025-09-19 12:20:40.0 Robert W. Baird upgraded Tesla (TSLA) to Outperform with target $548
2025-09-18 17:11:04.0 Goldman reiterated Tesla (TSLA) coverage with Neutral and target $395
2025-09-15 14:03:38.0 Tesla's Musk makes bold $1 bln stock bet amid EV headwinds and AI ambitions
2025-07-29 12:14:24.0 RBC Capital Mkts reiterated Tesla (TSLA) coverage with Outperform and target $325
2025-07-25 13:00:32.0 China Renaissance downgraded Tesla (TSLA) to Hold with target $349
2025-07-24 14:20:22.0 Tesla's better-than-feared Q2 results overshadowed by Musk's cautious outlook
2025-07-24 11:54:12.0 Canaccord Genuity reiterated Tesla (TSLA) coverage with Buy and target $333
2025-07-07 12:14:59.0 William Blair downgraded Tesla (TSLA) to Mkt Perform
2025-07-01 14:10:42.0 Tesla shares slide as Trump targets Musk's EV subsidies in public spat
2025-06-26 12:32:13.0 The Benchmark Company reiterated Tesla (TSLA) coverage with Buy and target $475

Note:

It is also possible to get entire articles with reqNewsArticle().

References

https://interactivebrokers.github.io/tws-api/news.html