Skip to content

A simple wrapper for fetching information from reddit posts.

License

Notifications You must be signed in to change notification settings

LilyAsFlora/reddit-fetch

Repository files navigation

reddit-fetch

Downloads Minified size Version License

NPM

A simple, fast wrapper for fetching information from reddit posts.

Status

This package is deprecated, and I'm no longer fixing bugs. Please use justreddit instead.

You can fork the project if you wish to develop it further.

Usage & Example

const redditFetch = require('reddit-fetch');

redditFetch({

    subreddit: 'all',
    sort: 'hot',
    allowNSFW: true,
    allowModPost: true,
    allowCrossPost: true,
    allowVideo: true

}).then(post => {
    console.table(post);
});

Options

FIELD TYPE DESCRIPTION DEFAULT
subreddit string an existing reddit community N/A
sort ?string a valid reddit sorting option 'top'
allowNSFW ?boolean whether or not the returned post can be marked as NSFW false
allowModPost ?boolean whether or not the returned post can be distinguished as a mod post false
allowCrossPost ?boolean whether or not the returned post can be a crosspost false
allowVideo ?boolean whether or not the returned post can be a video false

Function details

  • Returns a promise that resolves to a JSON object (Promise<object>).
  • By default, the Reddit JSON API should not return any removed or deleted posts.
  • Unhandled rejections can be caught and handled:
...
}).then(post => {
    // Use post data
}).catch(e => {
    console.error(`Promise rejection: ${e}`);
});

Additional Links


Made with <3 by Lily :)

About

A simple wrapper for fetching information from reddit posts.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published