Reddit API
Read posts, comments and subreddit data (and post, authenticated).
What it does
Reddit’s API exposes listings (hot/new/top/rising) for any subreddit or user, comment trees, search, subreddit metadata, and (authenticated) voting, posting and moderation. Almost every page on reddit.com has a JSON representation.
Base URL
Authentication
Register an app to get a client ID and secret, then obtain an OAuth 2.0 token (the client_credentials or password grant for scripts) and send Authorization: bearer TOKEN plus a unique, descriptive User-Agent. Unauthenticated www.reddit.com/….json access still exists but is heavily throttled and discouraged.
Code examples
curl -s -X POST https://www.reddit.com/api/v1/access_token \ -u "$CLIENT_ID:$CLIENT_SECRET" \ -d grant_type=client_credentials \ -A "larzos-demo/1.0 by u/yourname"
import requests
H = {"Authorization": f"bearer {TOKEN}", "User-Agent": "larzos-demo/1.0 by u/yourname"}
r = requests.get("https://oauth.reddit.com/r/programming/hot",
params={"limit": 5}, headers=H, timeout=10)
for c in r.json()["data"]["children"]:
p = c["data"]
print(p["score"], p["title"])Rate limits & quotas
Free OAuth access: 100 queries per minute per client ID, averaged over a 10-minute window. Response headers (X-Ratelimit-Remaining, X-Ratelimit-Reset) track it. High-volume and commercial use requires a paid data agreement (in force since 2023). A non-generic User-Agent is mandatory — generic ones are rate-limited far harder or blocked.
Key response fields
| data.children[].data | Each post/comment — the useful payload |
| ….title / selftext / url / permalink | Post content and links |
| ….score / ups / num_comments / created_utc | Engagement and timestamp |
| data.after / data.before | Fullname cursors for pagination (?after=t3_xxxxx) |
| kind | t1 comment, t3 link, t5 subreddit… |
Common errors
| 401 | Missing/expired token, or you called oauth.reddit.com without one. |
| 403 | Private/quarantined subreddit, or your app lacks the needed scope. |
| 429 | Over 100 queries/minute, or a generic User-Agent got you throttled. |
| 404 | Banned or non-existent subreddit/user. |
When to use it (and alternatives)
Use it for subreddit feeds, comment analysis and bots — but design for the 100/minute ceiling and be aware Reddit now gates scale behind paid access. For a friendlier dev-news source with no auth, Hacker News is far simpler.
FAQ
Can I still just add .json to a Reddit URL?
It works for light, occasional use but is aggressively rate-limited and against the spirit of the current terms. For anything real, register an app and use OAuth.
Why am I getting 429s almost immediately?
Two common causes: a generic User-Agent (use appname/version by u/you), and sharing one client ID across many servers — the 100/minute limit is per client ID, not per server.
Is the Reddit API free?
For low-volume, non-commercial use within the 100/minute limit, yes. Commercial or high-volume access requires a paid agreement with Reddit.
New to APIs?
Short guides for working with this API — and any other.