DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 28.8h Behind: Catching World Sentiment Leads with Pulsebit

Your 24-hour momentum spike of +0.268 in sentiment surrounding the topic of "world" is a striking anomaly that highlights a fascinating shift in global news narratives. This spike is particularly tied to a cluster of articles discussing a remarkable event: Chinese humanoid robots breaking Usain Bolt’s 100m record. While the mainstream conversation remains focused on humanoid robots and records, the sentiment momentum is leading us toward a more optimistic framing. This is the kind of actionable insight you want to catch in your pipeline.

But what if your model missed this by 28.8 hours? The leading language was English, but if your pipeline doesn’t account for multilingual origins or the dominance of certain entities, you could be blind to significant sentiment changes. The world is evolving rapidly, and your models need to adapt just as quickly. If you’re only processing English language data, you are likely missing out on critical shifts that arise in other languages or regional contexts.

English coverage led by 28.8 hours. So at T+28.8h. Confidenc
English coverage led by 28.8 hours. So at T+28.8h. Confidence scores: English 0.85, Id 0.85, Spanish 0.85 Source: Pulsebit /sentiment_by_lang.

Here's how we can catch this sentiment spike programmatically. Below is a Python snippet that utilizes our API to filter articles by language, focusing specifically on the topic of "world."

import requests

# Setting up the API call
endpoint = "https://api.pulsebit.com/v1/articles"
params = {
    "topic": "world",
    "score": -0.013,
    "confidence": 0.85,
    "momentum": +0.268,
    "lang": "en"  # Filtering by English language
}

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


response = requests.get(endpoint, params=params)
articles = response.json()

# Output the articles
print(articles)
Enter fullscreen mode Exit fullscreen mode

Next, we want to assess the meta-sentiment of the cluster reason itself. This is crucial because it allows us to analyze how the narrative is being framed. Let’s run the string through our sentiment endpoint:

# Meta-sentiment analysis
meta_sentiment_endpoint = "https://api.pulsebit.com/v1/sentiment"
cluster_reason = "Clustered by shared themes: humanoid, record, world, chinese, robots."

meta_response = requests.post(meta_sentiment_endpoint, json={"text": cluster_reason})
meta_sentiment = meta_response.json()

# Output the sentiment score and confidence
print(meta_sentiment)
Enter fullscreen mode Exit fullscreen mode

By executing these API calls, you’re not just catching the anomaly but also understanding the broader implications of the sentiment around it.

Now, let’s explore three specific builds you can implement with this pattern:

  1. Geo-filtered Alert System: Build an alert that triggers when the sentiment momentum for the topic "world" exceeds a threshold of +0.2. Use the geographic origin filter to ensure you're only capturing articles in English.

Geographic detection output for world. India leads with 35 a
Geographic detection output for world. India leads with 35 articles and sentiment +0.11. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Dashboard: Create a dashboard that visualizes the sentiment scores of clustered articles, particularly focusing on those that mention "humanoid" and "record." Use the meta-sentiment loop we discussed to provide context around the narratives shaping public perception.

  2. Thematic Analysis Engine: Develop an engine that analyzes forming themes such as "world", "google", and "record". Set up a monitoring system that alerts you when these themes diverge significantly from the mainstream narratives like "humanoid" or "record."

By leveraging these insights, you can ensure your pipeline remains relevant and responsive to the ever-changing landscape of global sentiment.

To get started, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run these examples in under 10 minutes, setting yourself up to catch the next big momentum shift.

Top comments (0)