Skip to content

Sentiments API

Retrieve AI-powered sentiment analysis scores derived from financial news. Get sentiment scores for any ticker.

GET /v1/sentiments/{market}/{ticker}

Requires API key via token query parameter.

ParameterTypeRequiredDescription
marketstringYesMarket identifier (e.g., S&P 500, NASDAQ)
tickerstringYesStock ticker symbol (e.g., AAPL, MSFT)
ParameterTypeRequiredDescription
tokenstringYesYour API key
dateFromstringNoStart date (YYYY-MM-DD)
dateTostringNoEnd date (YYYY-MM-DD)
Terminal window
# Get sentiment data
curl "https://api.finbrain.tech/v1/sentiments/S%26P%20500/AAPL?token=YOUR_API_KEY"
# With date range
curl "https://api.finbrain.tech/v1/sentiments/S%26P%20500/AAPL?token=YOUR_API_KEY&dateFrom=2024-01-01&dateTo=2024-01-31"
{
"ticker": "AMZN",
"name": "Amazon.com Inc.",
"sentimentAnalysis": {
"2021-12-15": "0.223",
"2021-12-14": "0.037",
"2021-12-13": "-0.038",
"2021-12-10": "0.156",
"2021-12-09": "0.089"
}
}
FieldTypeDescription
tickerstringStock ticker symbol
namestringCompany name
sentimentAnalysisobjectObject with date keys and sentiment score values (as strings)

The sentimentAnalysis field is an object where each key is a date (YYYY-MM-DD) and the value is the sentiment score as a string.

Value RangeInterpretation
”-1” to “1”Sentiment score from bearish to bullish (stored as string)
Score RangeInterpretation
0.5 to 1.0Strong bullish sentiment
0.2 to 0.5Moderate bullish sentiment
-0.2 to 0.2Neutral sentiment
-0.5 to -0.2Moderate bearish sentiment
-1.0 to -0.5Strong bearish sentiment
from finbrain import FinBrainClient
fb = FinBrainClient(api_key="YOUR_API_KEY")
sentiment = fb.sentiments.ticker("S&P 500", "AAPL")
# Get latest sentiment (most recent date)
sentiment_data = sentiment["sentimentAnalysis"]
dates = sorted(sentiment_data.keys(), reverse=True)
latest_date = dates[0]
score = float(sentiment_data[latest_date]) # Convert string to float
if score > 0.5:
print(f"AAPL sentiment is strongly bullish: {score:.3f}")
elif score > 0:
print(f"AAPL sentiment is mildly bullish: {score:.3f}")
elif score > -0.5:
print(f"AAPL sentiment is mildly bearish: {score:.3f}")
else:
print(f"AAPL sentiment is strongly bearish: {score:.3f}")
from finbrain import FinBrainClient
fb = FinBrainClient(api_key="YOUR_API_KEY")
def detect_sentiment_spike(market, ticker):
"""Detect unusual sentiment activity"""
data = fb.sentiments.ticker(market, ticker)
sentiment_data = data["sentimentAnalysis"]
dates = sorted(sentiment_data.keys(), reverse=True)
if len(dates) < 10:
return None
# Calculate baseline from historical data (convert strings to floats)
historical_scores = [float(sentiment_data[d]) for d in dates[1:10]]
avg_score = sum(historical_scores) / len(historical_scores)
# Compare to latest
latest_score = float(sentiment_data[dates[0]])
score_change = latest_score - avg_score
alerts = []
if abs(score_change) > 0.2:
direction = "improved" if score_change > 0 else "declined"
alerts.append(f"Sentiment {direction} significantly ({score_change:+.3f})")
return alerts
alerts = detect_sentiment_spike("S&P 500", "TSLA")
if alerts:
print("Sentiment Alerts:")
for alert in alerts:
print(f" - {alert}")
from finbrain import FinBrainClient
fb = FinBrainClient(api_key="YOUR_API_KEY")
def analyze_sentiment_trend(market, ticker, days=14):
"""Analyze sentiment trend over time"""
data = fb.sentiments.ticker(market, ticker)
sentiment_data = data["sentimentAnalysis"]
dates = sorted(sentiment_data.keys(), reverse=True)
if len(dates) < days:
return None
recent_dates = dates[:days//2]
older_dates = dates[days//2:days]
# Convert string scores to floats for calculation
recent_avg = sum(float(sentiment_data[d]) for d in recent_dates) / len(recent_dates)
older_avg = sum(float(sentiment_data[d]) for d in older_dates) / len(older_dates)
change = recent_avg - older_avg
if change > 0.1:
trend = "improving"
elif change < -0.1:
trend = "deteriorating"
else:
trend = "stable"
return {
"ticker": ticker,
"recent_sentiment": recent_avg,
"older_sentiment": older_avg,
"change": change,
"trend": trend
}
result = analyze_sentiment_trend("S&P 500", "NVDA")
print(f"Sentiment trend: {result['trend']} ({result['change']:+.3f})")
CodeErrorDescription
400Bad RequestInvalid market or ticker
401UnauthorizedInvalid or missing API key
404Not FoundTicker not found
500Internal Server ErrorServer-side error