1.1.4 • Published 4 years ago
redditdata v1.1.4
redditdata
A simple tool to get data from reddit
Installation
> npm i redditdataUsage
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 to25): The maximum number of posts to get. Sometimes may not get so many posts because they don't exist. - Stickies (
boolean, defaults totrue): Whether or not to allow sticky/pinned posts. - Videos (
boolean, defaults totrue): Whether or not to allow video posts. - NSFW (
boolean, defaults totrue): Whether or not to allow nsfw posts. - Spoiler (
boolean, defaults totrue): Whether or not to allow spoiler posts. - OnlyAwarded (
boolean, defaults tofalse): Whether or not to only get posts that have been awarded. - MinScore (
integer, defaults to0): 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 to25): 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 totrue): Whether or not to allow sticky/pinned posts. - Videos (
boolean, defaults totrue): Whether or not to allow video posts. - NSFW (
boolean, defaults totrue): Whether or not to allow nsfw posts. - Spoiler (
boolean, defaults totrue): Whether or not to allow spoiler posts. - OnlyAwarded (
boolean, defaults tofalse): Whether or not to only get posts that have been awarded. - MinScore (
integer, defaults to0): The minimum score posts need to have in order to get them.