Tuesday, September 15, 2026
Stream Real-Time Stock News in Python with finlight
Stream Real-Time Stock News in Python with finlight
Polling an API for news means you're always a little behind. For live dashboards and trading signals, you want each article the moment it's published. finlight's WebSocket does exactly that, and the Python SDK makes it a few lines. In this tutorial you'll build a live stream of stock news, filtered by ticker and already scored for sentiment.
Install the SDK
pip install finlight-client
The full example
import asyncio
from finlight_client import FinlightApi, ApiConfig
from finlight_client.models import GetArticlesWebSocketParams
client = FinlightApi(config=ApiConfig(api_key="YOUR_API_KEY"))
def on_article(article):
print(f"[{article.sentiment}] {article.title} - {article.source}")
async def main():
await client.websocket.connect(
request_payload=GetArticlesWebSocketParams(
tickers=["AAPL", "NVDA"],
includeEntities=True,
),
on_article=on_article,
)
if __name__ == "__main__":
asyncio.run(main())
Run it, and every time a matching article is published, your on_article callback fires with the
article, including its sentiment, title, source, and (because includeEntities is on) the tagged
companies.
What's happening
client.websocket.connect(...)opens a persistent connection and streams matching articles. It's an async call, so it runs insideasyncio.run(...).GetArticlesWebSocketParamstakes the same kinds of filters as the REST API:tickers,query,sources,countries,categories,language,includeEntities, and more.on_articleis your handler. This is where you'd push to a queue, update a dashboard, or evaluate a signal instead of just printing.
The SDK manages the connection for you, including automatic reconnection with backoff, so a dropped connection won't stop your stream.
Enhanced vs raw
client.websocket is the enhanced stream: articles arrive with full enrichment (sentiment and
entities). If you only need lightweight, basic article data as fast as possible, there's also
client.raw_websocket with the same connect(...) shape. Use enhanced when you want the analysis,
raw when you want minimal latency.
Filter to exactly what you need
Because the WebSocket accepts the same filters as REST, you can stream a precise slice: only crypto news, only a watchlist of tickers, only certain countries. See Advanced Filtering for the full filter set.
Where to go next
- REST vs WebSocket vs Webhooks vs MCP to decide when streaming is the right choice.
- Full documentation for the WebSocket guides.
