npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redditwrap.js

v7.0.0

Published

Unofficial Reddit Library for Node.Js

Downloads

47

Readme

reddit.js

npm npm Travis branch Known Vulnerabilities

Events

Methods

Types


I will not be responsible for how you use this wrapper!

Install: npm install redditwrap.js

Reddit.js is a promise and event based library for interacting with Reddit!

Getting started with making a basic post:

const redditjs = require('reddit.js')
let reddit = new redditjs({
  useragent: USERAGENT,
  username: USERNAME,
  password: PASSWORD,
  clientID: YOUR-SCRIPT-TYPE-APP-ID,
  clientSecret: YOUR-SCRIPT-TYPE-APP-SECRET
})
reddit.on('ready', () =>{
  reddit.submitTextPost('test', 'Hello World!', 'My first text post!')
    .then(data =>{
      console.log(data)
    })
    .catch(err => {
      console.log(err)
    })
})

reddit.on('message', message =>{
  message.reply("beep boop!")
})

Documentation

Events

comment

Emmitted when there is a new comment. Listens to r/all. (Needs a bit of fixing. Some subreddits might not appear for some reason.)

Parameters

commentData


message

Emitted when client receives a new notification in inbox.

Parameters

inbox


ready

Emitted when the client is ready.


submission

Emitted when there is a new post on reddit. Listen's to all posts.

Paramaters

postData


Methods

getCurrentUser()

Gets details about the current logged on user.

Returns

  • Promise: userData

getFriends()

Returns an array of objects of the friends the authenticated user has. Each object has name and created.

Returns

  • Promise: friendsList

getInbox([option])

Returns an array of objects of your mail.

Arguments

option: A filter. One of unread, sent. Defaults to inbox.

Returns

  • Promise: inbox

getPosts(subreddit, [sort])

Get submissions on a subreddit based on sort.

Arguments

  • sort: One of hot, new, rising, controversial, random, top.

Returns

  • Promise: postData

getUser(username)

Retrieves information on a user.

Arguments

  • username: The username of the user.

Returns

  • Promise: userData object.

login(credentials)

This method doesn't log you in. It just specifies the details the wrapper will use to authenticate your actions.

Arguments

  • credentials: An object containing username, password, clientID and clientSecret.

searchPost(id)

Search for a post by ID/fullname.

Arguments

  • id: The fullname of the post without t3_

Returns

  • Promise: postData

submitComment(targetID, comment)

Reply to a post/comment.

Arguments

targetID: The fullname of the target. Please refer to Reddit documentation if you don't know what that is. comment: The contents of your comment as a string.


submitTextPost(subreddit, title, content)

Submit a new text/selfpost to a subreddit.

Arguments

  • subreddit: The subreddit you'd like to post in.
  • title: The title of the post.
  • content: The content of your post.

Returns

  • Promise: successData

Types

commentData

Properties

  • subreddit_id
  • approved_at_utc
  • edited
  • banned_by
  • removal_reason
  • link_id
  • link_author
  • likes
  • replies
  • user_reports
  • saved
  • id
  • banned_at_utc
  • gilded
  • archived
  • report_reasons
  • author
  • num_comments
  • can_mod_post
  • parent_id
  • score
  • approved_by
  • over_18
  • collapsed
  • body
  • link_title
  • author
  • downs
  • is_submitter
  • collapsed_reason
  • body_html
  • distinguished
  • quarantine
  • can_gild
  • subreddit
  • name
  • score_hidden
  • num_reports
  • link_permalink
  • stickied
  • created
  • author_flair_text
  • link_url
  • created_utc
  • subreddit_name_prefixed
  • controversiality
  • mod_reports
  • subreddit_type
  • ups

Methods

  • submitComment(comment)

        Reply to the comment.

        comment: The content of your reply.


friendsList

Properties

  • username
  • id
  • dateAdded

inbox

Properties

  • type
  • subject
  • body
  • created
  • parentId
  • id
  • author
  • subreddit

Methods

  • reply(text)

        Reply to the target inbox object.

        text: Your reply.


postData

Properties

  • domain
  • approved_at_utc
  • banned_by
  • media_embed
  • thumbnail_width
  • subreddit
  • selftext_html
  • selftext
  • likes
  • suggested_sort
  • user_reports
  • secure_media
  • link_flair_text
  • id
  • banned_at_utc
  • view_count
  • archived
  • clicked
  • report_reasons
  • title
  • media
  • mod_reports
  • can_mod_post
  • author_flair_text
  • score
  • approved_by
  • over_18
  • hidden
  • preview
  • thumbnail
  • subreddit_id
  • edited
  • link_flair_css_class
  • author_flair_css_class
  • contest_mode
  • gilded
  • downs
  • brand_safe
  • secure_media_embed
  • saved
  • removal_reason
  • post_hint
  • stickied
  • can_gild
  • thumbnail_height
  • parent_whitelist_status
  • name
  • spoiler
  • permalink
  • subreddit_type
  • locked
  • hide_score
  • created
  • url
  • whitelist_status
  • quarantine
  • author
  • created_utc
  • subreddit_name_prefixed
  • ups
  • num_comments
  • is_self
  • visited
  • num_reports
  • is_video
  • distinguished

Methods

  • submitComment(comment)

        Comment on the returned post.

        comment: The content of your reply.

  • save()

        Save the returned post.


userData

Properties

  • username
  • id
  • isFriend
  • joinedAt
  • commentKarma
  • linkKarma
  • subreddit
  • client

Methods

  • friend()

        Adds the user as friend.

  • unfriend()

        Unfriends the user.