This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit abe0a0e
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Nekos[dot]life API wrapper. | ||
This is a simple wrapper for the [Nekos.life](https://nekos.life) API, written for use with Deno. | ||
|
||
## Supported Endpoints | ||
The wrapper currently supports the following endpoints: | ||
|
||
### Non image endpoints | ||
* `/api/v2/cat` | ||
* `/api/v2/8ball` | ||
* `/api/v2/fact` | ||
* `/api/v2/name` | ||
* `/api/v2/owoify` (takes a text argument) | ||
* `/api/v2/why` | ||
|
||
### Image endpoints | ||
* `/api/v2/img/avatar` | ||
* `/api/v2/img/cuddle` | ||
* `/api/v2/img/feed` | ||
* `/api/v2/img/fox_girl` | ||
* `/api/v2/img/gasm` | ||
* `/api/v2/img/gecg` | ||
* `/api/v2/img/goose` | ||
* `/api/v2/img/hug` | ||
* `/api/v2/img/kiss` | ||
* `/api/v2/img/lewd` | ||
* `/api/v2/img/lizard` | ||
* `/api/v2/img/meow` | ||
* `/api/v2/img/ngif` | ||
* `/api/v2/img/neko` | ||
* `/api/v2/img/pat` | ||
* `/api/v2/img/slap` | ||
* `/api/v2/img/smug` | ||
* `/api/v2/img/spank` | ||
* `/api/v2/img/tickle` | ||
* `/api/v2/img/wallpaper` | ||
* `/api/v2/img/waifu` | ||
* `/api/v2/img/woof` | ||
|
||
## Disclaimer | ||
This wrapper provides access to the Nekos.life API, which is not developed or maintained by me. The API and its endpoints may stop working or change at any time, and the wrapper may not be updated to reflect these changes. Use of the wrapper and the API is at the user's own risk. | ||
|
||
For more information about the API and its endpoints see the list of endpoints at [/api/v2/endpoints](https://nekos.life/api/v2/endpoints). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
async function request(endPoint: string, startTime: number, input?: string): Promise<any> { | ||
let url = `https://nekos.life/api/v2/${endPoint}`; | ||
if (input != undefined) url += `?text=${input}`; | ||
|
||
const res = await fetch(url); | ||
const json = await res.json(); | ||
|
||
json['time'] = Date.now() - startTime; | ||
return json; | ||
} | ||
|
||
export namespace Nekos { | ||
export interface Response { time: number } | ||
export interface CatResponse extends Response { cat: string } | ||
export interface EightBallResponse extends Response { response: string } | ||
export interface FactResponse extends Response { fact: string } | ||
export interface ImageResponse extends Response { url: string } | ||
export interface NameResponse extends Response { name: string } | ||
export interface OwOReponse extends Response { owo: string } | ||
export interface WhyResponse extends Response { why: string } | ||
|
||
export const cat = (): Promise<CatResponse> => request("cat", Date.now()); | ||
export const eightBall = (): Promise<EightBallResponse> => request("8ball", Date.now()); | ||
export const fact = (): Promise<FactResponse> => request("fact", Date.now()); | ||
export const name = (): Promise<NameResponse> => request("name", Date.now()); | ||
export const owoify = (text: string): Promise<OwOReponse> => request("owoify", Date.now(), text); | ||
export const why = (): Promise<WhyResponse> => request("why", Date.now()); | ||
|
||
export const avatar = (): Promise<ImageResponse> => request("img/avatar", Date.now()); | ||
export const cuddle = (): Promise<ImageResponse> => request("img/cuddle", Date.now()); | ||
export const feed = (): Promise<ImageResponse> => request("img/feed", Date.now()); | ||
export const foxGirl = (): Promise<ImageResponse> => request("img/fox_girl", Date.now()); | ||
export const gasm = (): Promise<ImageResponse> => request("img/gasm", Date.now()); | ||
export const gecg = (): Promise<ImageResponse> => request("img/gecg", Date.now()); | ||
export const goose = (): Promise<ImageResponse> => request("img/gifter", Date.now()); | ||
export const hug = (): Promise<ImageResponse> => request("img/hug", Date.now()); | ||
export const kiss = (): Promise<ImageResponse> => request("img/kiss", Date.now()); | ||
export const lewd = (): Promise<ImageResponse> => request("img/lewd", Date.now()); | ||
export const lizard = (): Promise<ImageResponse> => request("img/lizard", Date.now()); | ||
export const meow = (): Promise<ImageResponse> => request("img/meow", Date.now()); | ||
export const ngif = (): Promise<ImageResponse> => request("img/ngif", Date.now()); | ||
export const neko = (): Promise<ImageResponse> => request("img/neko", Date.now()); | ||
export const pat = (): Promise<ImageResponse> => request("img/pat", Date.now()); | ||
export const slap = (): Promise<ImageResponse> => request("img/slap", Date.now()); | ||
export const smug = (): Promise<ImageResponse> => request("img/smug", Date.now()); | ||
export const spank = (): Promise<ImageResponse> => request("img/spank", Date.now()); | ||
export const tickle = (): Promise<ImageResponse> => request("img/tickle", Date.now()); | ||
export const wallpaper = (): Promise<ImageResponse> => request("img/wallpaper", Date.now()); | ||
export const waifu = (): Promise<ImageResponse> => request("img/waifu", Date.now()); | ||
export const woof = (): Promise<ImageResponse> => request("img/woof", Date.now()); | ||
} |