Skip to content

astridlol/redditjs

Repository files navigation

RedditJS

Retrieve stories instantly from reddit.

Downloads

Installation

npm install --save @kindl3d/reddit.js

or

npm install --save https://github.com/k1ndled/redditjs

Usage

Reddit.js is fairly simple to use

To get the post object:

const { getPost } = require('@kindl3d/reddit.js');

getPost("entitledparents").then(data =>{
	console.log(data);
})

This outputs the following object:

{
  "title": "Post title",
  "text": "Post text",
  "flairText": 'Flair text',
  "author": 'Author',
  "subreddit": 'r/example',
  "permalink": 'https://www.reddit.com/r/emample/comments/xxxxxxx/xxxxxxxxxxx',
  "created": '2021-01-23 00:02:34.000',
  "created_utc": '2021-01-22 16:02:34.000',
  "nsfw": false
}

v2

Now, this module uses the /random endpoint from Reddit thanks to a pull request from @ImAARIX.

Breaking changes

  1. URL is no longer apart of the Post object, you can just use permalink.
  2. Function was renamed to getPost instead of reddit to make things more simple.

About

redditjs - get random reddit posts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published