Skip to content

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

License

Notifications You must be signed in to change notification settings

nekos-best/nekos-best.js

Repository files navigation

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

Caution

Items annonated with @package and @private in their documentation are considered implementation details and are therefore subject to change without warning.

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(
    "************************.******.***************************",
);

Migrations

Follow the migration guide.

About

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

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •