DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 25.4h Behind: Catching World Sentiment Leads with Pulsebit

Your pipeline just missed a significant anomaly: a 24h momentum spike of +0.134. This spike, driven by English press coverage, indicates a strong surge in sentiment linked to a developing story about the Delhi High Court's involvement in FIFA broadcasting. With two clustered articles under the themes of "world," "FIFA," and "cup," this moment highlights how critical it is to catch these shifts in sentiment while they’re still fresh.

The Problem

If your pipeline doesn’t account for multilingual origins or entity dominance, you might find yourself lagging behind by a staggering 25.4 hours. In this case, English-language articles led the conversation, but if your model only processes data from a single language or misses the significance of emerging entities, you’re likely to miss these critical signals. While the world of sports unfolds rapidly, your model is stuck in yesterday’s news, unable to react in real time to developments that matter.

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

The Code

To catch this momentum spike effectively, we’ll leverage our API. Here’s how you can set it up in Python.

import requests

# Set the parameters for the geographic origin filter
params = {
    "lang": "en",
    "topic": "world",
    "score": +0.306,
    "confidence": 0.85,
    "momentum": +0.134
}

# Make the API call to filter by language
response = requests.get("https://api.pulsebit.com/v1/sentiment", params=params)
data = response.json()

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


# Now, let's get the cluster reason string and score the narrative framing
cluster_reason = "Clustered by shared themes: quiz:, dig, out, your, passport."
sentiment_response = requests.post("https://api.pulsebit.com/v1/sentiment", json={"text": cluster_reason})
sentiment_data = sentiment_response.json()

print(data)
print(sentiment_data)
Enter fullscreen mode Exit fullscreen mode

In the code above, we first query the sentiment data using the lang parameter to filter for English articles related to the topic of “world.” After capturing the relevant data, we take the cluster reason string and run it through our sentiment analysis endpoint to score how effectively that narrative is framing the conversation.

Three Builds Tonight

  1. Geographic Filter Build: Set an endpoint to catch rising sentiment in multiple languages. Use a threshold of +0.1 momentum and filter by lang: "en". This will allow you to quickly identify and react to critical developments in English-language articles.

Geographic detection output for world. India leads with 26 a
Geographic detection output for world. India leads with 26 articles and sentiment +0.15. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Loop: Implement a build that takes the cluster reason strings from articles and runs them through our sentiment analysis. Utilize a threshold of +0.5 for sentiment score and observe how these narratives affect your primary topic, like “world” or “FIFA.”

  2. Forming Theme Analysis: Create a signal that captures phrases like “world” (+0.00), “world’s” (+0.00), and “cup” (+0.00) while contrasting them with mainstream articles containing terms like “quiz:” or “dig.” Set a momentum threshold of +0.134 to highlight the divergence in sentiment, giving you a sharper view of emerging trends.

Get Started

Dive into our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run the above code in under 10 minutes, allowing you to catch these critical sentiment shifts before they become yesterday’s news.

Top comments (0)