redditdata

1.1.4 • Public • Published

redditdata

A simple tool to get data from reddit

Installation

> npm i redditdata

Usage

Getting posts from a subreddit

rd.getSubreddit(subreddit, opts)
const rd = require("redditdata")

const opts = {
    limit: 25,
    stickies: true,
    videos: true,
    nsfw: true,
    spoiler: true,
    onlyAwarded: false,
    minScore: 0
}

rd.getSubreddit("subreddit", opts)
  .then(response => {
    console.log(response)
  })
  .catch(error => {
    console.log(error)
  })

Opts object

  • Limit (integer, defaults to 25): The maximum number of posts to get. Sometimes may not get so many posts because they don't exist.
  • Stickies (boolean, defaults to true): Whether or not to allow sticky/pinned posts.
  • Videos (boolean, defaults to true): Whether or not to allow video posts.
  • NSFW (boolean, defaults to true): Whether or not to allow nsfw posts.
  • Spoiler (boolean, defaults to true): Whether or not to allow spoiler posts.
  • OnlyAwarded (boolean, defaults to false): Whether or not to only get posts that have been awarded.
  • MinScore (integer, defaults to 0): The minimum score posts need to have in order to get them.

Getting posts and comments from a user

rd.getUser(user, opts)
const rd = require("redditdata")

const opts = {
    limit: 25,        
    type: "all",
    stickies: true,
    videos: true,
    nsfw: true,
    spoiler: true,
    onlyAwarded: false,
    minScore: 0
}

rd.getUser("reddituser", opts)
  .then(response => {
    console.log(response)
  })
  .catch(error => {
    console.log(error)
  })

Opts object

  • Limit (integer, defaults to 25): The maximum number of posts to get. Sometimes may not get so many posts because they don't exist.
  • Type (string, defaults to "all"): The type of data to get.
    • "all": Gets all type of data.
    • "post": Only gets posts.
    • "comment": Only gets comments.
  • Stickies (boolean, defaults to true): Whether or not to allow sticky/pinned posts.
  • Videos (boolean, defaults to true): Whether or not to allow video posts.
  • NSFW (boolean, defaults to true): Whether or not to allow nsfw posts.
  • Spoiler (boolean, defaults to true): Whether or not to allow spoiler posts.
  • OnlyAwarded (boolean, defaults to false): Whether or not to only get posts that have been awarded.
  • MinScore (integer, defaults to 0): The minimum score posts need to have in order to get them.

Readme

Keywords

Package Sidebar

Install

npm i redditdata

Weekly Downloads

2

Version

1.1.4

License

ISC

Unpacked Size

8.95 kB

Total Files

3

Last publish

Collaborators

  • ivancm