DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

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

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

We recently uncovered a significant anomaly: a 24h momentum spike of +0.987 in the world sentiment space. This spike points to a notable surge in interest surrounding the narrative of Schwarzman's £185 million donation to humanities at Oxford, highlighting the way sentiment can shift sharply based on emerging stories. With this kind of data at our fingertips, it’s vital to ensure our pipelines are agile enough to catch these movements in real-time.

The Problem

This discovery exposes a critical structural gap in any sentiment analysis pipeline that doesn’t account for multilingual origins and entity dominance. Your model missed this spike by 23.9 hours, while the leading language was English. As a developer, you know that if your models are lagging behind by even a few hours, you risk missing out on valuable insights. The failure to process narratives like the Schwarzman donation means you could be left blind to critical shifts in public sentiment.

English coverage led by 23.9 hours. Sv at T+23.9h. Confidenc
English coverage led by 23.9 hours. Sv at T+23.9h. Confidence scores: English 0.85, Spanish 0.85, No 0.85 Source: Pulsebit /sentiment_by_lang.

The Code

To catch this momentum spike effectively, we can utilize our API to filter by geographic origin and process relevant narratives. Here’s how you can do it in Python:

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

import requests

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


# Step 1: Geographic origin filter
url = "https://api.pulsebit.com/sentiment"
params = {
    "topic": "world",
    "score": -0.032,
    "confidence": 0.85,
    "momentum": +0.987,
    "lang": "en"  # Filter for English language
}

response = requests.get(url, params=params)
data = response.json()

# Step 2: Meta-sentiment moment
cluster_reason = "Clustered by shared themes: schwarzman, £185, million, humanities, its."
sentiment_response = requests.post(url, json={"text": cluster_reason})
sentiment_data = sentiment_response.json()

print(data)
print(sentiment_data)
Enter fullscreen mode Exit fullscreen mode

In this code, we first filter the sentiment data by the English language, allowing us to focus on the most relevant narratives. Next, we run the cluster reason string back through the sentiment analysis endpoint to evaluate how the narrative itself is being framed.

Three Builds Tonight

Now that we’ve identified this spike, here are three specific builds you can create using this pattern:

  1. Geo-Filtered Sentiment Tracker: Set a signal threshold of +0.750 for world sentiment filtered by English. This will allow you to catch early signals of major events that could influence market sentiment, ensuring you’re always on top of emerging narratives.

  2. Meta-Sentiment Analyzer: Create an endpoint that leverages the meta-sentiment loop by scoring narrative clusters. Use the cluster reason string to score articles and derive insights based on themes like "schwarzman", "million", and "humanities." This will help you identify the framing of stories that influence sentiment.

  3. Forming Themes Monitor: Set up a monitoring service that alerts you when sentiment in forming themes like world, health, or google drops below a certain threshold (e.g., -0.050) compared to mainstream narratives. This could highlight potential market shifts or public reactions to news before they fully develop.

Get Started

You can dive into the specifics at pulsebit.lojenterprise.com/docs. With these examples, you can copy-paste and run this setup in under 10 minutes, enabling your pipeline to be more responsive and informed about the ongoing narrative landscape.

Top comments (0)