How to Scrape Social Sentiment From r/wallstreetbets Using Python
This guide will walk you through step by step how you can set up your own social sentiment scraper to analyze the top posts on any subreddit, and find out if a certain stock (or any keyword term) is viewed as bullish, bearish, or neutral. You will learn how to do this manually using a Python — Reddit wrapper module, or with the Styvio API to simplify the process.
Option 1: Install Python Reddit API Wrapper
Pip install PRAW. This is the official Python wrapper for the Reddit API. You can read more about this Python module and the setup process through the official documentation here.
Once you have installed the module, initialize the API with your Reddit client ID, client secret, and user agent. Then, you can call the API to return the top posts from your desired subreddit. From there, use a natural language processor to process the results.
Option 2: Use the Styvio API
Option 2 involves using the Styvio API, which completes this process under the hood and hosts the results on a json API. To access this data directly for a given stock, go to Styvio.com/apiKey and copy your key. Then, make a call to the public sentiment API, Styvio.com/apiV2/sentiment/AAPL/secret. Place your copied secret key into the end of the API endpoint, and you should see the sentiment data for 5 different sources, for your entered stock.
There are two main ways you can access Reddit sentiment data for your app, project, or for personal use. You can access Reddit posts via the Reddit API (or a wrapper), or use the hosted Styvio API that does this under the hood. This post was meant to give an overview of those two options and how you can choose which one fits your use case better.