Reddit Has a Free JSON API (No Auth Required) — Here is How to Use It
title: Reddit Has a Free JSON API (No Auth Required) — Here's How to Use It
tags: python, api, webdev, datascience
Reddit exposes a hidden JSON API on every single page. Add .json to any URL and you get structured data — no OAuth, no API key, no rate limit headaches.
I used this to build a sentiment analysis pipeline that tracks brand mentions across 50+ subreddits. Here's the complete guide.
The Secret: Just Add .json
Every Reddit URL has a JSON version:
https://www.reddit.com/r/python/hot.json
https://www.reddit.com/r/webdev/top.json?t=month
https://www.reddit.com/r/datascience/new.json
https://www.reddit.com/user/spez/comments.json
That's it. No signup. No tokens. Just append .json.
Quick Start: Get Top Posts in 5 Lines
import urllib.request
import json
url = "https://www.reddit.com/r/python/top.json?t=week&limit=5"
req = urllib.request.Request(url, headers={"User-Agent": "python-tutorial/1.0"})
response = urllib.request.urlopen(req)
data = json.loads(response.read())
for post in data["data"]["children"]:
p = post["data"]
print(f"⬆ {p['ups']:>5} | {p['title'][:80]}")
print(f" {p['num_comments']} comments | u/{p['author']}")
Important: Always set a custom User-Agent header. Reddit blocks the default Python one.
5 Practical Use Cases
1. Track Brand Mentions Across Subreddits
def search_brand(brand, limit=25):
url = f"https://www.reddit.com/search.json?q={brand}&sort=new&limit={limit}"
req = urllib.request.Request(url, headers={"User-Agent": "brand-monitor/1.0"})
response = urllib.request.urlopen(req)
data = json.loads(response.read())
results = []
for post in data["data"]["children"]:
p = post["data"]
results.append({
"title": p["title"],
"subreddit": p["subreddit"],
"score": p["ups"],
"url": f"https://reddit.com{p['permalink']}"
})
return results
for mention in search_brand("ChatGPT"):
print(f"r/{mention['subreddit']:20} ⬆{mention['score']:>5} | {mention['title'][:60]}")
2. Analyze Subreddit Growth
import time
def subreddit_stats(name):
url = f"https://www.reddit.com/r/{name}/about.json"
req = urllib.request.Request(url, headers={"User-Agent": "stats/1.0"})
response = urllib.request.urlopen(req)
data = json.loads(response.read())["data"]
return {
"name": data["display_name"],
"subscribers": data["subscribers"],
"active_users": data["active_user_count"],
"created": time.strftime("%Y-%m-%d", time.gmtime(data["created_utc"]))
}
for sub in ["python", "javascript", "rust", "golang", "datascience"]:
s = subreddit_stats(sub)
print(f"r/{s['name']:15} | {s['subscribers']:>10,} subs | {s['active_users']:>5} online | since {s['created']}")
3. Extract All Comments from a Post
def get_comments(post_id, subreddit):
url = f"https://www.reddit.com/r/{subreddit}/comments/{post_id}.json?limit=100"
req = urllib.request.Request(url, headers={"User-Agent": "comments/1.0"})
response = urllib.request.urlopen(req)
data = json.loads(response.read())
comments = []
for comment in data[1]["data"]["children"]:
if comment["kind"] == "t1":
c = comment["data"]
comments.append({
"author": c["author"],
"body": c["body"][:200],
"score": c["ups"]
})
return comments
# Example: get comments from a specific post
comments = get_comments("1abc123", "python")
for c in comments[:5]:
print(f"u/{c['author']} (⬆{c['score']}): {c['body'][:100]}")
4. Monitor New Posts in Real-Time
import time
def monitor_subreddit(name, check_interval=60):
seen = set()
while True:
url = f"https://www.reddit.com/r/{name}/new.json?limit=10"
req = urllib.request.Request(url, headers={"User-Agent": "monitor/1.0"})
response = urllib.request.urlopen(req)
data = json.loads(response.read())
for post in data["data"]["children"]:
p = post["data"]
if p["id"] not in seen:
seen.add(p["id"])
print(f"[NEW] r/{name}: {p['title'][:80]}")
time.sleep(check_interval)
# monitor_subreddit("webdev") # Uncomment to run
5. Compare Subreddit Sentiment
def get_hot_titles(subreddit, limit=25):
url = f"https://www.reddit.com/r/{subreddit}/hot.json?limit={limit}"
req = urllib.request.Request(url, headers={"User-Agent": "sentiment/1.0"})
response = urllib.request.urlopen(req)
data = json.loads(response.read())
return [post["data"]["title"] for post in data["data"]["children"]]
# Simple keyword sentiment
positive = ["love", "great", "amazing", "best", "awesome"]
negative = ["hate", "worst", "terrible", "broken", "bug"]
for sub in ["python", "javascript", "rust"]:
titles = get_hot_titles(sub)
text = " ".join(titles).lower()
pos = sum(text.count(w) for w in positive)
neg = sum(text.count(w) for w in negative)
print(f"r/{sub:12} | 👍 {pos} positive | 👎 {neg} negative")
Endpoints Cheat Sheet
| URL Pattern | What You Get |
r/{sub}/hot.json | Hot posts |
r/{sub}/top.json?t=week | Top posts (hour/day/week/month/year/all) |
r/{sub}/new.json | Newest posts |
r/{sub}/about.json | Subreddit stats |
search.json?q=term | Search across Reddit |
user/{name}/comments.json | User's comments |
r/{sub}/comments/{id}.json | Post + comments |
Rate Limits
- No auth: ~30 requests/minute
- With OAuth: 60 requests/minute
- Always use a custom User-Agent
- Add
&raw_json=1to avoid HTML-encoded characters
When NOT to Use the JSON API
- You need more than 1000 posts per listing (use Pushshift or a scraper)
- You need historical data (JSON API only shows current listings)
- You need real-time streaming (use Reddit's websocket API instead)
Conclusion
Reddit's JSON API is the fastest way to get structured social data — zero setup, zero cost. Perfect for market research, brand monitoring, and competitive analysis.
More Free API Tutorials
- Spotify Has a Free API — Analyze Any Artist's Discography in Python
- GitHub Has a Free API — Analyze Any Repository in Seconds
- ArXiv Has a Free API — Search 2.4M+ Research Papers
- Hacker News Has a Free API — Track Tech Trends in Real Time
- Notion Has a Free API — Build a Personal Dashboard
Need production-scale Reddit scraping? Try Reddit Scraper Pro on Apify — handles pagination, rate limits, and exports to CSV/JSON automatically. 376+ production runs across 78 actors.
Need a custom scraper built in 48 hours? Pilot rate: $100/project. 78 published Apify actors, 376+ runs. Email spinov001@gmail.com — reply by Friday for priority slot.
💡 More scraping tips → @scraping_ai
