DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

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

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

We recently stumbled upon an intriguing anomaly: a 24h momentum spike of +0.800 in sentiment around the topic of sustainability. This spike is particularly compelling, especially considering it aligns with a leading narrative from the English press, led by a 19.9-hour lag. The article titled "EUDCA Recommits to Data Centre Sustainability Agenda" encapsulates the emerging conversation around sustainability and data centers. With just one article in the cluster, it’s clear that something significant is brewing.

Without a robust multilingual pipeline, you might find your model missing these critical moments by nearly 20 hours. This isn't just an oversight; it’s a structural gap that can leave you trailing behind in your understanding of emerging themes. The dominant entity here is the EUDCA, and if your model isn’t equipped to handle this type of entity dominance, you risk missing out on vital insights driven by global sentiment.

English coverage led by 19.9 hours. Nl at T+19.9h. Confidenc
English coverage led by 19.9 hours. Nl at T+19.9h. Confidence scores: English 0.85, Spanish 0.85, French 0.85 Source: Pulsebit /sentiment_by_lang.

To catch this momentum spike, we can leverage our API effectively. Here’s how you can code it in Python to ensure you’re not left behind:

import requests

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


# Step 1: Geographic origin filter
url = "https://api.pulsebit.com/sentiment"
params = {
    "topic": "sustainability",
    "lang": "en"
}
response = requests.get(url, params=params)
data = response.json()

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


# Example data from the API response
momentum = +0.800
score = +0.775
confidence = 0.85

print(f"Momentum: {momentum}, Sentiment Score: {score}, Confidence: {confidence}")
Enter fullscreen mode Exit fullscreen mode

Next, we need to run the narrative framing through our meta-sentiment endpoint to score it based on the clustered reasoning.

# Step 2: Meta-sentiment moment
cluster_reason = "Clustered by shared themes: sustainability, recommits, data, centre, eudca."
meta_sentiment_url = "https://api.pulsebit.com/sentiment/meta"
meta_response = requests.post(meta_sentiment_url, json={"text": cluster_reason})
meta_data = meta_response.json()

print(f"Meta Sentiment Score: {meta_data['score']}, Confidence: {meta_data['confidence']}")
Enter fullscreen mode Exit fullscreen mode

This approach allows us to not only capture the raw sentiment but also understand the narrative framing behind it — crucial for informed decision-making.

Now that we’ve established the basic framework, here are three specific builds we can implement with this newfound insight:

  1. Sustainability Pipeline Alert: Set up a threshold alert for when the momentum score exceeds +0.800. Use the geographic origin filter to ensure you're only tracking English-language articles. This can keep your team updated in real-time on pivotal sustainability discussions.

  2. Meta-Sentiment Analysis Tool: Create a dashboard that leverages the meta-sentiment loop to visualize how specific narratives around sustainability evolve over time. By regularly querying the cluster reason, you can identify which themes are gaining traction and adjust your strategies accordingly.

  3. Cross-Entity Comparison: Implement a comparison tool that tracks the sentiment for sustainability versus other emerging themes, such as "Google" and "Africa". By analyzing these against the mainstream sentiment, you can uncover unique insights that highlight forming gaps and opportunities.

If you want to dive deeper into these capabilities, check out our documentation at pulsebit.lojenterprise.com/docs. With just a bit of effort, you can copy-paste and run this code in under 10 minutes. Don’t let your pipeline lag behind; catch the sustainability sentiment leads today!

Top comments (0)