Documentation
Deno

Deno

💡

This page is incomplete. To read the complete documentation visit the librarie's homepage.

The nekosapi (opens in a new tab) Deno TypeScript library is an officially supported API warapper for Nekos API, kindly made by SLIME (opens in a new tab).

Source code: deno.land/x (opens in a new tab)

Importing

You can import the library from deno.land/x (opens in a new tab).

// Replace `v1.0.3` with the current library version.
import { Nekos } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts'

Since there are many domains you can use to access the API, the library allows you to select one using NekosUrl.

// Replace `v1.0.3` with the current library version.
import { Nekos, NekosUrl } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts'

Usage

First of all, you'll need to initialize the Nekos() wrapper class.

import { Nekos, NekosUrl } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts'
 
// Both parameters are optional. Defaults to `Nekos(NekosUrl.vercel)`.
const nekos = new Nekos(NekosUrl.nekosapi, '<your-token-here>')

NekosUrl has 3 properties:

They are all redirected to https://v1.nekosapi.com/api, so to avoid an extra request you should use nekosapi.

Get the token's details

This method requires a token.

If you own an access token, you can see it's information using the me() method.

import { Nekos, NekosUrl } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts';
 
const nekos = new Nekos(NekosUrl.nekosapi, '<your-token-here>')
 
nekos.me().then((token) => {
    // Do whatever you want here
})

Get a random image

To get a random image, you can use either randomImage() or randomImages().

Get a random image
import { Nekos } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts';
 
const nekos = new Nekos()
 
// The `categories` parameter is optional. Each item is the name of a
// category that the image must have.
const categories = [
    "Catgirl",
    "Kemonomimi"
]
nekos.randomImage(categories).then((image) => {
    // Do whatever you want here
})
Get many random images
import { Nekos } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts';
 
const nekos = new Nekos()
 
// The `categories` parameter is optional. Each item is the name of a
// category that all the images must have.
const categories = [
    "Catgirl",
    "Kemonomimi"
]
 
// You can change the 25 to whatever amount of images you need
nekos.randomImages(25, categories).then((images) => {
    // Do whatever you want here
})

Get all images

This method requires a token with the image:list scope.

To list all images in the API you'll need to use the images() method.

import { Nekos, NekosUrl } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts';
 
const nekos = new Nekos(NekosUrl.nekosapi, '<your-token-here>')
 
// The first parameter is the limit, the second one is the offset
nekos.images(25, 0).then((images) => {
    // Do whatever you want here
})

Get an image by it's ID

To get an image's details for it's ID, you can use the image().

import { Nekos } from 'https://deno.land/x/nekosapi@v1.0.3/mod.ts';
 
const nekos = new Nekos()
 
nekos.image('<the-image-uuid>').then((image) => {
    // Do whatever you want here
})