reddit

The Setup

Before we can dive into using Reddit's API, we must create an OAuth2 authorization token. This token will allow requests to be made to Reddit's API.

NOTE: Reddit has created a Quick Start Example. That example can be found here. We will not use the Quick Start Example in this guide

Step 1: Application id and secret

Follow this link to login or create a new account. Once logged in you will see some variation of the image below.

login

Click the button that asks, "Are you a developer? create an app," or if you've created an app before, create another app...

login1

At the create application screen you will need to enter a name, app type, and a redirect url.

login2

Once you successfully enter the name, app type, and redirect url, you will find a developed applications screen with a secret token. This token should not be given to anyone.

login3

Step 2: API Wrappers

A wrapper function is a subroutine in a software library of a computer program whose main purpose is to call a second subroutine or a system call with little or no additional computation. The Reddit API recommends using one of three API wrappers to use with JavaScript: snoowrap, raw.js, and snoocore. We will be using snoowrap in this tutorial. Documentation for Snoowrap can be found here.

The next page will walk you through how to use snoowrap with the Reddit API.

Step 2a: install required npm(s) for the node wrapper

Depending on which wrapper you choose, you may need to install additional npm(s). In addition, depending on your permissions, you may have to adjust directories on your computer. Changing directories is outside the scope of this project.

For the snoowrap wrapper you must install the following npm(s) "npm install snoowrap -- save," and "npm install -g redit-oaauth-helper." It is recommended that you install these two items first, but it can be done either way.

The next page will walk you through how to use snoowrap with the Reddit API.

After installing "npm install -g redit-oaauth-helper" you must run "reddit-oauth-helper" in the terminal. Running this helper function triggers the app's redirect you will need to enter into Reddit. You can always go back and add the redirect into the app. Follow the directions provided in the terminal

If completed correctly, you will see a variation of the below output

login6

This information will be needed for getting and sending information which will be covered on the next page.