V1 IS NO LONGER MAINTAINED! CHECK OUT THE V2 BRANCH! https://github.com/MrScopes/anilist.js/tree/v2
NPM module for communicating with Anilist.
Find any bugs or have any suggestions?
Create an issue on the repo or contact me on Discord @MrScopes#5548
const { Client } = require('anilist.js');
const AniList = new Client('API TOKEN'); // token is only required for some features
(async () => {
// list the 3 most popular MHA seasons
const search = await AniList.searchMedia({ search: 'My Hero Academia', format: 'TV', perPage: 3, sort: 'POPULARITY_DESC' });
console.log(search.Results.map(result => result.info.title));
// toggle favourite status for naruto (character)
const characters = await AniList.searchCharacters({ search: 'Naruto Uzumaki' });
const naruto = characters.Results[0];
await naruto.favourite(); // this requires an api token
})();
Note: variables
parameters are 100% auto completion compatible.
These docs are most likely temporary.
View the example usage.
Italics represents authorization required.
-
Methods:
.getMedia(id)
.searchMedia(variables)
.getCharacter(id)
.searchCharacters(variables)
.me()
-> Currently authorized user.getUser(id)
.searchUsers(variables)
.getStaff(id)
.searchStaff(variables)
.getStudio(id)
.searchStudios(variables)
-
Structures:
- Search Results:
- .Results[<StructureType>]
- .pageInfo
Media >
- .info
- .updateEntry(variables)
- .deleteEntry()
- .favourite()
Character >
- .info
- .favourite()
Viewer (EXTENDS User) >
represents the current authorized user- .updateUser(variables)
User >
- .info
- .follow()
- .getStats()
Staff >
- .info
- .favourite()
Studio >
- .info
- .favourite()
- Search Results:
-
This is my first large npm module. So some things might not work 100% as intended.
-
The JSON output is massive, so keep the following in mind:
- A lot of data is taken out, for example, in user info: statistics is taken out
- nodes are taken out. use
edges[] > node
- for
edges[] > node
, only important info is left in likeid
,title (or name)
-
API Key:
- API Keys are needed for user-specific methods, but you can still get media, characters, etc.
- Get yours @ https://anilist-token.glitch.me/. This is secure, created by me, and open source.
-
Types:
- Types are mainly auto generated, but not every property is 100% supported (this is mainly so the json isn't more massive than it is).