DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 11.9h Behind: Catching Sustainability Sentiment Leads with Pulsebit

Your Pipeline Is 11.9h Behind: Catching Sustainability Sentiment Leads with Pulsebit

We recently uncovered a striking anomaly: a 24-hour momentum spike of +0.563 in sustainability sentiment. This finding indicates that something significant is happening in the conversation around sustainability, particularly in the English press, which has been leading with a timestamp of 11.9 hours ahead. However, this spike reveals a gap that many pipelines may struggle to address, especially when dealing with multilingual content and entity dominance.

English coverage led by 11.9 hours. Italian at T+11.9h. Conf
English coverage led by 11.9 hours. Italian at T+11.9h. Confidence scores: English 0.85, Spanish 0.85, French 0.85 Source: Pulsebit /sentiment_by_lang.

If your model isn't equipped to handle different linguistic origins or the prominence of certain entities, you might have missed this trend by a substantial 11.9 hours. The leading language is English, while the Italian press trails behind, demonstrating how critical it is to have a multilingual grasp on content when assessing sentiment. This delay can result in missed opportunities to act on emerging trends or shifts in sentiment that could impact your strategies.

To catch this anomaly programmatically, we can leverage our API. Here's how we can capture the sentiment spike around the topic of sustainability.

import requests

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


# Define parameters
topic = 'sustainability'
score = +0.563
confidence = 0.85
momentum = +0.563
language = 'en'

# Geographic origin filter
response = requests.get('https://api.pulsebit.com/v1/articles', params={
    'topic': topic,
    'lang': language,
    'momentum': momentum,
    'score': score
})

![Geographic detection output for sustainability. India leads ](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_geo_output_1774010599031.png)
*Geographic detection output for sustainability. India leads with 2 articles and sentiment +0.85. Source: Pulsebit /news_recent geographic fields.*


articles = response.json()
print("Filtered articles:", articles)

# Meta-sentiment moment
meta_sentiment_input = "Semantic API incomplete — fallback semantic structure built from available keywords and article/search evidence."
meta_sentiment_response = requests.post('https://api.pulsebit.com/v1/sentiment', json={
    'text': meta_sentiment_input
})

meta_sentiment_score = meta_sentiment_response.json()
print("Meta-sentiment score:", meta_sentiment_score)
Enter fullscreen mode Exit fullscreen mode

In this code, we first filter articles based on the topic of sustainability and the specified language. This ensures that we’re tapping into the relevant English-language discussions. After that, we run a meta-sentiment analysis on the narrative framing itself to gauge how the sentiment is constructed around the observed spike. This dual approach allows us to not just see the spike but understand the conditions around it.

Now that we have a way to catch these spikes, here are three specific builds you might want to consider:

  1. Geographic Sentiment Analysis: Extend the geographic origin filter to include a broader range of languages. For instance, you could set a threshold of momentum greater than +0.5 to identify significant sentiment shifts across different languages, not just English.

  2. Meta-Sentiment Clustering: Use the meta-sentiment loop to build a clustering algorithm that identifies emerging themes based on sentiment scores. For example, if you detect a forming theme of "machine learning" with a score of +0.18, you can create alerts for further investigation.

  3. Real-Time Sentiment Dashboard: Construct a dashboard that visualizes sentiment trends in real-time, focusing on the forming gaps like "world" (+0.17) vs mainstream discussions. This dashboard can highlight articles that are gaining traction and flag them for your team to review.

We hope this gives you a clearer path to leveraging our API for catching key sentiment shifts. For more details, visit pulsebit.lojenterprise.com/docs. You can copy-paste the provided code and run it in under 10 minutes to see this in action.

Top comments (0)