Giter VIP home page Giter VIP logo

nekos-best.js

High quality nekos and role-playing GIFs powered by nekos.best! This is the official API wrapper for the nekos.best's API with built-in TypeScript typings. Node LTS is recommended.

Join the official Discord server here

Installation

npm install nekos-best.js | yarn add nekos-best.js | pnpm install nekos-best.js

Usage

import { Client, fetchRandom } from "nekos-best.js";

// You can use the `fetchRandom()` function to fetch a random neko.
console.log(await fetchRandom("neko")); // { results: [{ artist_href: '···', artist_name: '···', source_url: '···', url: 'https://nekos.best/api/v2/neko/XXXXX-XXXXX.png' }] }

// Alternatively, you can initialize a new client which offers more features.
const nekosBest = new Client();

// Such as the `<Client>.fetch()` method.
console.log(await nekosBest.fetch("neko", 1)); // { results: [{ artist_href: '···', artist_name: '···', source_url: '···', url: 'https://nekos.best/api/v2/neko/XXXXX-XXXXX.png' }] }
console.log(await nekosBest.fetch("hug", 10)); // { results: [{ artist_href: '···', artist_name: '···', source_url: '···', url: 'https://nekos.best/api/v2/hug/XXXXX-XXXXX.gif' }, ···] }

// Or the `<Client>.fetchFile()` method to get a single file.
console.log(await nekosBest.fetchFile("neko")); // { artist_href: '···', ···, data: <Buffer> }

Build a simple Discord Bot with discord.js

import { Client as DiscordClient } from "discord.js";
import { Client } from "nekos-best.js";

const discordClient = new DiscordClient();
const nekosBest = new Client();

discordClient.on("messageCreate", async (message) => {
    if (message.author.bot) return;

    if (message.content.startsWith('!neko')) {
        message.channel.send((await nekosBest.fetch("neko", 1)).results[0].url);
    }
})

discordClient.login("************************.******.***************************");

Migrate from 5.X.X to 6.X.X

❗ For the TypeScript users, the type NbEndpointMetadata will be removed in the 7.X.X version due to recent API changes

<Client>.fetchRandom() & <Client>.fetchMultiple() methods have been removed in favor of the <Client>.fetch(category, amount) method

const nekosBest = new Client();

- nekosBest.fetchRandom("neko")
+ nekosBest.fetch("neko", 1)
const nekosBest = new Client();

- nekosBest.fetchMultiple("neko", 15)
+ nekosBest.fetch("neko", 15)

The <Client>.init() method has been removed

const nekosBest = new Client();

- await nekosBest.init();

Migrate from 4.X.X to 5.X.X

The fetchNeko(category) function has been removed in favor of the <Client>.fetchRandom() method and its shortcut fetchRandom()

- fetchNeko('category')
+ const nekosBest = new Client();
+
+ nekosBest.fetchRandom('category')
- fetchNeko('category')
+ fetchRandom('category')

The optional parameter amount of the fetchNeko() function has been removed in favor of the <Client>.fetchMultiple() method

- fetchNeko('category', 15)
+ const nekosBest = new Client();
+
+ nekosBest.fetchMultiple('category', 15)

Other Changes

  • The optional options max and min of the fetchNeko() function have been removed

nekos.best API's Projects

docs icon docs

nekos.best's documentation repository.

nekos-best.js icon nekos-best.js

JavaScript API wrapper for the https://nekos.best API with TS typings

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.