DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 19.3h Behind: Catching Business Sentiment Leads with Pulsebit

Your Pipeline Is 19.3h Behind: Catching Business Sentiment Leads with Pulsebit

We just noticed an intriguing anomaly: a 24h momentum spike of +0.102 in business sentiment. This spike stands out against the backdrop of recent discussions in English press, particularly around the Kerala Police warning companies against a “boss scam” cyber fraud. With this significant uptick, it's clear there’s a pulse we need to catch and understand.

But here's the kicker — your model missed this by 19.3 hours. If you’re not accounting for multilingual origin or entity dominance, you’re potentially out of sync with emerging trends. The leading language in this spike is English, but the content of the story focuses heavily on local developments in Kerala. Ignoring this can lead to missed opportunities in sentiment analysis, especially when regional events are driving spikes in sentiment.

English coverage led by 19.3 hours. Et at T+19.3h. Confidenc
English coverage led by 19.3 hours. Et at T+19.3h. Confidence scores: English 0.85, Spanish 0.85, French 0.85 Source: Pulsebit /sentiment_by_lang.

To catch this anomaly, we can leverage our API to create a focused query. Here’s how we can filter for the relevant sentiment data:

import requests

# Define the parameters for our API call
params = {
    'topic': 'business',
    'lang': 'en',  # We're focusing on English content
    'momentum': 0.102,
}

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


# Make the API call
response = requests.get('https://api.pulsebit.com/sentiment', params=params)
data = response.json()  # Process the JSON response

# Now, let's extract and print the relevant information
print(data)
Enter fullscreen mode Exit fullscreen mode

Next, we need to dive deeper into the narrative framing by running the cluster reason string back through our sentiment scoring endpoint. The cluster reason we have is: "Clustered by shared themes: kerala, police, companies, cyber, fraud." Here’s how we can score that narrative:

# Define the cluster reason for sentiment scoring
narrative = "Clustered by shared themes: kerala, police, companies, cyber, fraud."

# POST request to score the narrative
response = requests.post('https://api.pulsebit.com/sentiment', json={'text': narrative})
narrative_score = response.json()  # Process the JSON response

# Display the sentiment score of the narrative
print(narrative_score)
Enter fullscreen mode Exit fullscreen mode

With these two snippets, we're not only capturing a significant business sentiment spike but also understanding the context driving it.

Now, what can we build with this newfound insight? Here are three specific builds we can implement:

  1. Geographic Origin Filter: Set up a monitoring endpoint that tracks business sentiment specifically in regions where English is predominantly spoken. For example, use the geo filter to alert on spikes originating from any English-speaking country, not just the U.S. This allows us to capture global sentiment shifts.

Geographic detection output for business. India leads with 4
Geographic detection output for business. India leads with 4 articles and sentiment +0.04. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Loop: Create a feedback loop that runs the cluster reasons through our sentiment scoring. For instance, every time there’s a spike in sentiment around themes like "cyber fraud", we can automatically score the narrative and adjust our content strategy accordingly.

  2. Forming Themes Tracker: Build a dashboard that visualizes forming themes like business, Google, and businesses against mainstream topics such as Kerala, police, and companies. This will help us stay ahead of the curve and react proactively to emerging narratives.

If you’re looking to implement this, head over to our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste these snippets and get running in under 10 minutes. Let's make sure we're not just catching up but staying ahead of these significant sentiment trends.

Top comments (0)