APIYard
Back to APIs
SocialOAuth 2.0

Reddit

Access Reddit content — browse subreddits, read posts and comments, search across the platform, and authenticate users via OAuth.

Base URL

https://www.reddit.com
subredditspostscommentsOAuthsearch

Endpoints

GET/r/{subreddit}/top.json

Fetch 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
      }
    }]
  }
}