### Install MyAnimeList API v2 Node.js Package Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Install the @chris-kode/myanimelist-api-v2 package into your Node.js project using npm. This command adds the library to your project's dependencies, allowing you to import and use its functionalities. ```bash npm i @chris-kode/myanimelist-api-v2 ``` -------------------------------- ### JavaScript: Get MyAnimeList Anime Suggestions Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves a list of anime suggestions provided by MyAnimeList. This method supports pagination and allows customizing the returned fields. It's useful for discovering new anime based on user preferences or platform algorithms. ```APIDOC Method: animeSuggestions Description: Anime suggestion from MAL Params: - offset: number (default = 0) - limit: number (default = 100) - fields: Array (default = [structures.animeInList]) - fields to show ``` ```JavaScript //Get the anime suggestion from MAL anime.animeSuggestions(); ``` -------------------------------- ### Get User Anime List (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves the user's anime list based on the current session. Allows pagination and filtering of fields. The default username is '@me', and results are paginated with a default limit of 100. ```APIDOC getListAnime( user_name: String = "@me", offset: Number = 0, limit: Number = 100, fields: Array = [structures] ): AnimeList ``` ```JavaScript //Third page of results, 50 limit, 100-150, anime_list.getList("@me", 150, 50); ``` -------------------------------- ### Get User Manga List (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves the user's manga list based on the current session. Allows pagination and filtering of fields. The default username is '@me', and results are paginated with a default limit of 100. ```APIDOC getListManga( user_name: String = "@me", offset: Number = 0, limit: Number = 100, fields: Array = [structures] ): MangaList ``` ```JavaScript //Third page of results, 50 limit, 100-150, manga_list.getList("@me", 150, 50); ``` -------------------------------- ### Get Current User Information (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves detailed information about the user associated with the current session. Allows filtering of fields to retrieve specific user data. This method provides access to the authenticated user's profile. ```APIDOC me( fields: Array = [structures.user] ): User ``` ```JavaScript user.me(); ``` -------------------------------- ### JavaScript: Get MyAnimeList Anime Rankings Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves a list of animes based on various ranking types, such as 'all', 'airing', 'movie', etc. This method supports pagination and allows specifying fields to customize the returned data. It's used to explore popular or trending anime lists. ```APIDOC Method: animeRanking Description: Ranking animes, with all type of rankings Params: - ranking_type: string (OPTIONS: "all" | "airing" | "upcoming" | "tv" | "ova" | "movie" | "special" | "bypopularity" | "favorite") (default = "all") - offset: number (default = 0) - limit: number (default = 100) - fields: Array (default = [structures.animeInList]) - fields to show ``` ```JavaScript //Get all the ranking where is now airing anime.animeRanking("airing"); //Third page of ranking results, 50 limit, 100-150, anime.animeRanking("all", 150, 50); ``` -------------------------------- ### JavaScript: Get MyAnimeList Manga Rankings Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves a list of mangas based on various ranking types, such as 'all', 'manga', 'novels', etc. This method supports pagination and allows specifying fields to customize the returned data. It's used to explore popular or trending manga lists. ```APIDOC Method: mangaRanking Description: Ranking mangas, with all type of rankings Params: - ranking_type: string (OPTIONS: "all" | "manga" | "novels" | "oneshots" | "doujin" | "manhwa" | "manhua" | "bypopularity" | "favorite") (default = "all") - offset: number (default = 0) - limit: number (default = 100) - fields: Array (default = [structures.mangaInList]) ``` ```JavaScript //Get all the ranking where are mangas manga.mangaRanking("manga"); //Third page of ranking results, 50 limit, 100-150, anime.mangaRanking("all", 150, 50); ``` -------------------------------- ### Generate MyAnimeList OAuth2 Authorization URL with PKCE Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Demonstrates how to generate the authorization URL for MyAnimeList OAuth2 using PKCE. This involves initializing the OAUTH client, generating a PKCE challenge, and then creating the redirect URL. The code_challenge and code_verifier should be saved securely for later use in the token exchange. ```javascript const API = require("@chris-kode/myanimelist-api-v2"); const oauth = new API.OAUTH(CLIENT_ID); const pkceChallenge = require("pkce-challenge"); //save this variable value that contains the code_challenge and code_verification in a database or something const pkce = pkceChallenge(); const urlToRedirect = oauth.urlAuthorize(pkce.code_challenge); // this generate the url that you need to redirect //This example is for expressjs, but you only need to do a redirection to the url generated res.redirect(urlToRedirect); ``` -------------------------------- ### Initialize MyAnimeList User API (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Initializes the API_USER object, which allows retrieval of user-specific information. Requires a valid bearer token for authentication. This object provides methods to access user profile data. ```APIDOC class API_USER { constructor(BEARER_TOKEN: string) } ``` ```JavaScript /*BEARER_TOKEN (ONLY THE TOKEN) = eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY4MWExNTIzYzBkZjI0MWNmNDlmZTg1Y2Y2MmQ5ZWU2ZDNjNDJlMGQ3ODIzN2I4ZjQ1NjkzMjUxZDdlYzhjZjIyYTVmNzdjZGY3MmJkMTkyIn0.ey... */ const user = new API.API_USER(BEARER_TOKEN); ``` -------------------------------- ### Initialize MyAnimeList Anime List API (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Initializes the API_LIST_ANIME object, which allows interaction with the user's anime list. Requires a valid bearer token for authentication. This object provides methods to manage anime entries. ```APIDOC class API_LIST_ANIME { constructor(BEARER_TOKEN: string) } ``` ```JavaScript /*BEARER_TOKEN (ONLY THE TOKEN) = eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY4MWExNTIzYzBkZjI0MWNmNDlmZTg1Y2Y2MmQ5ZWU2ZDNjNDJlMGQ3ODIzN2I4ZjQ1NjkzMjUxZDdlYzhjZjIyYTVmNzdjZGY3MmJkMTkyIn0.ey... */ const anime_list = new API.API_LIST_ANIME(BEARER_TOKEN); ``` -------------------------------- ### MyAnimeList API OAUTH Class Initialization Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Initializes the OAUTH class from the @chris-kode/myanimelist-api-v2 library. It requires the CLIENT_ID and optionally CLIENT_SECRET for authentication. This object is essential for all OAuth-related operations, including generating authorization URLs and managing tokens. ```APIDOC class OAUTH { constructor(CLIENT_ID: string, CLIENT_SECRET?: string); } ``` ```javascript //Client_Id as first parameter, and optional Cliente Secret if is need it. const oauth = new API.OAUTH(CLIENT_ID, CLIENT_SECRET); ``` -------------------------------- ### JavaScript: Initialize MyAnimeList Anime API Client Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Initializes the API_ANIME object, which provides methods for interacting with the MyAnimeList anime endpoints. This object requires a valid BEARER_TOKEN for authentication. Once initialized, it can be used to perform various anime-related queries. ```JavaScript const anime = new API.API_ANIME(BEARER_TOKEN); ``` -------------------------------- ### MyAnimeList API OAUTH.urlAuthorize Method Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Generates the URL to which the user must be redirected to authorize the application. This method requires a PKCE code_challenge which can be generated using a library like pkce-challenge. The generated URL is crucial for initiating the OAuth2 flow. ```APIDOC method urlAuthorize(code_challenge: string): string; Parameters: - code_challenge (string): The generated PKCE code challenge. Returns: - string: The URL for user authorization. ``` ```javascript //first parameter we need a code_challenge res.redirect(oauth.urlAuthorize(pcke.code_challenge)); ``` -------------------------------- ### Initialize MyAnimeList Manga List API (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Initializes the API_LIST_MANGA object, which allows interaction with the user's manga list. Requires a valid bearer token for authentication. This object provides methods to manage manga entries. ```APIDOC class API_LIST_MANGA { constructor(BEARER_TOKEN: string) } ``` ```JavaScript /*BEARER_TOKEN (ONLY THE TOKEN) = eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY4MWExNTIzYzBkZjI0MWNmNDlmZTg1Y2Y2MmQ5ZWU2ZDNjNDJlMGQ3ODIzN2I4ZjQ1NjkzMjUxZDdlYzhjZjIyYTVmNzdjZGY3MmJkMTkyIn0.ey... */ const manga_list = new API.API_LIST_MANGA(BEARER_TOKEN); ``` -------------------------------- ### JavaScript: Initialize MyAnimeList Manga API Client Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Initializes the API_MANGA object, which provides methods for interacting with the MyAnimeList manga endpoints. This object requires a valid BEARER_TOKEN for authentication. Once initialized, it can be used to perform various manga-related queries. ```JavaScript const manga = new API.API_MANGA(BEARER_TOKEN); ``` -------------------------------- ### MyAnimeList API v2 Anime Module Reference Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md This module provides methods for searching and retrieving anime information from MyAnimeList. It supports searching by ID or query, fetching rankings, seasonal anime, and suggestions, with options for custom field selection. ```APIDOC class API_ANIME { /** * Searches for anime by a query text. * @param {string} query The search query. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} A list of anime entries. */ static animes(query: string, options?: { fields?: string[]; limit?: number; offset?: number; }): Promise; /** * Retrieves a specific anime by its ID. * @param {number} id The anime ID. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @returns {Promise} The detailed anime entry. */ static anime(id: number, options?: { fields?: string[]; }): Promise; /** * Retrieves anime rankings. * @param {string} rankingType The type of ranking (e.g., 'all', 'airing', 'upcoming'). * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} A list of ranked anime entries. */ static animeRanking(rankingType: string, options?: { fields?: string[]; limit?: number; offset?: number; }): Promise; /** * Retrieves seasonal anime. * @param {string} year The year. * @param {string} season The season (e.g., 'winter', 'spring', 'summer', 'fall'). * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} A list of seasonal anime entries. */ static animeSeasonal(year: string, season: string, options?: { fields?: string[]; limit?: number; offset?: number; }): Promise; /** * Retrieves anime suggestions. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} A list of anime suggestions. */ static animeSuggestions(options?: { fields?: string[]; limit?: number; offset?: number; }): Promise; } ``` -------------------------------- ### MyAnimeList API v2 OAuth Module Reference Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md This module handles the OAuth2 authentication flow for the MyAnimeList API. It provides methods to generate authorization URLs, obtain access tokens, and refresh expired tokens, ensuring secure access to user data. ```APIDOC class OAUTH { /** * Generates the OAuth2 authorization URL for MyAnimeList. * @returns {string} The authorization URL. */ static urlAuthorize(): string; /** * Exchanges an authorization code for an access token. * @param {string} code The authorization code received from the callback. * @param {string} codeVerifier The code verifier used in the authorization request. * @returns {Promise} An object containing access_token, refresh_token, expires_in. */ static accessToken(code: string, codeVerifier: string): Promise<{ access_token: string; refresh_token: string; expires_in: number; }>; /** * Refreshes an expired access token using a refresh token. * @param {string} refreshToken The refresh token. * @returns {Promise} An object containing new access_token, refresh_token, expires_in. */ static refreshToken(refreshToken: string): Promise<{ access_token: string; refresh_token: string; expires_in: number; }>; } ``` -------------------------------- ### MyAnimeList API v2 User Module Reference Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md This module provides methods for retrieving information about the authenticated user's profile. It allows fetching the user's profile with options for custom field selection. ```APIDOC class API_USER { /** * Retrieves the authenticated user's profile. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @returns {Promise} The user's profile details. */ static me(options?: { fields?: string[]; }): Promise; } ``` -------------------------------- ### MyAnimeList API v2 Anime List Module Reference Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md This module manages a user's anime list on MyAnimeList. It provides functionalities to retrieve, delete, and update entries in the authenticated user's anime list. ```APIDOC class API_ANIME_LIST { /** * Retrieves the authenticated user's anime list. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return for each anime entry. * @param {string} [options.status] Filter by anime status (e.g., 'watching', 'completed'). * @param {string} [options.sort] Sort order (e.g., 'list_score', 'list_updated_at'). * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} The user's anime list. */ static getListAnime(options?: { fields?: string[]; status?: string; sort?: string; limit?: number; offset?: number; }): Promise; /** * Deletes an entry from the authenticated user's anime list. * @param {number} animeId The ID of the anime to delete. * @returns {Promise} */ static deleteListAnime(animeId: number): Promise; /** * Updates an entry in the authenticated user's anime list. * @param {number} animeId The ID of the anime to update. * @param {object} updateData The data to update (e.g., status, score, num_watched_episodes). * @returns {Promise} The updated anime list entry. */ static updateListAnime(animeId: number, updateData: { [key: string]: any }): Promise; } ``` -------------------------------- ### Obtain MyAnimeList OAuth2 Access Token Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Explains how to exchange the authorization code received from MyAnimeList for an access_token and refresh_token. This step requires the code obtained after user authorization and the original code_challenge used during the authorization URL generation. The response contains tokens and their expiration, which should be stored securely. ```javascript const API = require("@chris-kode/myanimelist-api-v2"); const oauth = new API.OAUTH(CLIENT_ID); //get the code that mal give us, and the code_challenge which we have generated before. oauth.accessToken(CODE, CODE_CHALLENGE).then( ((response) => { //PERFECT //save all the response at db or something, u will get something like this: /*{ token_type: 'Bearer', expires_in: 2678400, access_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY4MWExNTIzYzBkZjI0MWNmNDlmZTg1Y2Y2MmQ5ZWU2ZDNjNDJlMGQ3ODIzN2I4ZjQ1NjkzMjUxZDdlYzhjZjIyYTVmNzdjZGY3MmJkMTkyIn0.e..., refresh_token: 'def502009f00fd0d08d50a7faca228bb4f88fa61df80e70aab290d6431115a16b44dc3e9215b3489a71caf9d594b8803129b6497619928025a420f107efd4560b45eb4e136bc4d0d72...' }*/ }).catch((err) => { //ERROR //do something }) ); ``` -------------------------------- ### MyAnimeList API v2 Manga List Module Reference Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md This module manages a user's manga list on MyAnimeList. It provides functionalities to retrieve, delete, and update entries in the authenticated user's manga list. ```APIDOC class API_MANGA_LIST { /** * Retrieves the authenticated user's manga list. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return for each manga entry. * @param {string} [options.status] Filter by manga status (e.g., 'reading', 'completed'). * @param {string} [options.sort] Sort order (e.g., 'list_score', 'list_updated_at'). * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} The user's manga list. */ static getListManga(options?: { fields?: string[]; status?: string; sort?: string; limit?: number; offset?: number; }): Promise; /** * Deletes an entry from the authenticated user's manga list. * @param {number} mangaId The ID of the manga to delete. * @returns {Promise} */ static deleteListManga(mangaId: number): Promise; /** * Updates an entry in the authenticated user's manga list. * @param {number} mangaId The ID of the manga to update. * @param {object} updateData The data to update (e.g., status, score, num_volumes_read). * @returns {Promise} The updated manga list entry. */ static updateListManga(mangaId: number, updateData: { [key: string]: any }): Promise; } ``` -------------------------------- ### MyAnimeList API OAUTH.accessToken Method Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Exchanges the authorization code received from MyAnimeList for an access_token and refresh_token. This method is crucial for establishing a user session and making authenticated API requests. It returns a Promise that resolves with token details or rejects on error, requiring error handling. ```APIDOC method accessToken(code: string, code_challenge: string): Promise; Parameters: - code (string): The authorization code obtained from the callback URL. - code_challenge (string): The original PKCE code challenge used for authorization. Returns: - Promise: A promise that resolves with an object containing 'token_type', 'expires_in', 'access_token', and 'refresh_token'. ``` ```javascript oauth .accessToken(CODE, CODE_CHALLENGE) .then((response) => { //ALL OK //DO SOMETHING }) .catch((err) => { //ALL BAD //DO SOMETHING }); ``` -------------------------------- ### MyAnimeList API v2 Manga Module Reference Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md This module provides methods for searching and retrieving manga information from MyAnimeList. It supports searching by ID or query and fetching manga rankings, with options for custom field selection. ```APIDOC class API_MANGA { /** * Searches for manga by a query text. * @param {string} query The search query. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} A list of manga entries. */ static mangas(query: string, options?: { fields?: string[]; limit?: number; offset?: number; }): Promise; /** * Retrieves a specific manga by its ID. * @param {number} id The manga ID. * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @returns {Promise} The detailed manga entry. */ static manga(id: number, options?: { fields?: string[]; }): Promise; /** * Retrieves manga rankings. * @param {string} rankingType The type of ranking (e.g., 'all', 'publishing', 'manga'). * @param {object} [options] Optional parameters. * @param {string[]} [options.fields] Custom fields to return. * @param {number} [options.limit] Limit the number of results. * @param {number} [options.offset] Offset for pagination. * @returns {Promise} A list of ranked manga entries. */ static mangaRanking(rankingType: string, options?: { fields?: string[]; limit?: number; offset?: number; }): Promise; } ``` -------------------------------- ### JavaScript: Search Animes by Query Text Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves a list of animes based on a text search query. This method supports pagination through `offset` and `limit` parameters, and allows specifying `fields` to customize the returned data structure. It's used for general anime lookup. ```APIDOC Method: animes Description: List of animes via a query text search Params: - q: string (required) - text to search - offset: number (default = 0) - limit: number (default = 100) - fields: Array (default = [structures.animeInList]) - fields to show ``` ```JavaScript //Simple query anime.animes("one piece"); //Third page of one piece results, 50 limit, 100-150, anime.animes("one piece", 150, 50); ``` -------------------------------- ### JavaScript: Search Mangas by Query Text Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Retrieves a list of mangas based on a text search query. This method supports pagination through `offset` and `limit` parameters, and allows specifying `fields` to customize the returned data structure. It's used for general manga lookup. ```APIDOC Method: mangas Description: List of mangas via a query text search Params: - q: string (required) - text to search - offset: number (default = 0) - limit: number (default = 100) - fields: Array (default = [structures.mangaInList]) ``` ```JavaScript //Simple query manga.mangas("one piece"); //Third page of one piece results, 50 limit, 100-150, manga.mangas("one piece", 150, 50); ``` -------------------------------- ### JavaScript: Retrieve Specific Anime by ID Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Fetches detailed information for a specific anime using its unique ID. This method returns the full anime details and allows customization of the returned fields. It's ideal for retrieving comprehensive data about a single anime entry. ```APIDOC Method: anime Description: Specific anime by id, and return the anime with all details Params: - id: number (required) - fields: Array (default = [structures.animeFull]) - fields to show ``` ```JavaScript anime.anime(21); ``` -------------------------------- ### JavaScript: Retrieve Seasonal Anime Lists Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Fetches a list of animes for a specific year and season. By default, it returns the current season's anime. This method supports pagination, sorting by score or user count, and allows customizing the returned fields. It's useful for exploring seasonal anime releases. ```APIDOC Method: animeSeasonal Description: Seasonal Anime, by default is filled at actual season Params: - year: number (default = currentYear) - season: string (OPTIONS: "winter" | "spring" | "summer" | "fall") (default = currentSeason) - offset: number (default = 0) - limit: number (default = 100) - sort: string (OPTIONS: "anime_score" | "anime_num_list_users" | "") (default = "") - fields: Array (default = [structures.animeInList]) - fields to show ``` ```JavaScript //Get all the current anime season anime.animeSeasonal(); //Get the animes season of winter 2010 anime.animeSeasonal(2010, "winter"); //Get the animes season of spring 2015, third page ordered by anime_score anime.animeSeasonal(2015, "spring", 150, 50, "anime_score"); ``` -------------------------------- ### JavaScript: Retrieve Specific Manga by ID Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Fetches detailed information for a specific manga using its unique ID. This method returns the full manga details and allows customization of the returned fields. It's ideal for retrieving comprehensive data about a single manga entry. ```APIDOC Method: manga Description: Specific manga by id, and return the manga with all details Params: - id: number (required) - fields: Array (default = [structures.mangaFull]) ``` ```JavaScript //Simple query manga.manga(13); ``` -------------------------------- ### Update Anime Entry in List (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Updates an existing anime entry in the user's list. Allows modification of various fields such as status, score, and watched episodes. All update fields are optional, enabling partial updates. ```APIDOC updateListAnime( anime_id: Number, fieldsToUdpate: { status?: "watching" | "completed" | "on_hold" | "dropped" | "plan_to_watch", is_rewatching?: boolean, score?: 0-10, num_watched_episodes?: Number, priority?: 0-2, num_times_rewatched?: Number, rewatch_value?: 0-5, tags?: String, comments?: String } ): AnimeEntry ``` ```JavaScript //Update Boku no hero 3 entry with status completed and score 9 anime_list.updateList(36456, { status: "completed", score: 9 }); ``` -------------------------------- ### JavaScript: Refresh OAuth Token for MyAnimeList API Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md This function refreshes an expired OAuth token obtained during the initial access token step. It takes the REFRESH_TOKEN as input and returns a new access token upon success, or an error if the refresh fails. This is crucial for maintaining continuous API access without re-authentication. ```JavaScript oauth .refreshToken(REFRESH_TOKEN) .then((response) => { //ALL OK //DO SOMETHING }) .catch((err) => { //ALL BAD //DO SOMETHING }); ``` -------------------------------- ### Refresh MyAnimeList OAuth2 Access Token Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Describes how to refresh an expired access token using the refresh_token obtained during the initial access token generation. This process provides a new access_token and refresh_token, extending the session without requiring user re-authorization. Always store the new refresh token securely. ```javascript const API = require("@chris-kode/myanimelist-api-v2"); const oauth = new API.OAUTH(CLIENT_ID); //REFRESH TOKEN that we generated before, when we create a Access Token oauth.refreshToken(REFRESH_TOKEN).then( ((response) => { //PERFECT //save all the response at db or something, u will get something like this: /*{ token_type: 'Bearer', expires_in: 2678400, access_token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY4MWExNTIzYzBkZjI0MWNmNDlmZTg1Y2Y2MmQ5ZWU2ZDNjNDJlMGQ3ODIzN2I4ZjQ1NjkzMjUxZDdlYzhjZjIyYTVmNzdjZGY3MmJkMTkyIn0.e..., refresh_token: 'def502009f00fd0d08d50a7faca228bb4f88fa61df80e70aab290d6431115a16b44dc3e9215b3489a71caf9d594b8803129b6497619928025a420f107efd4560b45eb4e136bc4d0d72...' }*/ }).catch((err) => { //ERROR //do something }) ); ``` -------------------------------- ### Update Manga Entry in List (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Updates an existing manga entry in the user's list. Allows modification of various fields such as status, score, and read chapters/volumes. All update fields are optional, enabling partial updates. ```APIDOC updateListManga( manga_id: Number, fieldsToUdpate: { status?: "reading" | "completed" | "on_hold" | "dropped" | "plan_to_read", is_rereading?: boolean, score?: 0-10, num_volumes_read?: Number, num_chapters_read?: Number, priority?: 0-2, num_times_reread?: Number, reread_value?: 0-5, tags?: String, comments?: String } ): MangaEntry ``` ```JavaScript //Update Boku no hero Academia entry with status completed and score 9 manga_list.updateList(75989, { status: "completed", score: 9 }); ``` -------------------------------- ### Delete Anime Entry from List (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Deletes a specific anime entry from the user's list. Requires the unique anime ID to identify the entry. This action is permanent and cannot be undone. ```APIDOC deleteListAnime( anime_id: Number ): void ``` ```JavaScript //Delete Boku no hero academy 3ยบ season from my anime list. anime_list.deleteList(36456); ``` -------------------------------- ### Delete Manga Entry from List (JavaScript) Source: https://github.com/chris-kode/myanimelist-api-v2/blob/master/README.md Deletes a specific manga entry from the user's list. Requires the unique manga ID to identify the entry. This action is permanent and cannot be undone. ```APIDOC deleteListManga( manga_id: Number ): void ``` ```JavaScript //Delete Boku no Hero Academia from my manga list. manga_list.deleteList(75989); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.