How to Build a Reddit Bot in 2025: The Complete Python Guide (With API Changes)

I built my first Reddit bot three years ago.
It was a simple thing - automatically replied to posts in a niche subreddit with helpful information. Took maybe 2 hours to code. Ran for 6 months without issues. Got me genuinely useful karma and even helped some people.
Then Reddit changed everything.
The 2023 API pricing update threw a massive wrench into the bot ecosystem. Suddenly, what was free became expensive. Many bots that had been running for years just... stopped. The indie developers maintaining them couldn't justify the costs.
But here's the thing: building Reddit bots in 2025 is still possible. You just need to understand the new rules. And honestly? For personal projects and small-scale automation, it's still free.
Let me show you exactly how to do it.
Understanding Reddit's API in 2025
Before we write any code, let's talk about what changed and what still works.
The Free Tier Still Exists
Reddit's API changes killed third-party apps that needed millions of API calls. But for personal bots making 100 requests per minute or less? Still free.
The limits:
- 100 requests per minute for OAuth apps
- 10 requests per minute for non-OAuth (don't do this)
- No limit on read vs write operations within that cap
For most bot projects, that's plenty. You're not building a commercial product - you're automating something for yourself.
What You Can Still Do for Free
- Monitor subreddits for new posts
- Reply to comments that match certain keywords
- Send DMs (within Reddit's rate limits)
- Download post data for research
- Cross-post between subreddits you moderate
- Track user activity (your own or with consent)
What Requires Paid Access
- Commercial applications with high volume
- Apps serving multiple users at scale
- Anything resembling a third-party Reddit client
- Real-time streaming at high frequency
For this guide, we're staying firmly in the free tier.
Step 1: Set Up Your Reddit Developer Account
First, you need API credentials. Here's how:
- Create a dedicated Reddit account for your bot
Don't use your main account. If something goes wrong, you don't want your primary account banned.
- Go to Reddit's app preferences
Navigate to reddit.com/prefs/apps while logged into your bot account.
- Create a new application
Click "create app" or "create another app"
Fill out the form:
- Name: Something descriptive like "MySubredditMonitorBot"
- App type: Select "script" (this is for personal use)
- Description: Brief description of what the bot does
- About URL: Can be blank
- Redirect URI: Use
http://localhost:8080(required but not used for script apps)
- Save your credentials
After creating the app, you'll see:
- client_id: The string under your app name
- client_secret: The "secret" value
Write these down. You'll need them.
Step 2: Install PRAW
PRAW (Python Reddit API Wrapper) handles all the messy authentication and API stuff for you.
pip install praw
That's it. PRAW is maintained, updated for the 2023+ API changes, and handles rate limiting automatically.
Step 3: Basic Authentication
Create a new Python file called reddit_bot.py:
import praw
reddit = praw.Reddit(
client_id="YOUR_CLIENT_ID",
client_secret="YOUR_CLIENT_SECRET",
user_agent="MyBot/1.0 by /u/YourBotUsername",
username="YourBotUsername",
password="YourBotPassword"
)
# Test the connection
print(f"Logged in as: {reddit.user.me()}")
Replace the placeholder values with your actual credentials.
Important: Never hardcode credentials in production code. Use environment variables:
import os
import praw
reddit = praw.Reddit(
client_id=os.environ["REDDIT_CLIENT_ID"],
client_secret=os.environ["REDDIT_CLIENT_SECRET"],
user_agent=os.environ["REDDIT_USER_AGENT"],
username=os.environ["REDDIT_USERNAME"],
password=os.environ["REDDIT_PASSWORD"]
)
Step 4: Monitoring a Subreddit
Here's a simple bot that monitors new posts in a subreddit:
import praw
import time
reddit = praw.Reddit(
# ... your credentials
)
subreddit = reddit.subreddit("test") # Use r/test for testing
print(f"Monitoring r/{subreddit.display_name}...")
# Stream new submissions
for submission in subreddit.stream.submissions(skip_existing=True):
print(f"New post: {submission.title}")
print(f"Author: {submission.author}")
print(f"URL: {submission.url}")
print("---")
The stream.submissions() function continuously watches for new posts. The skip_existing=True parameter means it won't process posts that were already there when the bot started.
Step 5: Replying to Posts (Carefully!)
Here's where things get risky. Automated replies can get you banned fast if you're not careful.
import praw
import time
reddit = praw.Reddit(
# ... your credentials
)
subreddit = reddit.subreddit("test")
keywords = ["help", "question", "newbie"]
for submission in subreddit.stream.submissions(skip_existing=True):
title_lower = submission.title.lower()
# Check if any keyword is in the title
if any(keyword in title_lower for keyword in keywords):
print(f"Found matching post: {submission.title}")
# Add a delay to be polite
time.sleep(10)
try:
submission.reply("This is an automated response. [Your helpful message here]")
print("Replied successfully!")
except Exception as e:
print(f"Error replying: {e}")
# Rate limit ourselves
time.sleep(60) # Wait 1 minute between replies
DON'T Get Banned
Seriously. Reddit bans bots that:
- Reply too frequently
- Leave generic/spammy comments
- Operate in subreddits that don't allow bots
- Fail to disclose they're automated
Best practices:
- Always identify as a bot in your messages
- Add delays between actions (I use 60+ seconds)
- Check subreddit rules before operating there
- Start small - test in r/test first
- Monitor for errors - if you're getting 403s, stop immediately
Step 6: Searching Reddit
One of the most useful bot functions is searching across subreddits:
import praw
reddit = praw.Reddit(
# ... your credentials
)
# Search a specific subreddit
for submission in reddit.subreddit("Python").search("API tutorial", limit=10):
print(f"Title: {submission.title}")
print(f"Score: {submission.score}")
print(f"Link: https://reddit.com{submission.permalink}")
print("---")
# Search multiple subreddits
subreddits = ["Python", "learnpython", "programming"]
for sub_name in subreddits:
print(f"\nSearching r/{sub_name}...")
subreddit = reddit.subreddit(sub_name)
for submission in subreddit.search("beginner project", limit=5):
print(f" - {submission.title}")
This is insanely powerful for research. But doing it manually for dozens of subreddits gets tedious fast.
For more serious Reddit research across multiple subreddits with advanced filters, I actually use Wappkit Reddit because it handles batch searching with a UI. But for simple automation, PRAW gets the job done.
Step 7: Downloading Post Data
Want to build a dataset? Here's how to export posts to JSON:
import praw
import json
from datetime import datetime
reddit = praw.Reddit(
# ... your credentials
)
def scrape_subreddit(subreddit_name, limit=100):
subreddit = reddit.subreddit(subreddit_name)
posts = []
for submission in subreddit.hot(limit=limit):
post_data = {
"title": submission.title,
"score": submission.score,
"url": submission.url,
"created_utc": submission.created_utc,
"num_comments": submission.num_comments,
"author": str(submission.author),
"selftext": submission.selftext[:500] if submission.selftext else None,
"permalink": f"https://reddit.com{submission.permalink}"
}
posts.append(post_data)
return posts
# Scrape and save
data = scrape_subreddit("programming", limit=50)
with open("reddit_data.json", "w") as f:
json.dump(data, f, indent=2)
print(f"Saved {len(data)} posts to reddit_data.json")
Step 8: Handling Comments
Comments are structured as trees. Here's how to navigate them:
import praw
reddit = praw.Reddit(
# ... your credentials
)
# Get a specific post
submission = reddit.submission(id="post_id_here")
# Replace "MoreComments" objects with actual comments
submission.comments.replace_more(limit=0)
# Iterate through all comments
for comment in submission.comments.list():
print(f"Author: {comment.author}")
print(f"Score: {comment.score}")
print(f"Body: {comment.body[:200]}...")
print("---")
The replace_more(limit=0) line is important - it tells PRAW to skip the "load more comments" links. Without it, you'll hit errors on long threads.
Common Bot Projects (And How to Build Them)
Keyword Alert Bot
Notifies you when specific keywords appear in a subreddit:
import praw
import smtplib
from email.mime.text import MIMEText
reddit = praw.Reddit(
# ... your credentials
)
keywords = ["job opening", "hiring", "looking for developer"]
subreddit = reddit.subreddit("forhire+remotejobs+jobs")
for submission in subreddit.stream.submissions(skip_existing=True):
text = f"{submission.title} {submission.selftext}".lower()
for keyword in keywords:
if keyword in text:
print(f"ALERT: Found '{keyword}' in: {submission.title}")
# Add email notification logic here
break
Flair Statistics Bot
Tracks which post flairs are most popular:
import praw
from collections import Counter
reddit = praw.Reddit(
# ... your credentials
)
subreddit = reddit.subreddit("Python")
flair_counts = Counter()
for submission in subreddit.hot(limit=500):
if submission.link_flair_text:
flair_counts[submission.link_flair_text] += 1
print("Top 10 post flairs:")
for flair, count in flair_counts.most_common(10):
print(f" {flair}: {count}")
Cross-Post Bot
Automatically cross-posts between subreddits you moderate:
import praw
reddit = praw.Reddit(
# ... your credentials
)
source = reddit.subreddit("your_source_sub")
target = reddit.subreddit("your_target_sub")
for submission in source.stream.submissions(skip_existing=True):
if submission.score > 100: # Only cross-post popular content
try:
submission.crosspost(target)
print(f"Cross-posted: {submission.title}")
except Exception as e:
print(f"Error: {e}")
Warning: Only do this for subreddits you moderate. Automated cross-posting to random subreddits WILL get you banned.
Avoiding Common Mistakes
After 3 years of running bots, here's what I've learned the hard way:
1. Rate Limits Are Your Friend
Don't try to speed up your bot by removing delays. Reddit WILL notice. PRAW handles most rate limiting automatically, but add your own delays for write operations.
2. Handle Errors Gracefully
Reddit goes down. API calls fail. Accounts get suspended. Your bot should handle all of this:
import time
from prawcore.exceptions import ServerError, ResponseException
while True:
try:
# Your bot logic here
pass
except ServerError:
print("Reddit servers are down. Waiting 5 minutes...")
time.sleep(300)
except ResponseException as e:
print(f"API error: {e}. Waiting 1 minute...")
time.sleep(60)
except Exception as e:
print(f"Unknown error: {e}")
time.sleep(60)
3. Log Everything
When something goes wrong, you need to know what the bot was doing:
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler("bot.log"),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
# Use logger.info(), logger.error(), etc.
logger.info("Bot started")
logger.error(f"Failed to reply: {error}")
4. Test in r/test First
The subreddit r/test exists specifically for testing bots. Use it before deploying anywhere else.
5. Read Subreddit Rules
Some subreddits explicitly ban bots. Others require permission. Check before you deploy.
Running 24/7: Deployment Options
For a bot that needs to run continuously:
Option 1: Raspberry Pi Cheap, runs forever, sits in a corner. Perfect for personal bots.
Option 2: DigitalOcean/AWS/etc $5/month droplets are enough for most bots. More reliable than home hardware.
Option 3: GitHub Actions Can run bots on a schedule (not continuous) for free. Good for periodic tasks.
Option 4: Heroku Free Tier Was great, now limited. Still works for some use cases.
My recommendation? Start with your local machine. When you're confident the bot works, move to a cheap VPS.
Final Thoughts
Reddit bots are still one of the most useful automation projects you can build. The API changes made commercial applications harder, but personal projects are basically unaffected.
Start simple. Build something that solves a real problem for you. Test thoroughly. And always, always be respectful of the communities you're operating in.
The best bots are invisible - they make Reddit better without anyone noticing they're there.
Happy coding.