# subredditapi.js

> A simple wrapper for the Reddit API

Latest version **1.0.0** (published 2020-12-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install subredditapi.js
pnpm add subredditapi.js
yarn add subredditapi.js
bun add subredditapi.js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-12-26 |
| First published | 2020-12-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Shamil |
| Maintainers | 11-shamil |
| Keywords | api, reddit, redditapi, image, reddit, image, subreddit |

## Links

- npm: https://www.npmjs.com/package/subredditapi.js
- Repository: https://github.com/Shamil-FD/SubRedditAPI.JS
- Homepage: https://github.com/Shamil-FD/SubRedditAPI.JS#readme
- Issues: https://github.com/Shamil-FD/SubRedditAPI.JS/issues
- npm.io page: https://npm.io/package/subredditapi.js

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-12-26

## README

# SubRedditAPI.JS

A simple API module to fetch images, posts from reddit.

**If you have any issues, just make a new PR on the repo or DM me on Discord Shamil#0810**

## Setup and Configuration

Initialisation
```javascript
const { newPost, stats, random, rising, top, search } = require("subredditapi.js");
```


## An example of what could return with your api call
```javascript
{
  upvotes: 70435,
  author: 'Thelazytimetraveller',
  title: 'Every cloud has a silver lining',
  url: 'https://reddit.com/r/dankmemes/comments/kjnssq/every_cloud_has_a_silver_lining/',
  subreddit: 'dankmemes',
  image: 'https://i.redd.it/l116ve0ek7761.jpg',
  upvoteRatio: 0.89,
  nsfw: false,
  video: false,
  created: '2020-12-25T06:06:35.000Z',
  totalAwardsReceived: 303,
  commentsCount: 280,
  description: ''
}
```

## To get a random post from a subreddit

```javascript
(async() => {

let post = await random("subreddit");
console.log(post) // Logs all the stuff returned with the post;

})();
```

## To get a top voted post from a subreddit
```javascript
(async() => {

let post = await top("subreddit", "sortType"); // You can sort the sorting type with 'hour', 'day', 'week', 'month', 'year', 'all' to sort by top posts of that particular time limit
console.log(post);
})();
```

## To get a new post from a subreddit
```javascript
(async() => {

let post = await newPost("subreddit");
console.log(post);

})();
```

## To get a rising post from a subreddit
```javascript
(async() => {

let post = await rising("subreddit");
console.log(post);

})();
```

## To search up a post
```javascript
(async() => {

let post = await search("query");
console.log(post);

})();
```

## To get the total amount of requests made on the API
```javascript
(async() => {

let totalRequests = await stats();
console.log(totalRequests);

})()
```

---
_Source: https://npm.io/package/subredditapi.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
