Appearance
Crypto Sentiment
The Crypto Sentiment endpoint analyzes all crypto news articles published within a chosen time window and returns an aggregated sentiment breakdown — how many articles are positive, neutral, or negative, together with percentage shares.
Use this to:
- Display a live "market mood" widget in your app
- Build sentiment-driven trading signals or alerts
- Track how news sentiment shifts over time (hourly vs. daily)
Base URL
https://crypto-news51.p.rapidapi.comRapidAPI key required
This endpoint is served through RapidAPI. You must include your RapidAPI host and key headers on every request — see Authentication below.
Get sentiment
GET/api/v1/crypto/sentiment
Returns the sentiment distribution of crypto news articles published within the specified interval. All articles in the window are scored independently; the counts and percentages in the response reflect the full set.
Authentication
Every request must include two RapidAPI headers:
| Header | Value |
|---|---|
X-RapidAPI-Key | Your RapidAPI secret key |
X-RapidAPI-Host | crypto-news51.p.rapidapi.com |
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| interval | string | required | Time window to analyse. Accepted values:1h — last 1 hour6h — last 6 hours12h — last 12 hours1d — last 24 hours7d — last 7 days |
Choosing an interval
Short intervals (1h, 6h) reflect breaking news and immediate market reactions. Longer intervals (1d, 7d) smooth out short-term noise and are better for trend analysis or weekly reports.
Example requests
bash
curl "https://crypto-news51.p.rapidapi.com/api/v1/crypto/sentiment?interval=1h" \
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
-H "X-RapidAPI-Host: crypto-news51.p.rapidapi.com"javascript
const response = await fetch(
'https://crypto-news51.p.rapidapi.com/api/v1/crypto/sentiment?interval=1h',
{
headers: {
'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
'X-RapidAPI-Host': 'crypto-news51.p.rapidapi.com',
},
}
)
const data = await response.json()
console.log(data)
// {
// interval: '1h',
// total: 69,
// counts: { positive: 19, neutral: 35, negative: 15 },
// percentages: { positive: 27.54, neutral: 50.72, negative: 21.74 }
// }javascript
import axios from 'axios'
const { data } = await axios.get(
'https://crypto-news51.p.rapidapi.com/api/v1/crypto/sentiment',
{
params: { interval: '1h' },
headers: {
'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
'X-RapidAPI-Host': 'crypto-news51.p.rapidapi.com',
},
}
)
const { counts, percentages, total } = data
console.log(`Analysed ${total} articles`)
console.log(`Positive: ${percentages.positive}%`)
console.log(`Neutral: ${percentages.neutral}%`)
console.log(`Negative: ${percentages.negative}%`)python
import os
import requests
response = requests.get(
"https://crypto-news51.p.rapidapi.com/api/v1/crypto/sentiment",
params={"interval": "1h"},
headers={
"X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"],
"X-RapidAPI-Host": "crypto-news51.p.rapidapi.com",
},
)
response.raise_for_status()
data = response.json()
print(f"Analysed {data['total']} articles over {data['interval']}")
print(f"Positive: {data['percentages']['positive']}%")
print(f"Neutral: {data['percentages']['neutral']}%")
print(f"Negative: {data['percentages']['negative']}%")python
import os
import requests
INTERVALS = ["1h", "6h", "12h", "1d", "7d"]
session = requests.Session()
session.headers.update({
"X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"],
"X-RapidAPI-Host": "crypto-news51.p.rapidapi.com",
})
for interval in INTERVALS:
r = session.get(
"https://crypto-news51.p.rapidapi.com/api/v1/crypto/sentiment",
params={"interval": interval},
)
d = r.json()
label = f"{interval:>3}"
pos = d["percentages"]["positive"]
neu = d["percentages"]["neutral"]
neg = d["percentages"]["negative"]
print(f"{label} 📰 {d['total']:>4} articles "
f"🟢 {pos:5.1f}% ⚪ {neu:5.1f}% 🔴 {neg:5.1f}%")Response
json
{
"interval": "1h",
"total": 69,
"counts": {
"positive": 19,
"neutral": 35,
"negative": 15
},
"percentages": {
"positive": 27.54,
"neutral": 50.72,
"negative": 21.74
}
}Response fields
| Field | Type | Description |
|---|---|---|
| interval | string | The interval you passed in the request (echoed back for confirmation). |
| total | integer | Total number of articles analysed in this time window. This is the denominator for all percentages. |
| counts.positive | integer | Number of articles classified as positive. |
| counts.neutral | integer | Number of articles classified as neutral. |
| counts.negative | integer | Number of articles classified as negative. |
| percentages.positive | number | Share of positive articles as a percentage of total. Rounded to 2 decimal places. |
| percentages.neutral | number | Share of neutral articles as a percentage of total. |
| percentages.negative | number | Share of negative articles as a percentage of total. |
Percentages always sum to ~100%
positive + neutral + negative percentages will sum to 100% (minor floating-point rounding may cause ±0.01% variance). Always use counts.* for exact arithmetic.
Interval reference
| Value | Window | Best used for |
|---|---|---|
1h | Last 60 minutes | Breaking news, immediate market reactions |
6h | Last 6 hours | Short-term trading signals |
12h | Last 12 hours | Half-day overview, morning/evening summaries |
1d | Last 24 hours | Daily sentiment digest, dashboard widgets |
7d | Last 7 days | Weekly trend analysis, report generation |
Error responses
| Status | Code | Description |
|---|---|---|
| 400 | bad_request | interval parameter is missing or not one of the accepted values |
| 401 | unauthorized | X-RapidAPI-Key is missing or invalid |
| 403 | forbidden | Your RapidAPI plan does not include access to this endpoint |
| 429 | too_many_requests | RapidAPI rate limit exceeded for your plan |
| 500 | internal_error | Server error — safe to retry after a short delay |
Example 400 response:
json
{
"detail":"Invalid interval format. Use values like '1h', '6h', '12h', '1d', '7d'. 'h' = hours, 'd' = days."
}Rate limits
Limits are enforced by RapidAPI and depend on your subscription plan:
| Plan | Price | Requests / month | Rate Limit |
|---|---|---|---|
| Basic | $0 | 50 | 1,000 / hour |
| Pro | $10 | 100,000 | 100 / min |
| Ultra | $20 | 500,000 | 180 / min |
| Mega | $50 | 1,000,000 | 180 / min |
Check your current usage in the RapidAPI developer dashboard.
Usage example — sentiment gauge widget
A minimal React component that fetches and displays a live sentiment bar:
jsx
import { useEffect, useState } from 'react'
export function SentimentGauge({ interval = '1h' }) {
const [data, setData] = useState(null)
useEffect(() => {
fetch(
`https://crypto-news51.p.rapidapi.com/api/v1/crypto/sentiment?interval=${interval}`,
{
headers: {
'X-RapidAPI-Key': import.meta.env.VITE_RAPIDAPI_KEY,
'X-RapidAPI-Host': 'crypto-news51.p.rapidapi.com',
},
}
)
.then((r) => r.json())
.then(setData)
}, [interval])
if (!data) return <p>Loading…</p>
const { percentages, counts, total } = data
return (
<div className="sentiment-gauge">
<p>{total} articles analysed ({interval})</p>
{/* Stacked bar */}
<div style={{ display: 'flex', height: 12, borderRadius: 6, overflow: 'hidden' }}>
<div style={{ width: `${percentages.positive}%`, background: '#10b981' }} />
<div style={{ width: `${percentages.neutral}%`, background: '#6b7280' }} />
<div style={{ width: `${percentages.negative}%`, background: '#ef4444' }} />
</div>
<ul>
<li>🟢 Positive: {counts.positive} ({percentages.positive}%)</li>
<li>⚪ Neutral: {counts.neutral} ({percentages.neutral}%)</li>
<li>🔴 Negative: {counts.negative} ({percentages.negative}%)</li>
</ul>
</div>
)
}