Skip to content
exiloniumPublic

About

Reddit Api Server With NO rate limits

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

RedApi

FastAPI proxy for Reddit's JSON API, modeled on Redlib. Works anonymously without a Reddit account.

How it fetches from Reddit

  1. Safari TLS impersonation (curl_cffi): Reddit returns 403 ("Blocked by network security") to standard HTTP clients (httpx, curl, Chrome/Firefox/OkHttp TLS fingerprints). Requests run through a Safari AsyncSession and reroll the Safari profile on fingerprint 403s.
  2. Anonymous OAuth: POST /auth/v2/oauth/access-token/loid with Android device headers (x-reddit-loid, x-reddit-session). If that fails, falls back to solving www.reddit.com's JS challenge for a token_v2 cookie.
  3. GraphQL over HTTP/1.1 (gql.py): Comments, user profiles/listings, and search are blocked on anonymous *.json even with a valid token. Those routes hit https://gql-fed.reddit.com/ over HTTP/1.1 (HTTP/2 returns 403) and map the response to Reddit's JSON shape.
  4. Fallbacks: Retries with backoff on 429/5xx, refreshes token on 401/403, falls through oauth.reddit.com -> www.reddit.com -> old.reddit.com -> REDDIT_COOKIE (if set) -> stale cache.

Run locally

pip install -r requirements.txt
uvicorn main:app --reload --port 8080

Deploy on Render

  • Build Command: pip install -r requirements.txt
  • Start Command: uvicorn main:app --host 0.0.0.0 --port $PORT
  • Environment variables (optional):
    • REDDIT_COOKIE (or REDLIB_REDDIT_COOKIE): Logged-in reddit_session=... cookie string (or bare reddit_session value). Only used as a last-resort fallback if anonymous tiers fail (for example, if Reddit blocks a datacenter IP).
      • How to get it: Log into reddit.com in a browser (use a throwaway account, and don't click Log out afterwards), open DevTools → Application / Storage → Cookies → https://www.reddit.com, and copy the reddit_session value.

Endpoints

Route Description
GET /health Health check
GET /r/{subreddit}/{sort} Subreddit listing (hot, new, top, rising, controversial)
GET /r/{subreddit}/comments/{post_id} Post + comment tree
GET /comments/{post_id} Post + comment tree (short form)
GET /user/{username}/about User profile info
GET /user/{username} Combined user info + listing (sort, limit, after)
GET /user/{username}/{sort} User listing (overview, submitted, comments, upvoted, gilded)
GET /search?q=...&subreddit=... Search, optionally scoped to a subreddit
GET /best Front page listing
GET /raw/{path} Passthrough for any Reddit JSON path

Files

  • config.py — ANDROID_CLIENT_IDS, Safari profiles, Android device/UA lists, REDDIT_COOKIE, timing constants
  • cache.py — In-memory TTL cache (fresh + stale reads, single-process)
  • gql.py — Persisted GraphQL queries (gql-fed.reddit.com) and JSON shaping
  • reddit_client.py — curl_cffi session, OAuth flows, fallback chain
  • main.py — FastAPI routes

About

Reddit Api Server With NO rate limits

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages