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
npm install nekos-best.js | yarn add nekos-best.js | pnpm install nekos-best.js | bun add nekos-best.js
import { Client, fetchRandom } from "nekos-best.js";
// You can use the `fetchRandom()` function to quickly fetch a random result.
console.log(await fetchRandom("neko"));
// Alternatively, you can initialize a new client which offers more features.
const nekosBest = new Client();
// You can configure rate limit handling behavior (default: "sleep").
// "sleep" waits until the rate limit resets, "throw" rejects the promise immediately.
const nekosBestStrict = new Client({ ratelimitHandleMode: "throw" }); // "sleep" (default) | "throw"
// Use the `<Client>.fetch()` method to fetch one or more results from a category.
console.log(await nekosBest.fetch("neko", 1));
console.log(await nekosBest.fetch("hug", 10));
// Use the `<Client>.fetchFile()` method to fetch and download a single file along with its metadata.
console.log(await nekosBest.fetchFile("neko"));
// Use the `<Client>.search()` method to search for results by query.
console.log(await nekosBest.search("cat", "neko", 5));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(
"************************.******.***************************",
);Please refer to MIGRATION.md.