Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.
/ imageapi.js Public archive

The fast way of grabbing random images from subreddits.

License

Notifications You must be signed in to change notification settings

Milo123459/imageapi.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

The fast way of grabbing random images from subreddits.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published