Skip to content

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.com

RapidAPI 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:

HeaderValue
X-RapidAPI-KeyYour RapidAPI secret key
X-RapidAPI-Hostcrypto-news51.p.rapidapi.com

Query parameters

ParameterTypeRequiredDescription
intervalstringrequired Time window to analyse. Accepted values:
1h — last 1 hour
6h — last 6 hours
12h — last 12 hours
1d — last 24 hours
7d — 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

FieldTypeDescription
intervalstringThe interval you passed in the request (echoed back for confirmation).
totalintegerTotal number of articles analysed in this time window. This is the denominator for all percentages.
counts.positiveintegerNumber of articles classified as positive.
counts.neutralintegerNumber of articles classified as neutral.
counts.negativeintegerNumber of articles classified as negative.
percentages.positivenumberShare of positive articles as a percentage of total. Rounded to 2 decimal places.
percentages.neutralnumberShare of neutral articles as a percentage of total.
percentages.negativenumberShare 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

ValueWindowBest used for
1hLast 60 minutesBreaking news, immediate market reactions
6hLast 6 hoursShort-term trading signals
12hLast 12 hoursHalf-day overview, morning/evening summaries
1dLast 24 hoursDaily sentiment digest, dashboard widgets
7dLast 7 daysWeekly trend analysis, report generation

Error responses

StatusCodeDescription
400bad_requestinterval parameter is missing or not one of the accepted values
401unauthorizedX-RapidAPI-Key is missing or invalid
403forbiddenYour RapidAPI plan does not include access to this endpoint
429too_many_requestsRapidAPI rate limit exceeded for your plan
500internal_errorServer 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:

PlanPriceRequests / monthRate Limit
Basic$0501,000 / hour
Pro$10100,000100 / min
Ultra$20500,000180 / min
Mega$501,000,000180 / 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>
  )
}

Released under the MIT License.