DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 20.8h Behind: Catching Finance Sentiment Leads with Pulsebit

Your Pipeline Is 20.8h Behind: Catching Finance Sentiment Leads with Pulsebit

We just uncovered a fascinating anomaly in our data: a 24h momentum spike of +0.318 in the finance sentiment. This spike indicates a significant uptick in sentiment, particularly led by English press coverage. Notably, the leading language is English, with a lag of only 0.0 hours compared to the dominant entity at 20.8 hours. This is a clear signal that something important is brewing in the finance sector, and it’s essential we stay ahead of these changes.

The issue at hand is that traditional pipelines often miss out on critical sentiment shifts, especially when they fail to account for multilingual data or the dominance of certain entities. Your model missed this spike by an alarming 20.8 hours. If you’re only analyzing a single language or failing to integrate data from diverse sources, you're likely to overlook nuanced sentiment changes—like the one we just detected around the finance minister carrying a rosary and making a sign of the cross.

English coverage led by 20.8 hours. Da at T+20.8h. Confidenc
English coverage led by 20.8 hours. Da at T+20.8h. 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. Below is a Python snippet that demonstrates how to fetch the relevant data, specifically focusing on the English language and scoring the narrative framing.

import requests

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


# Constants
topic = 'finance'
score = +0.057
confidence = 0.85
momentum = +0.318

# Geographic origin filter: querying by language
url = "https://api.pulsebit.com/sentiment"
params = {
    "topic": topic,
    "lang": "en",
    "score": score,
    "confidence": confidence,
    "momentum": momentum
}

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


response = requests.get(url, params=params)
data = response.json()

# Meta-sentiment moment: run the cluster reason string
cluster_reason = "Clustered by shared themes: finance, minister, rosary, sign, cross."
meta_sentiment_response = requests.post(f"{url}/sentiment", json={"text": cluster_reason})
meta_sentiment = meta_sentiment_response.json()

print("Data Response:", data)
print("Meta Sentiment Response:", meta_sentiment)
Enter fullscreen mode Exit fullscreen mode

This code effectively filters for sentiment related to the finance sector while focusing on English-language articles. It also pulls in relevant data and runs the narrative framing through our sentiment scoring endpoint. By doing this, we can gauge how the media is framing the sentiment around these clustered themes.

Now, let’s explore three specific builds that you can create using this pattern:

  1. Geo-Filtered Sentiment Score: Build a service that aggregates sentiment scores specifically for finance-related articles in the English language. Set a threshold score of +0.05 to trigger alerts when significant spikes occur. This can help you react promptly to emerging themes.

  2. Meta-Sentiment Analysis Loop: Utilize the meta-sentiment loop to evaluate how narratives frame certain topics. For instance, when you detect a spike in sentiment around the themes of "finance" and "minister," use our endpoint to analyze how this framing impacts public perception over time.

  3. Thematic Comparison Dashboard: Create a dashboard that compares forming themes (like finance, minister, tamil) against mainstream narratives (finance, minister, rosary). This comparison can help identify emerging stories and shifts in public sentiment, allowing you to stay ahead of the curve.

You can get started today by heading over to our documentation at pulsebit.lojenterprise.com/docs. With this setup, you can copy-paste and run the provided code in under 10 minutes, getting you up to speed with real-time sentiment analysis and anomaly detection.

Top comments (0)