Skip to main content

Python 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 python installed on your system. If not, you can download it from here.
  • You should have pip installed on your system. If not, you can download it from here.
  • You should have virtualenv installed on your system. If not, you can download it from here.

Installation

To install the Python SDK, run the following command:

pip install dalalstreet-news-sentiment

To see the package on PyPi, click here.

Usage

To use the Python SDK, you need to import the NewsSentiment class from the dalalstreet_news_sentiment module. You can then create an instance of the class by passing your platformToken as a parameter. You can then call the get_news_sentiment 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.

from dalalstreet-news-sentiment.news_sentiment_data import NewsSentimentDataSDK

platform_token = "your-platform-token" # Replace with your actual platform token (mandatory)

newsSentimentData = NewsSentimentDataSDK()

print(newsSentimentData.get_news_sentiment(platformToken=platform_token)) # See the results of the news sentiment
note

Do note that the get_news_sentiment method takes the country, sources as a parameter. If you do not pass the filter as a parameter, the method will return the sentiment data of the latest articles published.

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