DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 14.8h Behind: Catching Energy Sentiment Leads with Pulsebit

Your Pipeline Is 14.8h Behind: Catching Energy Sentiment Leads with Pulsebit

We recently uncovered a striking anomaly: a 24h momentum spike of +0.277 in energy sentiment. This isn’t just a number; it’s a signal that can drastically change how we perceive potential market shifts. The leading language for this spike? French. It’s a clear indicator that significant conversations are happening outside your usual English-centric data feeds, and if you’re not tuned in, you’re missing out.

But here’s the kicker: your model missed this by 14.8 hours. If you’re only processing data in English or focusing solely on dominant entities, you’re lagging behind. In this case, the French press is leading the narrative, yet your pipeline is stuck in the past, potentially costing you insights that could inform your strategies.

To harness this momentum spike, we can leverage our API to catch these insights programmatically. Here’s a concise Python snippet that does just that. First, we’ll query the sentiment data focusing on the French language, which is critical for this analysis:

import requests

# Define the parameters for the API call
params = {
    "topic": "energy",
    "score": +0.194,
    "confidence": 0.95,
    "momentum": +0.277,
    "lang": "fr"  # Filtering by French language
}

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


# Make the API call to get the energy sentiment
response = requests.get('https://api.pulsebit.com/sentiment', params=params)
data = response.json()
print(data)
Enter fullscreen mode Exit fullscreen mode

Next, we need to analyze the narrative framing itself through the meta-sentiment moment. This is where we run the cluster reason string back through our API to score the thematic framing:

# Define the cluster reason for meta sentiment analysis
input_example = "Clustered by shared themes: iran, west, asia, live:, threatens."

# Make the POST request to get the meta sentiment score
meta_response = requests.post('https://api.pulsebit.com/sentiment', json={"text": input_example})
meta_data = meta_response.json()
print(meta_data)
Enter fullscreen mode Exit fullscreen mode

By incorporating these two calls, you’ll not only identify the sentiment spike but also understand the context driving it. This dual approach gives you a comprehensive view of the energy landscape, particularly in relation to the rising threats from Iran and how they’re being framed in the media.

Now that we have the groundwork laid out, here are three specific builds to consider:

  1. Geographic Anomaly Detector: Use the geo filter to catch spikes in sentiment across multiple languages. Set a threshold for momentum, say +0.25, and trigger alerts when the energy topic spikes in French or other languages.

Geographic detection output for energy. India leads with 4 a
Geographic detection output for energy. India leads with 4 articles and sentiment +0.44. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Score Tracker: Automate the analysis of narratives surrounding energy. Whenever you detect a sentiment change, run the associated cluster reason through the sentiment API to score the narrative. This can help in identifying emerging themes before they hit mainstream outlets.

  2. Forming Theme Watchlist: Create a watchlist for forming themes that merge topics like energy (+0.00), Google (+0.00), and Iran (+0.00). Set alerts for when any of these themes start to diverge from the mainstream narratives of Iran, the West, and Asia, indicating potential market shifts.

With these builds, you can stay ahead of the curve and ensure that your models are not just reactive but proactive in capturing sentiment shifts.

For more insights and to get started, check out our documentation at pulsebit.lojenterprise.com/docs. With just a few lines of code, you can copy-paste and run this in under 10 minutes to start catching these critical signals.

French coverage led by 14.8 hours. Sv at T+14.8h. Confidence
French coverage led by 14.8 hours. Sv at T+14.8h. Confidence scores: French 0.95, English 0.95, Spanish 0.95 Source: Pulsebit /sentiment_by_lang.

Top comments (0)