aniki
v1.4.9
Published
Node.js APIs wrapper for anime/manga related content.
Maintainers
Readme
Aniki
Node.js APIs wrapper for anime/manga related content.
See CHANGELOG for recent changes.
Table of contents
Installation
With NPM:
npm i aniki@latestWith PNPM:
pnpm i aniki@latestAvailable APIs
Bugs or suggestions
PLEASE let me know instantly if there are any mistakes / bugs by using the Issues.
If you want to suggest me anything, please also make an issue with the enhancement label.
Authentification
Important
If you need to authenticate with the APIs, you have to make your own authentification system, and use the basicfetchto use the auth, once you have made your system, you can use theaccess_tokens in the classes to make unrestricted requests.
Otherwise, for the MyAnimeList and MyMangaList, you can still use the client_id but it is recommended for tests only if requests appears in the client side.
Usage
Kitsu
const { AnimeKitsu } = require("aniki");
// ESM/TS
import { AnimeKitsu } from "aniki";
const anime = new AnimeKitsu();
// With an access_token
// If you have one, you'll be able to use the R18 rating category on the find and list age rating parameter.
// I do not take any responsibility for users who use the unrestricted content.
const anime = new AnimeKitsu("abCdEfgHiJK12345");
// Find anime in a simple way:
anime
.find({ query: "Oshi no ko", offset: 0 })
.then((r) => console.log(r.data[0]));
// All list from the first page (limited by 10 result)
anime.findMany({ offset: 0, limit: 10 }).then((results) => {
console.log(results.data);
});
// Find anime with ID
anime.findUnique(2303).then((result) => {
console.log(result.data);
});
// Alternative
anime.find(1733).then((result) => {
console.log(result.data);
});
// Find an episode
anime.episode(2302).then((result) => {
console.log(result.data);
});
// Using hooks
anime
.find(
{ query: "Oshi no ko" },
{
beforeRequest: async (config) => {
console.log("Before request with the url: " + config.url);
// ...
},
onError: async (err, res) => {
if (res.status === 404)
console.error(`The requested content was not found!
More details: ${(await err).errors[0].title}`);
// ...
},
afterRequest: async (res) => {
console.log("Request done!");
// ...
},
},
)
.then((r) => console.log(r));Warning
Using anaccess_tokenin theAnimeKitsu/MangaKitsuclasses will unlock R18 (rule 18) features IN the API. THIS MODULE CAN RETRIEVE R18 CONTENT FROM THE API, MISUSE OF THOSE FEATURES IS AT YOUR OWN RISK. I DO NOT TAKE ANY RESPONSABILITY.
MyAnimeList
const { MyAnimeList } = require("aniki");
// ESM/TS
import { MyAnimeList } from "aniki";
// Using authentification
// Client ID.
const anime = new MyAnimeList({ client_id: "ClIENT_ID" });
// Access token
const anime = new MyAnimeList({ access_token: "ACCESS_TOKEN" });
// Both at the same time will not work.
// Fiding an anime
anime
.find({ query: "Oshi no ko", offset: 0, limit: 10 })
.then((r) => console.log(r.data[0])); // Return nodes.
// Getting the details of an anime
anime.details({ anime_id: 363 }).then((r) => console.log(r.id)); // Return anime details.
// Listing animes based on a specific rank
anime
.ranking({ ranking_type: "tv", offset: 0, limit: 16 })
.then((r) => console.log(r.data[0])); // Return nodes.
// Listing animes based on a year and a season of publication.
anime
.seasonal({ year: 2009, season: "fall", offset: 0, limit: 16 })
.then((r) => console.log(r.data[0])); // Return nodes.
// Almost the same for MyMangaList!Note
I recommend to add any fields depending on your needs, if you don't specify the proper fields, some properties returned by the API will be undefined.
Example:
// Proper fields
anime
.details(52991, ["created_at", "updated_at"])
.then((r) =>
console.log(r.id, r.title, new Date(r.created_at), new Date(r.updated_at)),
); // 52991, Sousou no Frieren, Date, Date
// Unproper fields
anime
.details(52991, ["alternative_titles", "background"])
.then((r) => console.log(r.id, r.title, r.mean)); // 52991, Sousou no Frieren, undefined.Waifu.Im
const { WaifuIm } = require("aniki");
const waifu = new WaifuIm();
// Getting simple SFW maid images.
waifu
.find({ isNsfw: "False", IncludedTags: "maid" })
.then((r) => console.log(r));Note
TheisNsfwparameter is"False"by default.
License
MIT License - Normioffi
