Giter VIP home page Giter VIP logo

imageapi.js's Introduction

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

imageapi.js's People

Contributors

milo123459 avatar suyashtnt avatar

Stargazers

Hudr avatar Mohamed Haitham Ghasim avatar  avatar Abisha_Evan avatar Radicalz avatar Shamil avatar ForSomeCodezYT avatar Costi avatar

Watchers

James Cloos avatar  avatar  avatar

imageapi.js's Issues

Multiple Subreddits?

Is there a way to put multiple subreddits and not only one like:

let img = await imageapi("Kitsunemimi", "memes", "dankmemes' true);

Also, if you want the image to actually be displayed, all you have to do is add, message.channel.send(img); on top of console.log(img);

hey follow semver

1.1.6 should be 2.0.0 as it had a beraking change. Pls follow semver

It doesn't work.

Everytime I try to use it, it returns a FetchError.

If needed, I'll send the exact error message.

Is there any way to check if a meme is NSFW before it errors?

Hi, is there any way to check if a post from reddit is NSFW using this API before an error appears?
I catch the error but what if there's a different error? This also makes the process slower overall.
If you can't do this, it would be nice if it was included in the next release.

Invalid Subreddit

When adding an nsfw subreddit there's an error

(node:13764) UnhandledPromiseRejectionWarning: TypeError: Error, probably due to an invalid subreddit!

Logging

Is there any way i can possibly disable the [IMAGEAPI.JS]: TOOK 706MS TO RECIEVE YOUR IMAGE. SUBREDDIT: dank IMAGE: http://imgur.com/73UYwcp.png REQUEST: 69921 message whenever is use this API?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.