Reddit Integration Guide
Technology: reddit · Category: comms · Last reviewed: 2026-10-20
Source: https://tech-stack.codeamanilabs.org/guide/reddit
Insight:
Reddit is a social-listening, community-engagement and ad channel, not a payment or auth rail. Since 2025-11-11 the Data API is approval-only under the Responsible Builder Policy: you can no longer self-create a working app at reddit.com/prefs/apps, so file the API-access request before you plan any Data API build, and expect rejections for vague or commercial use cases. Approved clients get 100 QPM per OAuth client id (10-min average), must send a descriptive User-Agent, and should delete stored content within 48 h. Reddit now steers bots and mod tools to Devvit (
devvit/@devvit/web0.15.0), which needs no API key but only allows OpenAI and Gemini as LLMs, not Claude. The Ads API v3 and Conversions API are separate, open without allowlisting, and the right tool for paid campaigns. For codeAmani: manual, value-first participation is always allowed; programmatic listening for product research is a business use, so get written approval first. Never astroturf: sockpuppets, vote manipulation and copy-paste promo are bannable.
██████╗ ███████╗██████╗ ██████╗ ██╗████████╗
██╔══██╗██╔════╝██╔══██╗██╔══██╗██║╚══██╔══╝
██████╔╝█████╗ ██║ ██║██║ ██║██║ ██║
██╔══██╗██╔══╝ ██║ ██║██║ ██║██║ ██║
██║ ██║███████╗██████╔╝██████╔╝██║ ██║
╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝
Reddit Integration Guide
Focus: Use Reddit to learn what users actually ask for (listening), to build trust as the
codeAmani-Labsaccount (engagement), and, when a product is live, to run and measure ads (Ads API + Conversions API). Pick the right one of Reddit's four developer surfaces before writing code; the access rules differ a lot between them.
Overview
Reddit is a forum of forums: thousands of topic communities ("subreddits") where people ask real questions and complain about real problems in their own words. That makes it one of the best voice-of-customer sources on the open web, and a place to build reputation by being helpful before being promotional.
Reddit exposes four developer surfaces. They have different owners, access rules and auth:
| Surface | What it's for | Access (Oct 2026) | Auth |
|---|---|---|---|
Data API (oauth.reddit.com) |
Read listings/search, post comments from an off-Reddit server | Approval required for every new client (Responsible Builder Policy, 2025-11-11). Commercial use needs a written agreement. | OAuth2 client id + secret, bearer token |
| Developer Platform ("Devvit") | Apps that run on Reddit: mod tools, bots, interactive posts, games | Self-serve to build and playtest; App Review before public listing or premium features (fetch, LLMs, payments) | None to manage: Devvit authenticates the reddit permission |
Ads API v3 (ads-api.reddit.com/api/v3) |
Create and manage campaigns, pull reports | Open, no allowlisting (Ads API Terms apply) | OAuth2 auth-code flow, ads* scopes |
| Conversions API (CAPI v3) | Send server-side conversion events for ad attribution | Open to advertisers (Advertiser Measurement Program Terms) | Conversion access token from Events Manager |
The codeAmani loop is still listen → analyse → engage, with ads as an optional fourth step:
flowchart LR
A["Request Data API access<br/>(Responsible Builder Policy)"] -->|"approved client id + secret"| B["OAuth2 token<br/>/api/v1/access_token"]
B -->|"bearer token"| C["oauth.reddit.com"]
C -->|"GET /r/sub/new · /search"| D["Listen: threads"]
D --> E["Analyse with Claude<br/>themes · pain-points"]
E --> F["Roadmap decisions"]
E -.->|"value-first reply<br/>(manual or approved bot)"| G["Engage as codeAmani-Labs"]
F --> H["Ads API v3 campaign"]
H --> I["Conversions API<br/>server-side events"]
J["Devvit app<br/>(mod tool / bot on Reddit)"] -.->|"no API key, App Review"| G
Official Documentation
The archive wiki is stale in places.
reddit-archive/…/wiki/APIstill quotes the old 60 req/min limit and implies self-service app creation. The Data API Wiki itself warns that "some of the information in our legacy API documentation … may be out of date". Treat the Responsible Builder Policy, the Data API Wiki and the Data API Terms as the source of truth.
1. Data API access: request approval first
What changed. On 2025-11-11 Reddit announced the Responsible Builder Policy on r/redditdev and closed self-service access: "Starting today, self-service access to Reddit's public data API will be closed. Anyone looking to build with Reddit data, whether you're a developer, researcher, or moderator, will need to request approval before gaining access." Tokens issued before that date kept working; new clients need approval. The policy's own wording: "You must request access and get explicit approval before accessing any Reddit data through our API."
Which route fits:
| You are… | Route |
|---|---|
| Building a mod tool, bot or in-Reddit app | Use Devvit first (§6). The policy says developers "should use the Developer Platform"; file a ticket only "if your use case is not supported by Devvit". |
| A company using Reddit data to power or improve a product (this includes automated market research for codeAmani products) | Commercial: needs "explicit written approval" and a contract. Request via the enterprise ticket type. |
| An academic researcher | Only route is the Reddit for Researchers (RFR) program. Research with data collected outside RFR violates the policy. |
| A person reading and replying by hand | No API needed. This is always allowed. |
What the request must show. A clear purpose, the exact subreddits and API actions needed, how long you keep data, and confirmation that you won't train models on it. One request per use case: the policy forbids registering multiple accounts or submitting multiple requests for the same use case. Developer reports on r/redditdev (2026) describe slow review and frequent rejections for read-only projects; plan as if approval may not come.
Hard rules once approved (Responsible Builder Policy + Data API Terms):
- No AI/ML training on Reddit data, no selling or sharing it, no ad targeting with it, without written approval.
- No inferring sensitive traits (health, politics, sexual orientation) and no re-identifying users, including by matching with off-platform identifiers.
- Bots must be labelled. Register a developer profile to get the App profile label, use the app account only for the app ("no mixed use accounts"), and get explicit consent before private messages.
- No spam: no identical or near-identical posts across subreddits, and no vote or karma manipulation.
- Delete deleted content. When a post, comment or account is deleted you must delete your copy, including author identifiers. Reddit "strongly recommend[s] routinely deleting any stored user data and content within 48 hours."
- Enforcement: token revocation, app or account suspension, and suspension of associated accounts, domains or subreddits.
2. Register the app and store credentials
After approval you create (or are issued) the OAuth app. The app type still decides the grant:
| App type | Use it for | Grant |
|---|---|---|
| script | Server-side job acting as one account (our brand account) | password |
| web app | Acting as other users via consent; long-lived bots with a refresh token | authorization_code (+ duration=permanent) |
| installed app | Public clients (mobile/SPA), no secret | https://oauth.reddit.com/grants/installed_client |
Secrets go in the secrets vault / .env.local and never ship to the browser:
# .env.local: never commit, never expose via NEXT_PUBLIC_*
REDDIT_CLIENT_ID=your-approved-client-id
REDDIT_CLIENT_SECRET=your-client-secret
REDDIT_PASSWORD=brand-account-password # script-app password grant only
REDDIT_REFRESH_TOKEN=refresh-token-from-oauth # web-app flow (preferred for long-lived bots)
Non-secret settings (plain env vars or config):
| Setting | Example | Notes |
|---|---|---|
REDDIT_USERNAME |
codeAmani-Labs |
Account that owns the script app |
REDDIT_USER_AGENT |
web:com.codeamanilabs.listener:v1.0 (by /u/codeAmani-Labs) |
Mandatory, unique, descriptive. Bump the version when you ship. |
User-Agent format (Data API Wiki):
<platform>:<app ID>:<version string> (by /u/<reddit username>). Default agents likePython/urlliborJava"are drastically limited", and Reddit says to never lie about your UA. The same rule applies to the Ads API.
3. Get an OAuth2 token
POST https://www.reddit.com/api/v1/access_token, authenticated with HTTP Basic (client_id:client_secret). Tokens last about an hour (expires_in: 3600); cache and refresh before expiry.
Read-only "listening" token (application-only)
// lib/reddit-auth.ts
const TOKEN_URL = "https://www.reddit.com/api/v1/access_token";
export async function getAppToken(): Promise<string> {
const basic = Buffer.from(
`${process.env.REDDIT_CLIENT_ID}:${process.env.REDDIT_CLIENT_SECRET}`
).toString("base64");
const res = await fetch(TOKEN_URL, {
method: "POST",
headers: {
Authorization: `Basic ${basic}`,
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": process.env.REDDIT_USER_AGENT!,
},
// Confidential clients (script / web app) use client_credentials.
body: new URLSearchParams({ grant_type: "client_credentials" }),
});
if (!res.ok) throw new Error(`Reddit token failed: ${res.status}`);
const { access_token } = (await res.json()) as { access_token: string };
return access_token;
}
Posting token (script app, password grant)
Acts as codeAmani-Labs. Only works for the account that owns a script app.
// Swap the body for the password grant; everything else is identical.
const body = new URLSearchParams({
grant_type: "password",
username: process.env.REDDIT_USERNAME!,
password: process.env.REDDIT_PASSWORD!,
});
For a long-running bot, prefer a web app +
authorization_codeflow withduration=permanentand store the refresh token in the vault, so you never store the account password. Remember the policy: a bot account must be used only for the bot.
4. Authenticated requests → oauth.reddit.com
All API calls go to https://oauth.reddit.com (not www.reddit.com) with the bearer token and your UA. Modhashes are not needed under OAuth.
// lib/reddit.ts
const API = "https://oauth.reddit.com";
export async function redditGet<T>(path: string, token: string): Promise<T> {
const res = await fetch(`${API}${path}`, {
headers: {
Authorization: `bearer ${token}`,
"User-Agent": process.env.REDDIT_USER_AGENT!,
},
});
logRateLimit(res.headers); // see §5
if (!res.ok) throw new Error(`Reddit GET ${path} → ${res.status}`);
return (await res.json()) as T;
}
Listen: newest posts in a subreddit
// GET /r/:subreddit/new: limit ≤ 100, paginate with `after`
type Listing = { data: { after: string | null; children: { data: Record<string, unknown> }[] } };
const listing = await redditGet<Listing>("/r/SaaS/new?limit=50", token);
const posts = listing.data.children.map((c) => ({
fullname: String(c.data.name), // "t3_abc123"
title: String(c.data.title),
body: String(c.data.selftext ?? ""),
url: `https://reddit.com${String(c.data.permalink)}`,
score: Number(c.data.score),
numComments: Number(c.data.num_comments),
}));
Listen: search for threads we can answer
// Search all of Reddit
await redditGet(`/search?q=${encodeURIComponent("stripe checkout nextjs")}&sort=new&limit=25`, token);
// Search within one subreddit (restrict_sr=true)
await redditGet(`/r/webdev/search?q=stripe+webhooks&restrict_sr=true&sort=relevance&limit=25`, token);
// Find communities to monitor
await redditGet(`/subreddits/search?q=saas&sort=relevance&limit=10`, token);
Engage: comment on a thread
thing_id is the fullname of the parent (t3_ post, t1_ comment). Needs the submit scope and a posting token.
export async function redditPost(path: string, token: string, form: Record<string, string>) {
const res = await fetch(`https://oauth.reddit.com${path}`, {
method: "POST",
headers: {
Authorization: `bearer ${token}`,
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": process.env.REDDIT_USER_AGENT!,
},
body: new URLSearchParams(form),
});
if (!res.ok) throw new Error(`Reddit POST ${path} → ${res.status}`);
return res.json();
}
// Reply to a post
await redditPost("/api/comment", token, {
api_type: "json",
thing_id: "t3_abc123",
text: "Here's how we handled Stripe webhook retries idempotently…", // raw markdown
});
Engage: submit a self-post
// kind=self for a text post; kind=link with `url` for a link post.
await redditPost("/api/submit", token, {
api_type: "json",
sr: "webdev",
kind: "self",
title: "What we learned shipping Stripe subscriptions in Next.js 15",
text: "After a few launches, here's what tripped us up…",
});
Pre-validate before submitting.
GET /api/v1/{subreddit}/post_requirementsreturns mod rules (title length, required flair, blacklisted words, allowed domains). Check it first to avoid auto-removal. Automated posting is where the policy bites hardest: no identical text across subreddits, and every automated account needs the App label.
5. Rate limits, retention & resilience
From the Data API Wiki (Oct 2026), for free-access usage:
| Limit | Value |
|---|---|
| Requests | 100 QPM per OAuth client id, averaged over a 10-minute window (bursting is fine) |
| Chat messages | 2,000/day per recipient · 3,000/day total |
| Chat rooms (bots) | join up to 300/day |
| Non-OAuth traffic | Blocked (the old "10 QPM" fallback no longer applies) |
Every response carries the live budget:
| Header | Meaning |
|---|---|
X-Ratelimit-Used |
Approx. requests used this period |
X-Ratelimit-Remaining |
Approx. requests left |
X-Ratelimit-Reset |
Approx. seconds until the period ends |
export function logRateLimit(h: Headers): void {
const remaining = Number(h.get("x-ratelimit-remaining") ?? "100");
const reset = Number(h.get("x-ratelimit-reset") ?? "0"); // seconds
if (remaining < 5) {
// Sleep until the window resets instead of risking a 429.
console.warn(`Reddit budget low: ${remaining} left, reset in ${reset}s`);
}
}
On 429, wait for X-Ratelimit-Reset and retry (see examples/listen.ts). Cache tokens (~1 h) and listings; listening doesn't need to be real-time.
Retention. Delete local copies when Reddit content is deleted; default to purging stored posts after 48 h and keep only derived, de-identified aggregates (theme counts, not usernames). The Data API Terms also require deleting cached content and derived models if access ends.
Pricing
Reddit publishes no price list for the Data API. The Data API Terms (revised 2026-07-20) say Reddit "reserves the right to charge fees … rates to be determined at Reddit's sole discretion", and anything commercial, over the rate limit, or not expressly permitted needs a separate agreement. The FAQ adds that bulk export is "significantly limited by default" and that select developers "may be charged fees to lift those limits". Treat cost as "contract, negotiated". The "$0.24 per 1,000 calls" figure that circulated in 2023 was never in Reddit's docs and has been removed from this guide.
6. Devvit (Reddit Developer Platform)
Devvit apps run on Reddit's infrastructure: you don't create an OAuth app or manage keys ("Devvit handles authentication automatically when you enable the reddit permission"). Reddit now calls Devvit "the primary way to develop Reddit extensions" and is paying developers to migrate Data API bots (the $1,000,000 App Migration Program; register at https://developers.reddit.com/app-registration).
Versions (npm, 2026-10-20): devvit 0.15.0 (CLI) and @devvit/web 0.15.0 (released 2026-10-19). Templates require Node ≥ 24.
0.15.0 breaking changes: devvit.yaml is no longer supported (migrate to devvit.json), and reddit.getWikiPage(subreddit, page, revisionId) became getWikiPage(subreddit, page, options). @devvit/public-api and the blocks property in devvit.json are deprecated (still supported): build new apps on Devvit Web (@devvit/web).
npm install -g devvit@0.15.0 # or use npx devvit
npx devvit login
npx devvit init # pick a template (React, Phaser, Three.js, Hello World)
npx devvit playtest # installs to a test subreddit, streams logs
npx devvit upload # private upload (visible only to you)
npx devvit publish # new version + source uploaded for App Review
npx devvit settings set apiKey # store a global secret (never in devvit.json)
Shape of a Devvit Web app:
.
├── src/client/ # webview (HTML/CSS/JS, React…), shown inside a post
├── src/server/ # Node server: /api/* for the client, /internal/* for triggers, menus, cron
└── devvit.json # name, permissions, settings, triggers, scheduler, menu
{
"$schema": "https://developers.reddit.com/schema/config-file.v1.json",
"name": "keyword-watch",
"server": { "dir": "dist/server", "entry": "index.js" },
"permissions": { "reddit": true, "redis": true },
"triggers": { "onPostSubmit": "/internal/triggers/post-submit" }
}
Server code imports capabilities from one entry point:
import { reddit, redis, settings, context } from "@devvit/web/server";
import type { OnPostSubmitRequest, TriggerResponse } from "@devvit/web/shared";
Full runnable mod tool: examples/devvit-keyword-watch/.
Limits and rules that matter:
| Topic | Rule |
|---|---|
| Runtime | Serverless endpoints, 30 s max request, 4 MB payload, 10 MB response; no fs, no native packages, no websockets/streaming |
| Server endpoints | Client fetches only to your own /api/*; treat them as public and check permissions server-side |
| HTTP fetch | Server-side only, allowlisted exact hostnames declared in permissions.http.domains; reviewed in ~1–2 business days |
| LLMs | Only OpenAI (api.openai.com) and Google Gemini are approved. Self-hosted models are not. Anthropic/Claude is not allowed in Devvit apps. |
| Training | Never use Reddit data to train or fine-tune any model |
| Deletion | On onPostDelete / onCommentDelete, delete the content from Redis and any external service |
| Triggers | Can be delivered more than once, so make handlers idempotent; avoid recursive triggers |
| Review | Needed to list in the App Directory and for premium features (fetch, LLMs, payments); apps using them need their own ToS and privacy policy |
| Payments | Devvit Payments under Reddit's Earn Terms; you cannot send users off-platform to pay (so no Stripe or M-Pesa links in a Devvit app) |
| Secrets | settings with isSecret: true, set via npx devvit settings set; .env is read during playtest only |
7. Reddit Ads API v3 & Conversions API
Use these when a codeAmani product advertises on Reddit. They are separate from the Data API: the Ads API "is open to all developers and does not require allowlisting or approval". Terms: Ads API Terms; CAPI also falls under the Advertiser Measurement Program Terms.
Ads API basics
- Base URL
https://ads-api.reddit.com/api/v3; OpenAPI spec at/api/v3/openapi.json. - Create a developer application inside Reddit Ads (app name, about URL, redirect URL, a business-admin primary contact), then run the OAuth2 authorization-code flow against
https://www.reddit.com/api/v1/authorize/…/access_tokenfor access + refresh tokens. - Scopes:
adsread,adsedit,adsconversions,adsdatadeletion. - Pagination: follow
pagination.next_urlexactly; don't rebuild it from query params. - Rate limits are per endpoint group and per authorizing user, reported in the
RateLimit-PolicyandRateLimitheaders (e.g.RateLimit: "policy";r=2134;t=723). Back off exponentially on429. - Upcoming changes: new campaign objective enums rolled out from 2026-09-21 (see the objective migration guide), and from 2026-12-08
HOUR-breakdown reports are limited to ranges of 7 days or less.
Conversions API (CAPI v3)
POST https://ads-api.reddit.com/api/v3/pixels/{pixel_id}/conversion_eventswithAuthorization: Bearer <conversion access token>(generate it in Ads Manager → Events Manager → Conversions API).- Body
{ data: { test_id?, events: [...] } }, 1–1,000 events per call. Each event needsevent_at,action_source(WEBSITE/APP/OTHER/PHYSICAL_STORE) andtype.tracking_type(PAGE_VISIT,VIEW_CONTENT,SEARCH,ADD_TO_CART,ADD_TO_WISHLIST,PURCHASE,LEAD,SIGN_UP,CUSTOM+custom_event_name). - Limits: 1,000 requests/s and 10,000 events/s. Send events within 7 days (within 2 days for reliable dedup).
- Match keys:
click_id(therdt_cidlanding param),user.email/phone_number(SHA-256 after Reddit's canonicalization),ip_address,user_agent,uuid(_rdt_uuidcookie). Set the samemetadata.conversion_idin Pixel and CAPI for deduplication. - v3 field values (including
tracking_type) differ from v2; follow the CAPI migration guide if you have v2 code.
Runnable example with email hashing and backoff: examples/capi-conversion.ts. Store the conversion token as a secret:
REDDIT_CONVERSION_TOKEN=your-conversion-access-token
REDDIT_ADS_CLIENT_SECRET=your-ads-app-secret
| Non-secret setting | Example |
|---|---|
REDDIT_PIXEL_ID |
your Pixel ID (from Events Manager) |
REDDIT_ADS_CLIENT_ID |
Ads developer-app id |
REDDIT_CAPI_TEST_ID |
Test code from Events Manager → Testing (dev only) |
8. Wrappers
- Plain
fetch(§3–§4) is the recommended Node path: one bearer token, your own types. - snoowrap (
snoowrap@1.23.0) is deprecated on npm ("Package no longer supported") with types that track old response shapes. Don't use it for new code. - PRAW 8.0.3 (Python ≥ 3.10, released 2026-08-12) is the maintained Python wrapper. 8.0 made most listing/submit arguments keyword-only and merged
submit_image/submit_video/submit_galleryintosubmit(). It still needs an approved Data API client. Reddit's Devvit docs include a PRAW → Devvit Web migration guide.
codeAmani notes
Access decision (do this first)
- Manual participation by a human on
u/codeAmani-Labsneeds no API and is always fine. This is the default for engagement. - Programmatic listening for product research is a business use of Reddit data. Before building it, file the API-access request (commercial/enterprise ticket type) describing: read-only, named subreddits, 48 h retention, aggregate-only output, LLM analysis but no training. If it's rejected, fall back to manual research. Don't use third-party scraping services to get around the policy; scraping without approval violates it.
- A bot or mod tool for a community we moderate → build it on Devvit, not the Data API.
- Paid acquisition → Ads API + CAPI. No approval gate.
Security
- All credentials (client id/secret, password, refresh token, conversion token, Ads app secret) live server-side only: vault /
.env.local/ Vercel env vars, never aNEXT_PUBLIC_*var. Do Reddit calls from API routes or background jobs. - Never log tokens. Treat refresh and conversion tokens like passwords. Hash emails/phones before sending to CAPI.
Culture & ToS (this matters most)
- Be genuinely helpful first; a link is welcome only when it answers the question. Overt marketing, repeated drops of the same link, and thin self-promo get removed and can ban the account.
- No sockpuppets, no vote manipulation, no astroturfing. One authentic account. Respect each subreddit's self-promotion rules (a common norm: well under ~10% of activity) and check
post_requirements. - Any automated account must carry the App label and do nothing but its app job.
AI routing (ties to the AI Routing Policy)
- Off-platform (our servers, approved Data API data): pipe titles/bodies into Claude for theme clustering and pain-point ranking (
examples/cluster-themes.ts,claude-opus-5-5). Use OpenAI structured output only if strict per-thread JSON tags are needed. Never train or fine-tune on Reddit data. - Inside Devvit apps Claude is not allowed. Only OpenAI and Gemini are approved LLMs there, so a Devvit feature that needs an LLM must use OpenAI (our secondary provider) and must pass App Review.
Payments
- Reddit is not a payment rail for us. Stripe stays the default for codeAmani products (M-Pesa only for Kenya-targeted projects), but Devvit apps cannot link users out to pay, so don't put Stripe or M-Pesa checkout inside a Devvit app. Use CAPI to report Stripe-confirmed purchases (
PURCHASEwithvalue/currency).
Market fit (US-first, Kenya per project)
- Default monitoring and ad targeting to US communities, e.g.
r/SaaS,r/smallbusiness,r/Entrepreneur,r/webdev. - For Kenya-targeted projects,
r/Kenyaandr/Nairobiare useful for validating M-Pesa and low-bandwidth assumptions. Read them manually unless an approved client covers them. Check Reddit Ads' country targeting and audience estimates before budgeting a Kenya campaign; WhatsApp and local channels usually come first for those projects.
Official docs:
- https://support.reddithelp.com/hc/en-us/articles/42728983564564-Responsible-Builder-Policy
- https://support.reddithelp.com/hc/en-us/articles/16160319875092-Reddit-Data-API-Wiki
- https://support.reddithelp.com/hc/en-us/articles/14945211791892-Developer-Platform-Accessing-Reddit-Data
- https://www.redditinc.com/policies/data-api-terms
- https://www.reddit.com/dev/api
- https://github.com/reddit-archive/reddit/wiki/OAuth2
- https://developers.reddit.com/docs/
- https://developers.reddit.com/docs/devvit_rules
- https://ads-api.reddit.com/docs/v3/
- https://ads-api.reddit.com/docs/v3/guides/programs/capi/direct-integration
- https://praw.readthedocs.io/