DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

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

In just the last 24 hours, we've observed a momentum spike of +0.221 around the topic of "world." This anomaly isn't just a random blip; it signals a significant shift in sentiment that could have cascading implications for how we understand global narratives. Notably, this momentum is being driven by English-language press coverage, which has a leading edge of 25.8 hours. That’s a clear signal that there’s something brewing in the conversation that you might want to catch up with.

If your sentiment analysis pipeline doesn’t handle multilingual sources or takes into account dominance by specific entities, you might find yourself missing critical developments. In this case, your model missed the opportunity to capture this spike by 25.8 hours due to focusing solely on mainstream narratives. The dominant discourse around "world" and its recent coverage indicates that there's a growing sentiment that could be beneficial for your strategy.

English coverage led by 25.8 hours. Ro at T+25.8h. Confidenc
English coverage led by 25.8 hours. Ro at T+25.8h. Confidence scores: English 0.85, Spanish 0.85, Sl 0.85 Source: Pulsebit /sentiment_by_lang.

Here's how we can catch this spike with our API. First, we need to filter the data based on language and geographic origin. We'll query the topic "world" and specify the language as English:

import requests

# Define the parameters for the API call
params = {
    "topic": "world",
    "lang": "en",
}

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


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

# Extract values
momentum = data['momentum_24h']  # +0.221
score = data['sentiment_score']    # +0.124
confidence = data['confidence']     # 0.850
Enter fullscreen mode Exit fullscreen mode

Now, let’s leverage meta-sentiment to score the narrative framing itself. We can run the cluster reason string back through our sentiment endpoint:

# Define the cluster reason string
cluster_reason = "Clustered by shared themes: world, has, 193, countries, but."

# Make the API call to score the narrative
meta_sentiment_response = requests.post('https://api.pulsebit.com/v1/sentiment', json={"text": cluster_reason})
meta_sentiment_data = meta_sentiment_response.json()

# Extract the meta-sentiment score
meta_score = meta_sentiment_data['sentiment_score']  # This will give us insight into the framing
Enter fullscreen mode Exit fullscreen mode

With the data in hand, here are three specific things we can build using this pattern:

  1. Signal Monitoring: Set a threshold to catch spikes in sentiment momentum greater than +0.2. Use the geographic filter to ensure you’re only looking at English-language content. This can help you stay ahead of narratives that are gaining traction.

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

  1. Meta-Sentiment Analysis: Implement a loop that requests cluster reason strings for all topics you monitor. Score them to understand how narratives are being framed. For example, if the reason string returns a sentiment score below +0.1, it may indicate a need for deeper investigation.

  2. Forming Themes Tracker: Create a tracker that specifically identifies forming themes like "world," "cup," and "has." Compare their sentiment momentum against mainstream topics. If "world" shows a rising momentum while others are flat, it’s time to reassess your model's focus.

If you want to dive deeper into this, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste the code snippets above and have them running in under 10 minutes. Don’t let your pipeline lag behind; catch those emerging sentiments before they become mainstream narratives.

Top comments (0)