UNPKG

nekos-best.js

Version:

The official JavaScript wrapper for the https://nekos.best API with TypeScript typings.

74 lines (73 loc) 3.42 kB
declare const IMAGE_CATEGORIES: readonly ["kitsune", "neko", "husbando", "waifu"]; declare const GIF_CATEGORIES: readonly ["angry", "baka", "bite", "bleh", "blowkiss", "blush", "bonk", "bored", "carry", "clap", "confused", "cry", "cuddle", "dance", "facepalm", "feed", "handhold", "handshake", "happy", "highfive", "hug", "kabedon", "kick", "kiss", "lappillow", "laugh", "lurk", "nod", "nom", "nope", "nya", "pat", "peck", "poke", "pout", "punch", "run", "salute", "shake", "shocked", "shoot", "shrug", "sip", "slap", "sleep", "smile", "smug", "spin", "stare", "tableflip", "teehee", "think", "thumbsup", "tickle", "wag", "wave", "wink", "yawn", "yeet"]; type Nullable<T> = T | undefined | null; export type NbCategories = (typeof GIF_CATEGORIES)[number] | (typeof IMAGE_CATEGORIES)[number]; /** @deprecated This will be removed in the next major version */ export type NbEndpointMetadata = Record<string, { format: string; min: string; max: string; }>; export type NbIndividualResponse = { anime_name?: string; artist_href?: string; artist_name?: string; dimensions: { width: number; height: number; }; source_url?: string; url: string; }; export type NbResponse = { results: NbIndividualResponse[]; }; export type NbBufferResponse = NbIndividualResponse & { data: Buffer; }; export type RatelimitHandleMode = "sleep" | "throw"; export interface ClientOptions { ratelimitHandleMode: RatelimitHandleMode; } /** * A quick function to fetch a random file URL along with its metadata (if available). * * If you are going to call this function multiple times, it's better to initialize a new `Client` instead. * * @param category The category to fetch the file URL from. If omitted, it picks a random category. */ export declare function fetchRandom(category?: NbCategories): Promise<NbResponse>; export declare class Client { #private; constructor(clientOptions?: Partial<NbBufferResponse>); /** * Fetch and download a random file with its metadata (if available). * For more advanced options, you should use the `Client.fetch()` method and * fetch the file by yourself. * * Refer to the documentation for more details: https://docs.nekos.best/api/endpoints.html#get-categoryfilenameformat * * @param category The category to download from. */ fetchFile(category?: Nullable<NbCategories>): Promise<NbBufferResponse>; /** * Fetch multiple assets with their metadata (if available). * * Refer to the documentation for more details: https://docs.nekos.best/api/endpoints.html#get-categoryamountx * * @param category Category of assets. Set to `null` to pick a random category. * @param amount The amount of assets. Refer to the documentation for the limits. */ fetch(category: Nullable<NbCategories>, amount: number): Promise<NbResponse>; /** * Search for assets. * * Refer to the documentation for more details: https://docs.nekos.best/api/endpoints.html#get-searchqueryxtypexcategoryxamountx * * @param query Search query. * @param category Category of assets. Set to `null` to pick a random category. * @param amount The amount of assets. Refer to the documentation for the limits. */ search(query: string, category?: Nullable<NbCategories>, amount?: number): Promise<NbResponse>; } export default Client;