How-To Build a Reddit Bot
No need to manually troll others, let your bot do it for you
r/
Reddit is a network of communities where people can dive into their interests, hobbies, and passions. There’s a community for whatever you’re interested in, such as social news aggregation, web content rating, and discussion website. Registered members submit content to the site, such as links, text posts, images, and videos, which are then voted up or down by other members.
Prerequisite
- Python basic knowledge and Python install is required
- Reddit Account
Reddit bot
Unlike many social platforms, Reddit is actually bot-friendly. It even provides an API to help developers create bots. However, keep in mind Reddit bot rules, especially if you are going to use the Reddit API for commercial purposes. Otherwise, you may be at risk of being banned. Every subreddit also has some regulations, and your bot should be in line with them.
Reddit API
Reddit API is actually easy to use, based on REST and JSON, not requiring any hard setup to get it up working. The important thing is to follow their rules, check them out here. In addition, it is advisable to be familiar with the way Reddit works to be able to determine what functions your bot has to fulfill. For more information click here
Create The Bot
— Steps
- name: My Example App
- App type: Choose the script option
- description: You can leave this blank
- about url: You can leave this blank
- redirect url: http://www.example.com/unused/redirect/uri (We won’t be using this as a redirect)
Note: These examples will only work for script type apps, which will ONLY have access to accounts registered as "developers" of the app and require the application to know the user's password. Read more about app types.
Go to https://ssl.reddit.com/prefs/apps . There you will see this panel

Create an application by typing the name of your bot, selecting the option ‘script,’ providing some description, writing any random link in the box ‘redirect URL,’ and clicking the button ‘create an app.’ Then you will get ‘personal use script’ and ‘secret’. You will use them while writing the script for your bot. Next, you need to download Python Reddit API Wrapper (PRAW) that allows you to log in to the Reddit API and interact with the backend of the website. To install PRAW;
ubuntu@Destktop: pip install prawDRAW Configuration Files (draw.ini)
PRAW comes with a praw.ini file in the package directory, and looks for user defined praw.ini files in a few other locations:
- In the current working directory at the time
Reddit is initialized. - In the launching user’s config directory. This directory, if available, is detected in order as one of the following:
- In the directory specified by the
XDG_CONFIG_HOMEenvironment variable on operating systems that define such an environment variable (some modern Linux distributions). - In the directory specified by
$HOME/.configif theHOMEenvironment variable is defined (Linux and Mac OS systems). - In the directory specified by the
APPDATAenvironment variable (Windows).
praw.ini uses the INI file format, which can contain multiple groups of settings separated into sections. PRAW refers to each section as a site. The default site, DEFAULT, is provided in the package’s praw.ini file. This site defines the default settings for interaction with Reddit. The contents of the package’s praw.ini file are:
[DEFAULT]
# A boolean to indicate whether or not to check for package updates.
check_for_updates=True
# Object to kind mappings
comment_kind=t1
message_kind=t4
redditor_kind=t2
submission_kind=t3
subreddit_kind=t5
trophy_kind=t6
# The URL prefix for OAuth-related requests.
oauth_url=https://oauth.reddit.com
# The amount of seconds of ratelimit to sleep for upon encountering a specific type of 429 error.
ratelimit_seconds=5
# The URL prefix for regular requests.
reddit_url=https://www.reddit.com
# The URL prefix for short URLs.
short_url=https://redd.it
# The timeout for requests to Reddit in number of seconds
timeout=16Avoid modifying the package’s praw.ini file. Prefer instead to override its values in your own praw.ini file. You can even override settings of the DEFAULT site in user defined praw.ini files.
Example Bot Script
