Skip to content
DDataNest

Data & Intelligence · 4 min read

How to use the News Sentiment API in Python & JavaScript

Turning messy public data into something usable is most of the work. The News Sentiment API hands you clean JSON instead.

By DataNest · Published May 2026

What the News Sentiment API does

AI sentiment scoring over real-time news: per-topic mood, trending topics, headline-level sentiment, and custom-text analysis. Responses are JSON, the API runs behind the RapidAPI gateway for auth and rate limiting, and there's a free tier for prototyping.

When to use it

trading signals
brand monitoring
PR tracking

The example request

GET https://news-sentiment-by-datanest.p.rapidapi.com/sentiment/sports?topic=sports

Example JSON response

An illustrative response body — run the live demo for the real thing.

{
  "topic": "technology",
  "overall": {
    "label": "positive",
    "score": 0.31
  },
  "articles": [
    {
      "headline": "Chipmaker beats Q2 expectations",
      "source": "Reuters",
      "publishedAt": "2026-05-17T08:12:00Z",
      "sentiment": "positive",
      "score": 0.64
    }
  ]
}

Common parameters

Every request also needs your RapidAPI auth headers.

ParameterInRequiredExample
x-rapidapi-keyheaderYesYOUR_RAPIDAPI_KEY
x-rapidapi-hostheaderYesnews-sentiment-by-datanest.p.rapidapi.com

Step by step

1. Subscribe and get your key

Open the News Sentiment API on RapidAPI, subscribe to the free BASIC plan, and copy your X-RapidAPI-Key.

2. Call the endpoint

The example call for this API is shown above. The quick-start snippets below send exactly that request in cURL, Python and Node so you get a real response on the first try.

3. Try it without code first

The News Sentiment page has a live "Try it" panel — change the input, run it, and inspect the real JSON before you integrate.

4. Integrate and cache

Call it from your backend and cache responses where it makes sense. Most responses change slowly, so even a daily cache keeps you well within the free tier.

Quick-start code

curl --request GET \
  --url 'https://news-sentiment-by-datanest.p.rapidapi.com/sentiment/technology' \
  --header 'x-rapidapi-host: news-sentiment-by-datanest.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY'

What you can build

Trading signal

Exit positions when sentiment for a held ticker turns sharply negative.

Brand monitor

Track how media tone about a company shifts week over week.

PR dashboard

Quantify campaign impact with a daily sentiment score for a client.

Wrapping up

If your project needs trading signals, the News Sentiment API removes the part nobody enjoys building. It's one of 23 in the DataNest collection — grab a free key and make your first call.

News Sentiment updates

New News Sentiment guides and endpoint updates, occasionally.