

Copy and paste your 14-characters personal use script and 27-character secret key somewhere safe. Hit create app and now you are ready to use the OAuth2 authorization to connect to the API and start scraping.

If you have any doubts, refer to Praw documentation. Also make sure you select the “script” option and don’t forget to put in the redirect uri field. Pick a name for your application and add a description for reference. Go to this page and click create app or create another app button at the bottom left. The very first thing you’ll need to do is “Create an App” within Reddit to get the OAuth2 keys to access the API. These two Python packages installed: Praw, to connect to the Reddit API, and Pandas, which we will use to handle, format, and export data.You can also run scripts from the command-line. An IDE (Interactive Development Environment) or a Text Editor: I personally use Jupyter Notebooks for projects like this (and it is already included in the Anaconda pack), but use what you are most comfortable with.When following the script, pay special attention to indentations, which are a vital part of Python. You can also download Python from the project’s website. Python 3.x: I recommend you use the Anaconda distribution for the simplicity with packages.


This is what you will need to get started: In this Python tutorial, I will walk you through how to access Reddit API to download data for your own project. For the story and visualization, we decided to scrape Reddit to better understand the chatter surrounding drugs like modafinil, noopept and piracetam. Many of the substances are also banned by at the Olympics, which is why we were able to pitch and publish the piece at Smithsonian magazine during the 2018 Winter Olympics. Last month, Storybench editor Aleszu Bajak and I decided to explore user data on nootropics, the brain-boosting pills that have become popular for their productivity-enhancing properties.
