Reddit API Documentation

Build, grow, and learn with the Reddit API

Overview

The Reddit API allows developers to access and interact with Reddit's vast community-driven platform. With this API, you can retrieve posts, comments, and other content, as well as perform actions like posting, voting, and moderating.

Note: To use the Reddit API, you need to register your application and obtain OAuth2 credentials. Make sure to review and comply with Reddit's API Terms of Use.

Key Features

Getting Started

  1. Create a Reddit account if you don't have one
  2. Register your application at https://www.reddit.com/prefs/apps
  3. Obtain your client ID and client secret
  4. Choose an authentication flow (script, web app, or installed app)
  5. Start making API calls!
Register Your App

Authentication

Reddit API uses OAuth 2.0 for authentication. You'll need to obtain an access token to make API calls.

OAuth Flow

  1. Direct user to authorization URL
  2. User grants permission
  3. Reddit redirects back to your app with an authorization code
  4. Exchange the code for an access token
  5. Use the access token to make API requests

# Example OAuth flow using Python and PRAW (Python Reddit API Wrapper)
import praw

reddit = praw.Reddit(client_id='YOUR_CLIENT_ID',
                     client_secret='YOUR_CLIENT_SECRET',
                     user_agent='YOUR_USER_AGENT',
                     redirect_uri='YOUR_REDIRECT_URI')

# Generate the authorization URL
print(reddit.auth.url(['identity', 'read', 'submit'], '...', 'permanent'))

# After user grants permission and you receive the code...
reddit.auth.authorize(code)

# Now you can make API calls
for submission in reddit.subreddit('AskReddit').hot(limit=10):
    print(submission.title)
    

Core API Endpoints

GET /r/{subreddit}/hot

Get hot posts from a subreddit


GET https://oauth.reddit.com/r/AskReddit/hot
Authorization: bearer YOUR_ACCESS_TOKEN
User-Agent: YOUR_USER_AGENT
      

POST /api/submit

Submit a new link or text post


POST https://oauth.reddit.com/api/submit
Authorization: bearer YOUR_ACCESS_TOKEN
User-Agent: YOUR_USER_AGENT

kind=self&sr=AskReddit&title=Your%20post%20title&text=Your%20post%20content
      

POST /api/vote

Cast a vote on a submission or comment


POST https://oauth.reddit.com/api/vote
Authorization: bearer YOUR_ACCESS_TOKEN
User-Agent: YOUR_USER_AGENT

dir=1&id=t3_abcdef
      

Rate Limits

Reddit imposes rate limits to ensure fair usage across all developers. These limits may vary based on your app's OAuth2 client type and the specific endpoint.

OAuth Client Type Rate Limit
Script 60 requests per minute
Web App 30 requests per minute
Installed App 10 requests per minute

Note: Exceeding these rate limits will result in HTTP 429 (Too Many Requests) errors. Implement proper error handling and respect these limits in your applications.

Best Practices

Support and Resources