User:PokestarFan/Ultimate PRAW Guide/Setting Up PRAW

From Wikibooks, open books for an open world
Jump to navigation Jump to search

PRAW setup takes a bit of time.

Requirements[edit | edit source]

  • Python 3 (This guide uses Python 3 and it is recommended as it is the latest version)
  • A Reddit Account
  • Free Disk Space
  • An Internet Connection

Step 1: Download PRAW[edit | edit source]

Open up your terminal, and run the following command:

pip install praw

Wait for it to finish.

Step 2: Creating an auth code[edit | edit source]

Go to the apps section of your reddit preferences.

In there, you should see the "Create an app" button. If you do not, scroll down until you see it.

Click on the button, and do the following.

  1. In the name box, type in anything.
  2. Select the "script" option.
  3. Type in http://127.0.0.1:65010/authorize_callback as the redirect url.
  4. Click create app

You should now have a box with various different text.

Step 3: Login to Reddit[edit | edit source]

Open up the python interpreter or a text editor, and type in the following code:

import praw

u = ''
p = ''
c_id = ''
c_sec = ''
reddit = praw.Reddit(username=u, password=p, client_id=c_id, client_secret=c_sec, user_agent='Praw Tutorial')

Make sure to put in text in the following variables. In u = '', replace '' with 'username', where username is your Reddit username. Do the same for the password (p), client_id (c_id), and the client_secret (c_sec).

The client id can be found below the text "personal use script" in the box from step 2. The client secret is the text after the word "secret".