1.0.1 • Published 2 years ago

reddit-json-api v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

reddit-json-api

Simple reddit json api wrapper that able to fetch data without authentication

Installing

npm i reddit-json-api

Usage

  1. Import package
const RedditJsonApi = require('reddit-json-api');
  1. Initialize RedditJsonApi
const reddit = new RedditJsonApi();

Then you can set up the parameters to be sent

reddit
  .setSubReddit('node')
  .setListing('new')
  .setLimit(5)
  .setTimeFrame('day');
  1. After that you can simply get the result by calling getResults()
const data = await reddit.getResults();

It is also possible to immediately construct the parameter

const reddit = new RedditJsonApi({
  subReddit: 'node',
  listing: 'new',
  limit: 5,
  timeFrame: 'day',
});
const data = await reddit.getResults();

Method

ParameterFunctionDescriptionValue accepted
subRedditsetSubRedditSubreddit name without "r/"String
listingsetListingListing type what content will be sorted of available optionsString: controversial, best, hot, new, random, rising, top
limitsetLimitAmount of data to fetch per requestNumber
timeFramesetTimeFrameimeframe of when the post createdString: hour, day, week, month, year, all
1.0.1

2 years ago

1.0.0

2 years ago