Reddit's public API without authentication
If you want to use this in your project, there are prebuilt versions available.
- geddit.min.js - Minified version
Import via the GitHub Pages URL:
https://kaangiray26.github.io/geddit/geddit.min.js
import { Geddit } from './geddit.js';
const g = new Geddit();
// Get the top 10 posts from r/AskReddit
let posts = await g.getTop('AskReddit', {
limit: 10
})
console.log(posts);
Reddit has an undocumented feature that allows you to get data from their servers as RSS/JSON feeds. Geddit wraps around several endpoints to make it easier to get data from Reddit. This means that you can use Geddit to get data from Reddit without authentication, which is only suitable for getting public data.
- No authentication required
- Get data without dealing with application IDs and secrets
- NSFW content is allowed
Here are the methods that are available in Geddit. All methods return a promise that resolves to the data from Reddit. Methods are categorized by the source of the data.
- getSubmission(ID)
- getSubmissionComments(ID, options)
- getHot(subreddit, options)
- getBest(subreddit, options)
- getTop(subreddit, options)
- getNew(subreddit, options)
- getRising(subreddit, options)
- getControversial(subreddit, options)
- getDomainHot(domain, options)
- getDomainBest(domain, options)
- getDomainTop(domain, options)
- getDomainNew(domain, options)
- getDomainRising(domain, options)
- getDomainControversial(domain, options)
- getSubreddit(subreddit)
- getSubredditComments(subreddit, options)
- getSubredditRules(subreddit)
- getSubredditModerators(subreddit)
- getSubredditWikiPages(subreddit)
- getSubredditWikiPage(subreddit, page)
- getSubredditWikiPageRevisions(subreddit, page)
- getPopularSubreddits(options)
- getNewSubreddits(options)
- getPremiumSubreddits(options)
- getDefaultSubreddits(options)
- getUser(username)
- getUserComments(username, options)
- getUserSubmission(username, options)
- getPopularUsers(options)
- getNewUsers(options)
- searchAll(query, subreddit, options)
- searchSubreddits(query, options)
- searchUsers(query, options)
- getLiveThread(ID)
- getLiveThreadUpdates(ID, options)
- getLiveThreadContributors(ID, options)
- getLiveThreadDiscussions(ID, options)
- getLiveThreadsNow(options)
If you discover a new endpoint that is not in the list above, feel free to open an issue or a pull request.
This project is an open-source software. The projects is nothing more than a simple example of how to use Reddit's RSS/JSON feeds to build a library and it is not intended to be used instead of the Reddit API. Instead, use the official Reddit app or any other Reddit client that uses Reddit's API for full functionality. No data is collected from the users and no profit is made from the library. Developers are not responsible for any damage caused by the library. Use at your own risk.