DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 18.0h Behind: Catching Culture Sentiment Leads with Pulsebit

In the last 24 hours, we observed an intriguing momentum spike of +0.667 in the sentiment surrounding the topic of culture. This anomaly not only stands out due to its magnitude but also highlights a significant rise in positive sentiment, clocking in at +0.559. The leading language for this spike was English, with a noteworthy focus on U.S. entities, which contributed a 5% share of voice and a sentiment score of +0.142. This is a clear indication that something important is happening in the conversation around culture, and we need to pay attention.

If your pipeline doesn’t accommodate for multilingual origins or entity dominance, you may have missed this spike by a solid 18 hours. Relying solely on one language or a single source can create a blind spot. In this case, the U.S. entities are leading the conversation, and if you were only tracking in your native language or a specific region, you might not have captured this crucial cultural sentiment shift in time.

English coverage led by 18.0 hours. Et at T+18.0h. Confidenc
English coverage led by 18.0 hours. Et at T+18.0h. Confidence scores: English 0.90, Spanish 0.90, Da 0.90 Source: Pulsebit /sentiment_by_lang.

To catch this spike, we can leverage our API. Below is the Python code that helps us query the relevant data.

import requests

# Define parameters for the API call
params = {
    "topic": "culture",
    "score": +0.559,
    "confidence": 0.90,
    "momentum": +0.667,
    "lang": "en"  # Geographic origin filter
}

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


# API endpoint for fetching sentiment data
response = requests.get("https://api.pulsebit.com/sentiment", params=params)
data = response.json()

print(data)
Enter fullscreen mode Exit fullscreen mode

Next, we want to analyze the narrative framing of our results. We can run the cluster reason string through our sentiment endpoint to score how the narrative is positioned. Here’s how to do that:

# Input the cluster reason string
cluster_reason = "Clustered by shared themes: together, culture, traditions, stories, bring."

# API endpoint for scoring the narrative
sentiment_response = requests.post("https://api.pulsebit.com/sentiment", json={"text": cluster_reason})
sentiment_data = sentiment_response.json()

print(sentiment_data)
Enter fullscreen mode Exit fullscreen mode

The sentiment analysis of the cluster reason will give us deeper insights into how the narrative around culture is being framed and perceived.

Now, let's explore three specific builds you might want to implement based on this pattern.

  1. Geo-Filtered Alert System: Set a threshold for sentiment spikes greater than +0.5 for English-language articles in the U.S. This will notify you when cultural discussions are heating up, allowing you to react in real-time.

  2. Meta-Sentiment Analyzer: Build a module that uses the cluster reason string to evaluate sentiment around specific themes, like "together" and "traditions." When these scores exceed +0.2, it could trigger further investigation into trending topics.

  3. Cultural Gap Tracker: Create a dashboard that visualizes the forming gap between mainstream themes and emerging themes like "culture" and "google." Monitor when the sentiment score for these clusters crosses a certain threshold, indicating a potential shift in public discourse.

If you want to get started, head over to our documentation at pulsebit.lojenterprise.com/docs. You can copy-paste the above code snippets and run them in under 10 minutes to start capturing these insights in your own projects.

Top comments (0)