Skip to content

MrScopes/anilist.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Table of Contents

Example

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

})();

Documentation

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()

Notes:

  • 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 like id, 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).