Skip to main content

NPM SDK Documentation for News Sentiment

Pre-Conditions:

  • You have a valid platformToken which you can get by booking a demo our team here.
  • You should have node installed on your system. If not, you can download it from here.
  • You should have npm installed on your system. If not, you can download it from here.

Installation

To install the NPM SDK, run the following command:

npm i news-sentiment

To see the package on NPM, click here.

Usage

To use the NPM SDK, you need to import the NewsSentiment class from the news-sentiment module. You can then create an instance of the class by passing your platformToken as a parameter. You can then call the getNewsSentiment method on the instance of the class by passing the news_url as a parameter. The method returns the sentiment score of the news article as a string.

const newsSentimentDataSDK = require('news-sentiment');

const platformToken = "1234567890123456"; // Replace with your platform token (required)
const stockName = "AAPL"; // Replace with the name of the stock (optional)
const newsSources = ["CNN", "BBC"]; // Replace with the name of the news sources (optional)

newsSentimentDataSDK.getNewsSentimentData(platformToken, stockName, newsSources)
.then((data) => {
console.log(data);
})
.catch((error) => {
console.log(error);
});
note

Do note that the getNewsSentimentData method takes the stockName, newsSources as a parameter. If you do not pass the stockName, newsSources as a parameter, the method will return the sentiment data of the latest articles published.

For any additional information, please contact us at support@dalalstreet.ai.