News Sentiment API Documentation
Pre-requisites:
The following are the pre-requisites for using the News Sentiment API:
platformToken
- You can get this token by booking a demo with our team here.- Understanding of using REST APIs and JSON.
- Should able use tools like Postman, Swagger or cURL to make API requests.
Authentication
The News Sentiment API uses the platformToken
for authentication. You can get this token by booking a demo with our team here.
{
"platformToken": "<Your Platform Token>",
"pageNo": 1,
"pageSize": 10
}
Get News Sentiment
This endpoint returns the sentiment score of a news article. The sentiment score is a number between Positive
, Neutral
and Negative
.
curl --location 'https://api.dalalstreet.ai/v1/news-sentiment-data' \
--header 'Content-Type: application/json' \
--data '{
"platformToken":"2211568797426599",
"pageNo": 1,
"pageSize": 10
}''
The following are the different parameters that can be passed to the API:
Parameter | Type | Description | Required |
---|---|---|---|
platformToken | string | It is used to authenticate your account with the platform. | Yes |
stockName | string | The stock name specific to filter the news by the stock name required. | Optional |
country | string | Get the news sentiment data by filtering by country codes such as "us","in" etc. We support upto 50+ countries. For the list of countries supported please read the documentation [here] | Optional |
source | list | Get the news sentiment data by filtering by source name. We support upto 100+ sources. For the list of sources supported please read the documentation [here] | Optional |
The below is a sample response of the API Response Payload
which will be received on request:
{
"pageNo": 1,
"pageSize":3,
"data": [
{
"_id": "647355a9fbc96d29ceee62f2",
"title": "Adani Ports logs 11% rise in January cargo volumes; shares hit fresh 52-week low",
"summary": "Adani Ports share price today: The sentiment around the stock was weak after NSE placed the stock under ban for trade on Friday, February 3, 2023 under the futures and options (F&O) segment.",
"url": "https://www.businesstoday.in/markets/company-stock/story/adani-ports-logs-11-rise-in-january-cargo-volumes-shares-hit-fresh-52-week-low-368768-2023-02-03?utm_source=rssfeed",
"source": "businesstoday",
"image": null,
"country": "in",
"published_at": "2023-02-03T04:27:00+00:00",
"sentiment": "NEGATIVE",
"sentimentScore": {
"Positive": 0.0033303089439868927,
"Negative": 0.5143852829933167,
"Neutral": 0.48198840022087097,
"Mixed": 0.0002959572884719819
}
},
{
"_id": "647355aefbc96d29ceee62f5",
"title": "Sensex, Nifty open higher; Adani Ports, Adani Enterprises rally 4%; Tata Steel drops 3%",
"summary": "BSE Sensex jumped 93.92 points, or 0.16 per cent, at 60,600.82 whereas NSE's Nifty gained 24.2 points, or 0.14 per cent, at 17,788.80 at 9.20 am.",
"url": "https://www.businesstoday.in/markets/market-commentary/story/sensex-nifty-open-higher-adani-ports-adani-enterprises-rally-4-tata-steel-drops-3-369264-2023-02-07?utm_source=rssfeed",
"source": "businesstoday",
"image": null,
"country": "in",
"published_at": "2023-02-07T04:36:38+00:00",
"sentiment": "POSITIVE",
"sentimentScore": {
"Positive": 0.962073802947998,
"Negative": 0.003266965039074421,
"Neutral": 0.033266965039074421,
"Mixed": 0.001051733153872192
}
},
{
"_id": "647355affbc96d29ceee62f6",
"title": "NSE phone tapping | Delhi High Court grants bail to Chitra Ramkrishna in money-laundering case",
"summary": "The former NSE managing director, who was earlier arrested by the CBI in the alleged NSE co-location scam, was arrested in the money-laundering case by the Enforcement Directorate on July 14 last year.",
"url": "https://www.thehindu.com/news/cities/Delhi/nse-phone-tapping-delhi-high-court-grants-bail-to-chitra-ramkrishna-in-money-laundering-case/article66488539.ece",
"source": "The Hindu",
"image": null,
"country": "in",
"published_at": "2023-02-09T05:52:42+00:00",
"sentiment": "NEUTRAL",
"sentimentScore": {
"Positive": 0.005102031398564577,
"Negative": 0.2957565486431122,
"Neutral": 0.6987304091453552,
"Mixed": 0.0004109569126740098
}
}
]
}
The following are the different parameters that are returned in the API response:
Parameter | Type | Description |
---|---|---|
_id | string | The unique identifier of the news article. |
title | string | The title of the news article. |
summary | string | The summary of the news article. |
url | string | The URL of the news article. |
source | string | The source of the news article. |
country | string | The country of the news article. |
published_at | string | The published date of the news article. |
sentiment | string | The sentiment of the news article. The sentiment can be POSITIVE , NEGATIVE or NEUTRAL . |
sentiment_value | number | The sentiment value of the news article. The sentiment value can be 1 for POSITIVE , -1 for NEGATIVE and 0 for NEUTRAL . The sentiment value is a number between 1 , 0 and -1 which represents the sentiment score. |
sentimentScore | object | The sentiment score of the news article. The sentiment score is a number between Positive , Neutral , Negative and Mixed . |
Get News Sentiment By Stock Name
This endpoint returns the sentiment score of a news article. The sentiment score is a number between Positive
, Neutral
and Negative
.
curl --location 'https://b7ooir8kk9.execute-api.us-east-1.amazonaws.com/dev/news-sentiment-data' \
--header 'Content-Type: application/json' \
--data '{
"platformToken":"<Replace with your platform token>",
"stockName": "Apple Inc or AAPL"
}'
Get News Sentiment By Country
This endpoint returns the sentiment score of a news article. The sentiment score is a number between Positive
, Neutral
and Negative
.
curl --location 'https://b7ooir8kk9.execute-api.us-east-1.amazonaws.com/dev/news-sentiment-data' \
--header 'Content-Type: application/json' \
--data '{
"platformToken":"<Replace with your platform token>",
"country": "in"
}'
Get News Sentiment By Source
This endpoint returns the sentiment score of a news article. The sentiment score is a number between Positive
, Neutral
and Negative
.
curl --location 'https://b7ooir8kk9.execute-api.us-east-1.amazonaws.com/dev/news-sentiment-data' \
--header 'Content-Type: application/json' \
--data '{
"platformToken":"2211568797426599",
"sources": ["businesstoday","forextv"]
}'
Please find the list of sources supported in this document here.
Please contact us at support@dalalstreet.ai for any further requests or help required.