Build, grow, and learn with the Reddit API
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.
Reddit API uses OAuth 2.0 for authentication. You'll need to obtain an access token to make API calls.
# 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)
Get hot posts from a subreddit
GET https://oauth.reddit.com/r/AskReddit/hot
Authorization: bearer YOUR_ACCESS_TOKEN
User-Agent: YOUR_USER_AGENT
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
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
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.