DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

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

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

We recently discovered a significant anomaly: a 24-hour momentum spike of +0.098. This spike is driven by a narrative emerging from the Spanish press surrounding Disney's new CEO and a €2.18 billion overhaul of theme parks, specifically highlighted in a single article. The leading language is Spanish, with a 25.5-hour lead, indicating that any model not accounting for multilingual origin or entity dominance could completely miss the sentiment shift this story represents.

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

If your model isn't designed to handle multiple languages or recognize dominant entities, you likely missed this spike by 25.5 hours. This delay can be detrimental, especially in fast-paced environments where timely insights are crucial. The leading sentiment stems from the Spanish press, emphasizing the need for a robust multilingual processing capability to stay ahead of the curve.

To catch these insights, we can leverage our API effectively. Here's how you can build a simple Python script to identify these spikes:

import requests

# Geographic origin filter: Spanish language
query = 'world'
lang = 'sp'
base_url = 'https://api.pulsebit.com/v1/sentiment'
response = requests.get(f"{base_url}/search", params={
    "topic": query,
    "lang": lang
})

![Geographic detection output for world. India leads with 24 a](https://pub-c3309ec893c24fb9ae292f229e1688a6.r2.dev/figures/g3_geo_output_1774821269851.png)
*Geographic detection output for world. India leads with 24 articles and sentiment +0.10. Source: Pulsebit /news_recent geographic fields.*


data = response.json()
momentum = data['momentum_24h']
score = data['sentiment_score']
confidence = data['confidence']

print(f"Momentum: {momentum}, Score: {score}, Confidence: {confidence}")

# Meta-sentiment moment: scoring the narrative framing
cluster_reason = "Clustered by shared themes: new, ceo, caps, billion, euro."
sentiment_response = requests.post(f"{base_url}/sentiment", json={
    "text": cluster_reason
})

sentiment_data = sentiment_response.json()
print("Meta-Sentiment Score:", sentiment_data['score'])
Enter fullscreen mode Exit fullscreen mode

In this script, we first filter by Spanish language to capture the relevant momentum around the topic "world." The API call retrieves sentiment data, including the critical spike in momentum. We then run the narrative framing through our sentiment analysis endpoint to score the underlying themes driving this spike.

Left: Python GET /news_semantic call for 'world'. Right: ret
Left: Python GET /news_semantic call for 'world'. Right: returned JSON response structure (clusters: 3). Source: Pulsebit /news_semantic.

Here are three specific builds you can implement tonight based on this pattern:

  1. Geo-filtered Alerts: Set up a trigger for any topics that show a momentum spike greater than +0.05 in Spanish language articles. This can serve as an early warning system for emerging trends.

  2. Meta-Sentiment Analysis: Create a dashboard that visualizes the scores of narratives clustered by themes such as "new," "CEO," and "billion." Utilize the score from the meta-sentiment loop to assess which narratives are gaining traction.

  3. Trend Comparison Tool: Build an endpoint that compares the sentiment scores of forming topics like "world" and "Google" against mainstream ones like "new," "CEO," and "caps." This can help you identify which narratives are diverging from established sentiment trends.

If you're ready to get started, check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste the code above and run it in under 10 minutes to start capturing these crucial sentiment insights.

Top comments (0)