1.0.3 • Published 4 years ago

get-reddit v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

get-reddit

npm version downloads install size license dependencies

  Get random Reddit posts from a specified Subreddit extremely simple! Here's how it works:

Installation

npm i get-reddit --save

Options

You can use any of these options when getting a post:

  • searchLimit -> number: Number of posts to fetch for selection. (If this is too big, the request will have a significant delay)
  • imageOnly -> boolean: Determines if the post must come with an image
  • allowNSFW -> boolean: Determines if NSFW posts are allowed

JavaScript usage

const getReddit = require('get-reddit');

// Create options
let options = {
  imageOnly: true,
  allowNSFW: false,
};

/*
Get a random post from r/memes, 
returning only an image, and not
allowing NSFW posts
*/
getReddit('memes', options)
  .then((post) => {
    console.log(`Post found: ${post.title}`);
  })
  .catch((err) => {
    console.error(err);
  });

TypeScript usage

import getReddit, { SearchOptions } from 'get-reddit';

// Create options
let options: SearchOptions = {
  imageOnly: true,
  allowNSFW: false,
};

/*
Get a random post from r/memes, 
returning only an image, and not
allowing NSFW posts
*/
getReddit('memes', options)
  .then((post) => {
    console.log(`Post found: ${post.title}`);
  })
  .catch((err) => {
    console.error(err);
  });
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago