Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Mal

MalAPI

Official MyAnimeList API

Import:

import { Mal } from "node-myanimelist";

Initialize api (Auth)

const auth = Mal.auth("app_id")

Use initialized api (Auth) to login:

  • Unoffical way to login (not recomended) {@link Auth.Unstable.login}
    const acount = await auth.Unstable.login("username","password");
    
  • Offical way to login (recomended) Auth.authorizeWithCode
  • Generate pkce (in this example pkce-challenge npm package is used)
    import pkceChallenge from "pkce-challenge";
    const pkce = pkceChallenge();
  • Get OAuth url Auth.getOAuthUrl
    const url = auth.getOAuthUrl(pkce.code_challenge);
    
  • Open returned url, accept oauth and use returned code to authorize Auth.authorizeWithCode
    const acount = await auth.authorizeWithCode(code, code_challenge)
    

You probably want to save acount somewhere, you can just call acount.stringifyToken() to get json

Later you can load it using:

const token = Mal.MalToken.fromJsonString(jsonStr);
const acount = auth.loadToken(token);

If more time has passed you can also refresh token instead of loading last one

const acount = await auth.authorizeWithRefreshToken(json.refresh_token);

Finally you can use MalAcount

let search = await acount.manga.search(
"Sakurasou",
Mal.Manga.fields().all()
).call();

Index

Namespaces

Classes

Interfaces

Type aliases

Functions

Type aliases

ResponseError: AxiosError<MalError>

Functions

  • auth(clientId?: string): Auth

Generated using TypeDoc