Socket
Socket
Sign inDemoInstall

imageapi.js

Package Overview
Dependencies
7
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    imageapi.js

The best way to get random posts from subreddits


Version published
Weekly downloads
34
increased by21.43%
Maintainers
1
Install size
488 kB
Created
Weekly downloads
 

Readme

Source

ImageAPI.JS

npm stars contributors

What?

ImageAPI is a wrapper for ImageAPI.fionn.live - a fast API for fetching a random post from a subreddit.

How?

The main API is just fetching random data from the reddit API allowing for us to send the data we think is valid back to the user making the request.

Is it fast?

The API is as fast as the Reddit API is. We can't speed it up, but, we have optimized the code on the backend to make it as fast as possible.

Examples:

✌ JS example
const api = require('imageapi.js');
(async () => {
	const img = await api('subreddit');
	console.log(img); // Logs the image
	const advanced = await api.advanced('subreddit');
	console.log(advanced); // Logs an object. Not all data may be present.
	const stats = await api.stats();
	console.log(stats); // Logs an object.
})();
😎 TS example
import api, { stats, advanced } from 'imageapi';
(async () => {
	const img = await api('subreddit');
	console.log(img); // Logs the image
	const advanced = await api.advanced('subreddit');
	console.log(advanced); // Logs an object. Not all data may be present.
	const stats = await api.stats();
	console.log(stats); // Logs an object.
})();

Sort types, top & new.

If you want to get a 'new' or 'top' post, you can specify a sort type. The valid ones are top & new.

You specify this as a second paramter in the advanced & default function. For example:

api.advanced('meme', 'top'); // Gets a 'top' meme
api.advanced('meme', 'new'); // Gets a 'new' meme
api.advanced('meme', 'this-is-invalid'); // Errors, returns a rejected promise

Keywords

FAQs

Last updated on 30 May 2021

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