DEV Community

Pulsebit News Sentiment API
Pulsebit News Sentiment API

Posted on

Your Pipeline Is 20.8h Behind: Catching Markets Sentiment Leads with Pulsebit

Your Pipeline Is 20.8h Behind: Catching Markets Sentiment Leads with Pulsebit

We’ve just identified a notable 24h momentum spike of +0.593 in sentiment around financial markets. As we dive deeper into this anomaly, it’s clear there’s a significant shift occurring, particularly in how entities like Wall Street are being discussed in English-language media. With a sentiment score hovering around zero and negative sentiment from Wall Street, there’s an intriguing story unfolding that may have flown under your radar.

When your pipeline doesn’t account for multilingual origin or entity dominance, you risk being out of sync with the latest sentiment trends. In this case, your model missed this spike by 20.8 hours. That’s critical time lost, especially when Wall Street's share of voice is only 8% with a sentiment score of -0.086. If you’re only processing data in a single language or ignoring the influence of dominant entities, you're likely stuck behind the curve.

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

Here’s how you can catch up. We can utilize our API to filter the data by language and assess sentiment around key narratives. Below is a Python snippet that pulls relevant English-language articles about markets with a specific score and confidence level:

import requests

# Set parameters for the API call
params = {
    "topic": "markets",
    "score": +0.000,
    "confidence": 0.90,
    "momentum": +0.593,
    "lang": "en"
}

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


# API endpoint to fetch articles
response = requests.get('https://api.pulsebit.com/articles', params=params)

# Check for successful response
if response.status_code == 200:
    articles = response.json()
    print(articles)
else:
    print(f"Error fetching data: {response.status_code}")
Enter fullscreen mode Exit fullscreen mode

Next, let’s analyze the narrative framing itself by scoring the sentiment of the clustered themes. This step is crucial for understanding the broader context of sentiment around entities like China and its impact on markets. Here’s how to do that:

# Cluster reason input
cluster_reason = "Clustered by shared themes: chinese, china, too, neither, tariffs."

# API endpoint to analyze sentiment
sentiment_response = requests.post('https://api.pulsebit.com/sentiment', json={"text": cluster_reason})

# Check for successful response
if sentiment_response.status_code == 200:
    sentiment_analysis = sentiment_response.json()
    print(sentiment_analysis)
else:
    print(f"Error fetching sentiment analysis: {sentiment_response.status_code}")
Enter fullscreen mode Exit fullscreen mode

Now that we have our data and sentiment analysis, here are three specific builds you can implement using this pattern:

  1. Geo Filter for Market Trends: Create a daily report endpoint that pulls sentiment data for the "markets" topic filtered for English-language articles. Use the following parameters: {"lang": "en", "topic": "markets"}. This helps you stay updated on regional sentiment shifts.

  2. Meta-Sentiment Narrative Score: Build a function that loops through the cluster reasons for various topics and scores their sentiment. This can be done via the POST request to /sentiment for any narrative string. For example, "Clustered by shared themes: markets, oil, trade."

  3. Threshold Alerts for Forming Themes: Set up alerts for themes that are forming, specifically for "markets(+0.00), oil(+0.00), trade(+0.00)" contrasted against mainstream narratives like "chinese, china, too." Use a threshold score to trigger notifications when sentiment shifts dramatically.

If you're ready to get started, check out our documentation. You can copy-paste the provided code snippets and run them in under 10 minutes to start capturing these crucial insights. Don't let your pipeline lag behind—stay ahead with real-time sentiment data!

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

Top comments (0)