DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 25.9h Behind: Catching Banking Sentiment Leads with Pulsebit

Your model missed this by 25.9 hours. That's how far behind traditional sentiment pipelines can be when they don’t account for multilingual origin or entity dominance. Take the recent 24-hour momentum spike of +0.389 around the banking sector, particularly driven by the article titled "Why Deutsche Bank exiting India retail business | Explained." This spike illustrates a significant shift in sentiment that your existing frameworks might overlook, especially if they focus solely on English content or fail to capture the nuances of regional developments.

English coverage led by 25.9 hours. Af at T+25.9h. Confidenc
English coverage led by 25.9 hours. Af at T+25.9h. Confidence scores: English 0.90, Sv 0.90, French 0.90 Source: Pulsebit /sentiment_by_lang.

To catch these insights, we can leverage our API to create a Python script that accurately identifies these trends in real-time. Here's how we can implement it:

import requests

# Set parameters for the API call
topic = 'banking'
lang = 'en'
score = +0.300
confidence = 0.90
momentum = +0.389

![Left: Python GET /news_semantic call for 'banking'. Right: r](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_code_output_split_1783107962867.png)
*Left: Python GET /news_semantic call for 'banking'. Right: returned JSON response structure (clusters: 3). Source: Pulsebit /news_semantic.*


# Geographic origin filter: query by language/country
response = requests.get(f'https://api.pulsebit.com/sentiment?topic={topic}&lang={lang}')
data = response.json()

![Geographic detection output for banking. India leads with 8 ](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_geo_output_1783107962944.png)
*Geographic detection output for banking. India leads with 8 articles and sentiment +0.18. Source: Pulsebit /news_recent geographic fields.*


# Check if we have the right data
if data['momentum_24h'] > momentum and data['sentiment_score'] > score:
    print(f"Found significant sentiment for {topic}: {data}")
else:
    print("No significant sentiment found.")

# Meta-sentiment moment: run the cluster reason string back through POST /sentiment
cluster_reason = "Clustered by shared themes: why, deutsche, bank, what, exiting."
meta_response = requests.post('https://api.pulsebit.com/sentiment', json={"text": cluster_reason})
meta_data = meta_response.json()

print(f"Meta sentiment score: {meta_data['sentiment_score']}, Confidence: {meta_data['confidence']}")
Enter fullscreen mode Exit fullscreen mode

In this code, we first set up a query to capture sentiment data for banking in English. We use a geographic origin filter by specifying "lang": "en", ensuring we're focusing on the right audience. Then, we check if the sentiment meets our defined thresholds for momentum and score.

Next, we run the narrative cluster string through our sentiment endpoint to assess how the media is framing the story. This is crucial as it allows us to understand not just the sentiment score but the context of the narrative itself. The API response reveals sentiment dynamics that could be pivotal for understanding market movements.

Here are three specific things we can build with this pattern:

  1. Real-time Alerts on Banking Sentiment: Set a threshold of momentum > +0.389 and sentiment_score > +0.300. Use the geo filter to only alert for significant spikes in English-language articles pertaining to banking. This keeps your focus sharp on emerging trends.

  2. Meta-Analysis Dashboard: Create a dashboard that visualizes the meta-sentiment scores from clustered narratives. By running the cluster reason through our API, you can identify shifts in public perception and sentiment framing over time. This can help you adjust your strategies proactively.

  3. Cross-Entity Comparison Tool: Build a tool that compares sentiment and momentum across multiple financial institutions, using the existing framework. For example, monitor Deutsche Bank alongside other major banks to see how their narratives cluster and diverge, especially in relation to mainstream topics such as "why" and "exiting."

We encourage you to get started by exploring our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste the provided code and have it running in under 10 minutes. This is your chance to catch up on sentiment analysis and stay ahead of the curve.

Top comments (0)