UNPKG

nekos-best.js

Version:

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

70 lines (69 loc) 3.19 kB
declare const IMAGE_CATEGORIES: readonly ["kitsune", "neko", "husbando", "waifu"]; declare const GIF_CATEGORIES: readonly ["baka", "bite", "blush", "bored", "cry", "cuddle", "dance", "facepalm", "feed", "happy", "highfive", "hug", "kiss", "laugh", "pat", "pout", "shrug", "slap", "sleep", "smile", "smug", "stare", "think", "thumbsup", "tickle", "wave", "wink", "kick", "handhold", "punch", "shoot", "yeet", "poke", "nod", "nom", "nope", "handshake", "lurk", "peck", "yawn", "angry", "run"]; 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 = { artist_href?: string; artist_name?: string; source_url?: string; anime_name?: 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;