Socket
Socket
Sign inDemoInstall

reddit-posts

Package Overview
Dependencies
7
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reddit-posts

Get a random posts from reddit with data!


Version published
Weekly downloads
4
decreased by-55.56%
Maintainers
1
Install size
501 kB
Created
Weekly downloads
 

Readme

Source

Introduction

reddit-posts is a package to get a random reddit post data. In addition, it makes for programmer an easier work.

NOTE: This package is not made by reddit. It is just unofficial package to get random post data. It is legal to use.

Installing package

This is recommended command to execute in terminal to install package:

npm i reddit-posts@latest

Any command that install package is okay to run.

Requirements

minimum requirements:

  • Having Node.js v12 or newer versions installed in your device.

maximum requirements:

  • Having Node.js v16 or newer versions installed in your device.

Example

Here is an example for this package:

const RandomReddit = require("reddit-posts");

RandomReddit.GetRandompost("aww").then(async (data) => {
 	console.log(data.title); //returns title of a post. For example: "This is just an example!"
    console.log(data.SubredditPrefix); //return: r/aww
    console.log(data.IsNSFW); //return: false. If it is a NSFW post it will return true.
    console.log(data.UpVotes); //return: 919. Any number of post upvotes.
    console.log(data.ImageURL); //returns Image URL. For example: https://i.imgur.com/Example.jpg
    console.log(data.selftext); //returns selftext or description of a post. (String)
    console.log(data.url); //returns URL of post. For example: https://reddit.com/r/aww/comments/random/example/
    console.log(data.CommentsNum) // return: 4 or any number. It is for total comments number.
    console.log(data.Author); // Get an author username which returns a string.
    console.log(data.DownVotes); // DownVotes is just like data.UpVotes example and it returns number.
});

If you are using this package in async function. I recommend you to use await. For example:

const PostData = await RandomReddit.GetRandompost("aww");
console.log(PostData.url);

I wish that example helps.

NOTE: About GetRandomHotpost() and GetRandomNewpost() function codes are just same as GetRandompost() function. You all gotta do is just replacing function names.

What's new in 1.0.4

  • Added new values to those functions: score.
  • Added a new function and it is GetRandomNewpost();

Keywords

FAQs

Last updated on 27 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc