DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 29.2h Behind: Catching Business Sentiment Leads with Pulsebit

Your Pipeline Is 29.2h Behind: Catching Business Sentiment Leads with Pulsebit

We recently stumbled upon a fascinating anomaly: a 24h momentum spike of +0.750 in business sentiment. This sudden surge, particularly led by French articles, indicates a notable shift in how businesses are being discussed in the media. The leading language for this spike was French, with a significant cluster story revolving around the potential for ministers to allocate billions raised from business rates to England’s regions. This single data point could change how you perceive your data pipelines.

The Problem

If your pipeline doesn’t account for multilingual origins or dominant entities, you could be missing critical insights — like this one, which is lagging by a staggering 29.2 hours. This gap means your model has not processed the leading French sentiment, which is pivotal in understanding the evolving narrative around business in England. By overlooking multilingual coverage, you risk falling behind significant trends that could impact your analyses and decisions.

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

The Code

To help you catch these insights in real-time, here’s how we can set up a Python script using our API. We’ll first filter for the French language to capture relevant articles.

import requests

# Define parameters for the API call
params = {
    'topic': 'business',
    'lang': 'fr',
    'momentum': 0.750,
}

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


# Make API call to get sentiment data
response = requests.get('https://api.pulsebit.com/sentiment', params=params)
data = response.json()

# Output the fetched data
print(data)
Enter fullscreen mode Exit fullscreen mode

Now, let’s run the meta-sentiment analysis on the narrative framing itself. We’ll take the cluster reason string and score it using the POST endpoint:

# Define the narrative string
narrative = "Clustered by shared themes: tax, give, billions, raised, business."

# Make POST request for sentiment analysis
sentiment_response = requests.post('https://api.pulsebit.com/sentiment', json={"text": narrative})
sentiment_data = sentiment_response.json()

# Output the sentiment score
print(sentiment_data)
Enter fullscreen mode Exit fullscreen mode

By running this code, you’ll be able to pull the relevant sentiment data based on the dominant themes emerging in your articles.

Three Builds Tonight

Here are three specific things to build based on this pattern:

  1. Geo Filtered Business Sentiment Alert: Set a threshold that triggers an alert when business sentiment in French articles spikes above +0.750. This ensures you stay updated on emerging trends. Use the language filter directly, like we did in the first API call.

  2. Meta-Sentiment Dashboard: Create a dashboard that visualizes the meta-sentiment of clustered narratives. Feed the output from the POST request into a visualization tool to observe how narratives around business are evolving over time.

  3. Forming Gap Analysis: Build a function that continuously monitors the forming gap between emerging themes (like “business”, “new”, “google”) against mainstream narratives (like “tax”, “give”, “billions”). Set specific thresholds for alerting when the gap reaches critical levels.

Get Started

You can quickly implement these insights by checking out our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste and run the provided code in under 10 minutes. Start catching those momentum spikes before they become yesterday's news!

Geographic detection output for business. India leads with 5
Geographic detection output for business. India leads with 5 articles and sentiment +0.30. Source: Pulsebit /news_recent geographic fields.

Top comments (0)