Back to APIsReddit
SocialOAuth 2.0
Access Reddit content — browse subreddits, read posts and comments, search across the platform, and authenticate users via OAuth.
Base URL
https://www.reddit.comsubredditspostscommentsOAuthsearch
Endpoints
GET
/r/{subreddit}/top.jsonFetch top posts from a subreddit.
const response = await fetch("https://www.reddit.com/r/programming/top.json?limit=10", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
});
const data = await response.json();
console.log(data);Response Preview
{
"data": {
"children": [{
"data": {
"title": "I built X in Y days",
"score": 14200,
"url": "https://example.com",
"num_comments": 432
}
}]
}
}