DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 7.2h Behind: Catching Investing Sentiment Leads with Pulsebit

Your pipeline just missed a significant anomaly: a 24h momentum spike of +0.301. This spike indicates a noticeable shift in sentiment surrounding investing, particularly tied to the recent US-Iran meeting at the UN. As developers working in this space, it’s crucial to stay ahead of these trends, especially when they’re driven by specific entities like Investing.com, which currently holds a 23% share of voice in this topic cluster.

What does this mean for your sentiment analysis pipeline? If your model doesn’t accommodate multilingual origins or recognize entity dominance, you’re likely behind by 7.2 hours on the most pertinent developments. The leading language in this spike is English, but without a system that can track global sentiment effectively, you risk missing out on critical insights. In this case, your model might not have captured the nuances of this momentum shift and could be missing vital information that informs the investing landscape.

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

To catch this momentum spike in real-time, we can leverage our API in Python. Here’s a code snippet that queries for articles related to the topic “investing” with a sentiment score of +0.750 and a confidence of 0.80 while filtering for English language sources:

import requests

# Set parameters for the API call
topic = 'investing'
score = +0.750
confidence = 0.80
momentum = +0.301
lang = 'en'

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


# API call to get relevant articles
response = requests.get(
    'https://api.pulsebit.com/articles',
    params={
        'topic': topic,
        'score': score,
        'confidence': confidence,
        'lang': lang
    }
)

# Check the response
if response.status_code == 200:
    articles = response.json()
    print("Fetched articles:", articles)
else:
    print("Error fetching articles:", response.status_code)
Enter fullscreen mode Exit fullscreen mode

Next, we need to run the narrative framing of the cluster through our sentiment scoring endpoint. This allows us to assess how the narrative itself could influence market behavior. Here's how we can achieve this:

# Meta-sentiment moment: scoring the narrative
cluster_reason = "Clustered by shared themes: investinglive, americas, market, news, wrap:."
sentiment_response = requests.post(
    'https://api.pulsebit.com/sentiment',
    json={
        'text': cluster_reason
    }
)

# Output the sentiment score for the narrative
if sentiment_response.status_code == 200:
    narrative_sentiment = sentiment_response.json()
    print("Narrative sentiment score:", narrative_sentiment)
else:
    print("Error scoring narrative sentiment:", sentiment_response.status_code)
Enter fullscreen mode Exit fullscreen mode

Now, for three specific things you can build with this pattern:

  1. Geo-Focused Alerts: Create an alerting system that uses the geographic origin filter to notify you when sentiment spikes in English-speaking regions. Set a threshold where the momentum exceeds +0.250. This way, you can react swiftly to changes in sentiment that matter most to your audience.

Geographic detection output for investing. Hong Kong leads w
Geographic detection output for investing. Hong Kong leads with 2 articles and sentiment +0.35. Source: Pulsebit /news_recent geographic fields.

  1. Meta-Sentiment Insights: Build a dashboard that visualizes meta-sentiment scores from narratives like "Clustered by shared themes: investinglive, americas, market." Use this to provide context behind spikes, helping you understand how framing can sway sentiment.

  2. Multi-Entity Comparison: Develop a comparative analysis tool that assesses sentiment across different entities (like Investing.com vs. Google) with a focus on forming themes. Set thresholds where sentiment differences exceed 0.050 to highlight which narratives are gaining more traction.

By focusing on these builds, you can ensure your insights remain timely and data-driven.

Ready to get started? Check out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run this in under 10 minutes.

Top comments (0)