DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 17.0h Behind: Catching Climate Sentiment Leads with Pulsebit

Your 24h momentum spike of +0.344 around the topic of climate is a fascinating discovery. This indicates a significant shift in sentiment that you can’t afford to ignore. What’s even more compelling is that the leading language driving this spike is English, with an interesting focus on a specific cluster story: “A roadmap for Kerala’s agricultural transformation.” It’s clear that there is an emerging conversation on climate change that may not be on your radar yet, and it's crucial to tap into this momentum.

If your pipeline doesn’t account for multilingual data or entity dominance, you might find yourself 17.0 hours behind the curve. In this case, the leading language is English, and any model that only processes data in a single language or fails to recognize dominant entities will miss critical sentiment shifts. This means you could be operating with outdated information—missing out on valuable insights that could inform your strategies.

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

To catch this sentiment spike, we can leverage our API effectively. Here’s how to implement a Python script that utilizes the geographic origin filter and scores the narrative framing through meta-sentiment analysis.

Geographic detection output for climate. India leads with 6
Geographic detection output for climate. India leads with 6 articles and sentiment +0.53. Source: Pulsebit /news_recent geographic fields.

import requests

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


# Step 1: Fetching sentiment data with geographic origin filter
url = "https://api.pulsebit.com/sentiment"
params = {
    "topic": "climate",
    "lang": "en",  # Filter for English articles
    "momentum": +0.344,
    "signal_strength": 0.638,
    "articles_processed": 11,
}
response = requests.get(url, params=params)
climate_data = response.json()

# Step 2: Running meta-sentiment analysis on the cluster reason string
meta_sentiment_url = "https://api.pulsebit.com/sentiment"
meta_input = "Clustered by shared themes: roadmap, agricultural, kerala’s, transformation, ker"
meta_params = {
    "text": meta_input,
}
meta_response = requests.post(meta_sentiment_url, json=meta_params)
meta_sentiment_data = meta_response.json()

print(climate_data)
print(meta_sentiment_data)
Enter fullscreen mode Exit fullscreen mode

With this simple script, we’re able to filter sentiment data by language and gain insights into the framing of narratives surrounding climate. This gives you a two-pronged approach: first, you isolate the relevant discussions happening in English, and then you assess the sentiment of the overarching themes.

Now, let’s discuss three specific builds you can implement based on this pattern:

  1. Sentiment Spike Alerts: Set a threshold for momentum spikes. For example, if momentum exceeds +0.3, trigger an alert. Use the geographic origin filter to ensure you're only alerted on English articles, giving you timely insights into emerging trends.

  2. Narrative Analysis Dashboard: Create a dashboard that utilizes the meta-sentiment loop. Aggregate stories like "A roadmap for Kerala's agricultural transformation" and score them using the meta-sentiment endpoint. This can help you visualize how different narratives are perceived, guiding your content strategy around key themes like "climate" and "agriculture."

  3. Comparative Sentiment Analysis: Implement a function that compares the current sentiment around climate with historical data. This can be done by capturing sentiment scores over time and identifying shifts—like the +0.344 spike—allowing you to react quickly to changing public sentiment.

By focusing on signals like momentum, and thematic narratives, we can create a robust framework that not only keeps us updated but also allows us to anticipate market movements.

For more details and to start building, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run the provided code in under 10 minutes.

Top comments (0)