DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 29.1h Behind: Catching Human Rights Sentiment Leads with Pulsebit

Your Pipeline Is 29.1h Behind: Catching Human Rights Sentiment Leads with Pulsebit

We just noticed a significant anomaly in our data: a 24h momentum spike of +1.450 for the topic of human rights. This spike is underscored by a pressing story titled "KSHRC seeks NHAI report on Adimaly mudslide tragedy," which is clustering around shared themes of report, Adimaly, mudslide, tragedy, and KSHRC. It’s a stark reminder that in the fast-paced world of sentiment analysis, missing these signals can have dire consequences for our understanding of emerging narratives.

Imagine you’re running a sentiment pipeline that doesn’t account for multilingual origins or the dominance of specific entities. Your model missed this critical momentum by a staggering 29.1 hours, relying solely on mainstream narratives. While you were focused on other topics, the leading language—English—suddenly became pivotal in understanding the unfolding human rights narrative related to the Adimaly tragedy. This is a clear indicator that your pipeline needs to evolve to capture these multi-layered stories in real time.

English coverage led by 29.1 hours. Et at T+29.1h. Confidenc
English coverage led by 29.1 hours. Et at T+29.1h. Confidence scores: English 0.95, Spanish 0.95, Sw 0.95 Source: Pulsebit /sentiment_by_lang.

Let’s dive into how we can catch this anomaly using our API. We’ll start by filtering for sentiment data in English and then apply a meta-sentiment check on the cluster reason string.

import requests

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


# Define the API endpoint and parameters
endpoint = "https://api.pulsebit.com/sentiment"
topic = 'human rights'
score = -0.700
confidence = 0.95
momentum = +1.450

# Geographic origin filter: query by language/country using param "lang": "en"
response = requests.get(endpoint, params={
    "topic": topic,
    "score": score,
    "confidence": confidence,
    "momentum": momentum,
    "lang": "en"
})

![Geographic detection output for human rights. India leads wi](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_geo_output_1778866376826.png)
*Geographic detection output for human rights. India leads with 6 articles and sentiment -0.35. Source: Pulsebit /news_recent geographic fields.*


# Check for a successful response
if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print(f"Error: {response.status_code}")

# Now, let's run the cluster reason string back through POST /sentiment
cluster_reason = "Clustered by shared themes: report, adimaly, mudslide, tragedy, kshrc."
response_meta = requests.post(endpoint, json={
    "text": cluster_reason,
    "score": score,
    "confidence": confidence
})

if response_meta.status_code == 200:
    meta_data = response_meta.json()
    print(meta_data)
else:
    print(f"Error: {response_meta.status_code}")
Enter fullscreen mode Exit fullscreen mode

Now that we’ve captured the data, what can we build with this momentum spike? Here are three specific ideas:

  1. Geo-focused Sentiment Tracker: Create a real-time tracker that uses the geo filter to monitor human rights sentiment in English across regions impacted by the Adimaly mudslide. Set a threshold, for example, only trigger alerts when momentum exceeds +1.000.

  2. Meta-Sentiment Analyzer: Use the meta-sentiment loop we just demonstrated to continuously analyze narratives around emerging topics. Whenever a cluster reason indicates a significant shift, such as the themes of rights, human, and the recent tragedy, trigger further analysis or alerts.

  3. Real-time Reporting Dashboard: Build a dashboard that visualizes sentiment trends for clustered stories like the mudslide tragedy. Use our API to fetch data and display trends for the keywords "report," "Adimaly," and "mudslide." You can set alerts for when any of these terms begin to spike in sentiment or volume.

To get started, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run the provided code in under 10 minutes. Don’t let your pipeline fall behind!

Top comments (0)