npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

myanimelist-api

v1.0.1

Published

A wrapper for Official MyAnimeList REST API V2.

Downloads

32

Readme

MyAnimeList API

npm version dependencies Status github issues

This is a wrapper for the official MyAnimeList REST API V2. All the endpoints as defined in the documentation are supported including OAuth 2.0 authorization.

Installation

npm install myanimelist-api

Getting started

Generate API credentials by following these instructions.

Make sure to check the resource access is as per your requirements to prevent misuse of the API Keys.

Setup

Initializing the client

const MyAnimeList = require('myanimelist-api');

const mal = new MyAnimeList({
    'clientId': '<Your MAL Client ID>',
    'clientSecret': '<Your MAL Client Secret>',
});

Options

| Option | Type | Required | Description | --- | --- | --- | --- | clientId | String | yes | Your API Client ID | | clientSecret | String | yes | Your API Client Secret | | accessToken | String | yes | Your API Access Token | | refreshToken | String | yes | Your API Refresh Token | | timeout | Number | no | Request Timeout | | axiosConfig | Object | no | Reference

Requests are made with Axios library with support to promises. Error Handling is same as how Axios handles it.

Gerenate the Access Token and Refresh Token from Client

Since MAL V2 API uses oAuth 2 for authorization, you need to access MAL Web Page to allow your user to interact with your app.

const { challengeCode, url } = mal.auth.getChallenge();

In the above snippet, challengeCode is a PKCE compliant 128 character key which is generated in the getChallenge() function.

The user needs to be redirected to the url returned in the above snippet where they need to login with their MAL ID and allow access to your app.

After that, you will receive a code in the redirect URL from MAL. Now, using that code and the challengeCode, you need to do the following:

const { data } = await mal.auth.getRefreshToken(code, challengeCode);

The data has the access token as well as the refresh token.

Refresh your access token

const { data } = await mal.auth.refreshAccessToken(refreshToken);

To reissue the refresh token, you need to re-authorize your user on MAL, Follow from step 1.

API

To use the following methods, it is assumed that you have your access token as well as the refresh token, so you need to initialize the package a little differently.

const MyAnimeList = require('myanimelist-api');

const mal = new MyAnimeList({
    accessToken: "<Your access token>", 
    refreshToken: "<Your refresh token>",    
});

Anime

Details of a specific anime

const { data } = await mal.anime.details(11757, options);

| Parameter | Type | Required | Reference --- | --- | --- | --- id | Number | Yes | options | Object | No | Reference

Search

const { data } = await mal.anime.list("Your Name", options);

| Parameter | Type | Required | Reference --- | --- | --- | --- key | String | Yes | options | Object | No | Reference

Seasonal Anime

const { data } = await mal.anime.seasonal("summer", 2012, options);

| Parameter | Type | Required | Reference --- | --- | --- | --- season | String | Yes | Can be summer, winter, fall, spring year | Number | Yes | options | Object | No | Reference

Ranking

const { data } = await mal.anime.ranking("all", options);

| Parameter | Type | Required | Reference --- | --- | --- | --- rankingType | String | Yes | Follow Reference Below options | Object | No | Reference

Suggested Anime

const { data } = await mal.anime.suggestions(options);

| Parameter | Type | Required | Reference --- | --- | --- | --- options | Object | No | Reference

Manga

Details of a specific Manga

const { data } = await mal.manga.details(21479, options);

| Parameter | Type | Required | Reference --- | --- | --- | --- id | Number | Yes | options | Object | No | Reference

Search

const { data } = await mal.manga.list("Your Name", options);

| Parameter | Type | Required | Reference --- | --- | --- | --- key | String | Yes | options | Object | No | Reference

Ranking

const { data } = await mal.manga.ranking("all", options);

| Parameter | Type | Required | Reference --- | --- | --- | --- rankingType | String | Yes | Follow Reference Below options | Object | No | Reference

Forum

Get Boards

const { data } = await mal.forum.boards(options);

| Parameter | Type | Required | Reference --- | --- | --- | --- options | Object | No | Reference

Get Topics

const { data } = await mal.forum.topics(options);

| Parameter | Type | Required | Reference --- | --- | --- | --- options | Object | Yes | Reference

Get Topic Details

const { data } = await mal.forum.details(17876, options);

| Parameter | Type | Required | Reference --- | --- | --- | --- id | Number | Yes options | Object | No | Reference

User

Details

const { data } = await mal.user.details(username, options);

| Parameter | Type | Required | Reference --- | --- | --- | --- username | String | No | Defaults to @me options | Object | No | Reference

Get Anime List

const { data } = await mal.user.listAnime(username, options);

| Parameter | Type | Required | Reference --- | --- | --- | --- username | String | No | Defaults to @me options | Object | No | Reference

Update Anime List Entry

const { data } = await mal.user.updateAnime(11757, body);

| Parameter | Type | Required | Reference --- | --- | --- | --- id | Number | Yes | body | Object | Yes | Reference

Delete Anime List Entry

const { data } = await mal.user.deleteAnime(11757);

| Parameter | Type | Required | Reference --- | --- | --- | --- id | Number | Yes | Reference

Get Manga List

const { data } = await mal.user.listManga(username, options);

| Parameter | Type | Required | Reference --- | --- | --- | --- username | String | No | Defaults to @me options | Object | No | Reference

Update Manga List Entry

const { data } = await mal.user.updateManga(11757, body);

| Parameter | Type | Required | Reference --- | --- | --- | --- id | Number | Yes | body | Object | Yes | Reference

Delete Manga List Entry

const { data } = await mal.user.deleteManga(11757);

| Parameter | Type | Required | Reference --- | --- | --- | --- id | Number | Yes | Reference