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/web 0.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-Labs account (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

Resource URL
Responsible Builder Policy (who may access data, and how) https://support.reddithelp.com/hc/en-us/articles/42728983564564-Responsible-Builder-Policy
Data API Wiki (rules, User-Agent, rate limits, deletion) https://support.reddithelp.com/hc/en-us/articles/16160319875092-Reddit-Data-API-Wiki
Developer Platform & Accessing Reddit Data (FAQ: commercial use, fees, AI) https://support.reddithelp.com/hc/en-us/articles/14945211791892-Developer-Platform-Accessing-Reddit-Data
Data API Terms (last revised 2026-07-20) https://www.redditinc.com/policies/data-api-terms
Developer Terms https://www.redditinc.com/policies/developer-terms
API access request form https://support.reddithelp.com/hc/en-us/requests/new?ticket_form_id=14868593862164
Live API reference https://www.reddit.com/dev/api
OAuth2 flow (legacy archive wiki, still linked by Reddit) https://github.com/reddit-archive/reddit/wiki/OAuth2
Devvit docs / rules / changelog https://developers.reddit.com/docs/ · https://developers.reddit.com/docs/devvit_rules · https://developers.reddit.com/docs/changelog
Ads API v3 reference + OpenAPI spec https://ads-api.reddit.com/docs/v3/ · https://ads-api.reddit.com/api/v3/openapi.json
Conversions API direct integration https://ads-api.reddit.com/docs/v3/guides/programs/capi/direct-integration
PRAW (Python wrapper) https://praw.readthedocs.io/

The archive wiki is stale in places. reddit-archive/…/wiki/API still 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):

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 like Python/urllib or Java "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_code flow with duration=permanent and 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_requirements returns 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

Conversions API (CAPI v3)

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


codeAmani notes

Access decision (do this first)

Security

Culture & ToS (this matters most)

AI routing (ties to the AI Routing Policy)

Payments

Market fit (US-first, Kenya per project)

Official docs: