1.2.2 • Published 1 year ago

@davidqf555/mal.js v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

MAL.js

A strongly-typed TypeScript wrapper for the official MyAnimeList API.

Installation

npm install @davidqf555/mal.js

Usage

A client ID can be registered here.

The documentation for the API can be found here.

Example

import MALClient, { FieldsParser } from '@davidqf555/mal.js';

// Create client to access MyAnimeList API
const client = new MALCLient(client_id, client_secret);

// Generate URL for client to authenticate with randomly generated verifer
const { url, code_verifier } = client.requestAuthorization();

// Retrieve token after client authenticates and receives code
const { access_token } = await client.retrieveAuthorizationToken(code, code_verifier);

// Get anime list from a query
const { data } = await client.getAnimeList({ q: 'Sword Art Online', fields: new FieldsParser({ mean: true, rank: true }) });

// Get user anime list of access token owner
const { data } = await client.getUserAnimeList('@me', { status: 'watching' }, access_token);

Client Methods

There is support for user authentication and every documented endpoint.

User Authentication

The supported user authentication methods follow the OAuth 2.0 procedure outlined in the MyAnimeList API documentation.

NameDescription
requestAuthorizationUses/Generates a code verifier to create a link for the user to authenticate
retrieveAuthorizationTokenUses the code from the user redirect after authentication to generate both a refresh and access token
refreshAuthorizationTokenUses a refresh token to refresh both the access and refresh tokens

Endpoint Methods

Each method corresponds to a documented endpoint in the MyAnimeList API.

NameEndpoint
getAnimeListGET /anime
getAnimeDetailsGET /anime/{anime_id}
getAnimeRankingGET /anime/ranking
getSeasonalAnimeGET /anime/season/{year}/{season}
getSuggestedAnimeGET /anime/suggestions
updateAnimeListStatusPATCH /anime/{anime_id}/my_list_status
deleteAnimeListItemDELETE /anime/{anime_id}/my_list_status
getUserAnimeListGET /users/{user_name}/animelist
getForumBoardsGET /forum/boards
getForumTopicDetailsGET /forum/topic/{topic_id}
getForumTopicsGET /forum/topics
getMangaListGET /manga
getMangaDetailsGET /manga/{manga_id}
getMangaRankingGET /manga/ranking
updateMangaListStatusPATCH /manga/{manga_id}/my_list_status
deleteMangaListItemDELETE /manga/{manga_id}/my_list_status
getUserMangaListGET /users/{user_name}/mangalist
getUserInfoGET /users/{user_name}
1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago