DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 23.9h Behind: Catching Sustainability Sentiment Leads with Pulsebit

Your Pipeline Is 23.9h Behind: Catching Sustainability Sentiment Leads with Pulsebit

We recently uncovered a compelling anomaly: a 24-hour momentum spike of +0.171 in sustainability sentiment. This spike is not just a number; it’s a signal that something significant is happening in the discourse around sustainability, particularly in relation to NASA's latest initiatives. With the English press leading by 23.9 hours, you might be thinking: what are we missing in our analysis?

If your pipeline doesn't account for multilingual origins or entity dominance, you might have completely overlooked this crucial insight until it’s too late. In this case, your model missed the rising sentiment on sustainability by nearly a full day. The leading language in this discourse is English, which puts you at a disadvantage if your system isn’t configured to recognize the nuances of global conversations.

English coverage led by 23.9 hours. Hindi at T+23.9h. Confid
English coverage led by 23.9 hours. Hindi at T+23.9h. Confidence scores: English 0.85, French 0.85, Spanish 0.85 Source: Pulsebit /sentiment_by_lang.

To catch this momentum spike effectively, we can leverage our API to filter by language and analyze sentiment clusters. Below is the Python code that demonstrates how to achieve this.

import requests

# Set parameters for the API call
topic = 'sustainability'
score = +0.425
confidence = 0.85
momentum = +0.171

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


# STEP 1: Geographic origin filter
url = "https://api.pulsebit.com/v1/articles"
params = {
    "topic": topic,
    "lang": "en",
    "score": score,
    "confidence": confidence,
    "momentum": momentum
}
response = requests.get(url, params=params)
data = response.json()

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


# Output the response
print(data)
Enter fullscreen mode Exit fullscreen mode

Next, we want to analyze the narrative that clusters around this spike. Here’s how we can run the cluster reason string back through the sentiment scoring endpoint.

# STEP 2: Meta-sentiment moment
meta_sentiment_url = "https://api.pulsebit.com/v1/sentiment"
cluster_reason = "Clustered by shared themes: compliance, competitive, advantage:, embedding, sust"

meta_response = requests.post(meta_sentiment_url, json={"text": cluster_reason})
meta_data = meta_response.json()

# Output the sentiment score for the cluster reason
print(meta_data)
Enter fullscreen mode Exit fullscreen mode

These two API calls will help you pinpoint not only the rising sentiment around sustainability but also the specific framing of the conversation.

Now that we’ve extracted this signal, let's discuss three builds you can implement based on this pattern:

  1. Geo-Filtered Sentiment Dashboard: Create a dashboard that visualizes sentiment spikes by region. Use the geographic origin filter to pull data from different languages and compare emerging themes in sustainability. Set a threshold for momentum greater than +0.15 to catch significant shifts.

  2. Narrative Analysis Tool: Build a tool that uses the meta-sentiment loop to analyze how narratives evolve over time. Input various cluster reasons to see how sentiment scores change. Focus on framing themes like sustainability, compliance, and leadership.

  3. Competitive Advantage Alerts: Implement an alert system that triggers when sentiment around sustainability stories reaches a certain confidence level (e.g., 0.85) and momentum. This way, you can stay ahead of competitors by understanding how shifts in sentiment affect compliance and competitive advantage.

To start building with this data, refer to our documentation at pulsebit.lojenterprise.com/docs. You can copy, paste, and run the provided code within 10 minutes to catch the sustainability sentiment leads that could otherwise slip through the cracks.

Top comments (0)