Welcome to myanimelistpy’s documentation!

A library to use the MyAnimeList API more easily.
Getting started
Client ID
First, you need to get a Client ID in the MyAnimeList platform. To do this, follow these steps:
If you haven’t already, create an account on the MyAnimeList platform;
After that, go to Account Settings page;
In the top menu, click in the API option;
It’s important that you read the information on the API page, after that, click on Create ID button;
Fill in the required fields and agree to the API License and Developer Agreement after reading it;
After creating your Clients Accessing the MAL API, click on Edit button, then copy and save your Client ID.
Installation
Click here to check how to install the myanimelistpy library.
Examples
Anime List
The sections below will show you how to get the anime list using different methods.
getAnimeList()
Basic example
1from myanimelistpy.myanimelist import MyAnimeList
2
3CLIENT_ID = "YOUR_MY_ANIME_LIST_CLIENT_ID"
4
5if __name__ == "__main__":
6 my_anime_list = MyAnimeList(client_id=CLIENT_ID)
7
8 anime_list = my_anime_list.getAnimeList(
9 anime_name = "Hunter x Hunter",
10 limit = 2
11 )
12
13 for anime in anime_list:
14 print(f"Id: {anime.getId()}")
15 print(f"Title: {anime.getTitle()}")
16 print(f"Main Picture (medium): {anime.getMainPicture().getMedium()}\n")
Output
Id: 11061
Title: Hunter x Hunter (2011)
Main Picture (medium): https://api-cdn.myanimelist.net/images/anime/1337/99013.jpg
Id: 136
Title: Hunter x Hunter
Main Picture (medium): https://api-cdn.myanimelist.net/images/anime/8/19473.jpg
Request with fields
1from myanimelistpy.myanimelist import MyAnimeList
2
3CLIENT_ID = "YOUR_MY_ANIME_LIST_CLIENT_ID"
4
5if __name__ == "__main__":
6 my_anime_list = MyAnimeList(client_id=CLIENT_ID)
7
8 anime_list = my_anime_list.getAnimeList(
9 anime_name = "Hunter x Hunter",
10 limit = 2,
11 fields = ["rank", "status"]
12 )
13
14 for anime in anime_list:
15 print(f"Id: {anime.getId()}")
16 print(f"Title: {anime.getTitle()}")
17 print(f"Main Picture (medium): {anime.getMainPicture().getMedium()}")
18 print(f"Rank: {anime.getRank()}")
19 print(f"Status: {anime.getStatus()}\n")
Output
Id: 11061
Title: Hunter x Hunter (2011)
Main Picture (medium): https://api-cdn.myanimelist.net/images/anime/1337/99013.jpg
Rank: 9
Status: Finished airing
Id: 136
Title: Hunter x Hunter
Main Picture (medium): https://api-cdn.myanimelist.net/images/anime/8/19473.jpg
Rank: 165
Status: Finished airing
Tip
We strongly recommend using a .env
file or something similar to store
your Client ID. You can use the python-dotenv
library to do this. Click here
to check out their documentation.
1from os import getenv
2from dotenv import load_dotenv
3
4from myanimelistpy.myanimelist import MyAnimeList
5
6load_dotenv()
7
8CLIENT_ID = getenv("CLIENT_ID")
9
10if __name__ == "__main__":
11 my_anime_list = MyAnimeList(client_id=CLIENT_ID)
12
13 anime_list = my_anime_list.getAnimeList(
14 anime_name = "Hunter x Hunter",
15 limit = 2,
16 fields = ["rank", "status"]
17 )
18
19 for anime in anime_list:
20 print(f"Id: {anime.getId()}")
21 print(f"Title: {anime.getTitle()}")
22 print(f"Main Picture (medium): {anime.getMainPicture().getMedium()}")
23 print(f"Rank: {anime.getRank()}")
24 print(f"Status: {anime.getStatus()}\n")
All the next examples will using the python-dotenv library, but feel free not to use it if you don’t want to.
getAnimeListInDict()
1from os import getenv
2from dotenv import load_dotenv
3
4from myanimelistpy.myanimelist import MyAnimeList
5
6load_dotenv()
7
8CLIENT_ID = getenv("CLIENT_ID")
9
10if __name__ == "__main__":
11 my_anime_list = MyAnimeList(client_id=CLIENT_ID)
12
13 anime_list = my_anime_list.getAnimeListInDict(
14 anime_name = "Hunter x Hunter",
15 limit = 2,
16 fields = ["genres"]
17 )
18
19 for anime in anime_list:
20 print(str(anime) + "\n")
Output
{'node': {'id': 11061, 'title': 'Hunter x Hunter (2011)', 'main_picture': {'medium': 'https://api-cdn.myanimelist.net/images/anime/1337/99013.jpg', 'large': 'https://api-cdn.myanimelist.net/images/anime/1337/99013l.jpg'}, 'genres': [{'id': 1, 'name': 'Action'}, {'id': 2, 'name': 'Adventure'}, {'id': 10, 'name': 'Fantasy'}, {'id': 27, 'name': 'Shounen'}]}}
{'node': {'id': 136, 'title': 'Hunter x Hunter', 'main_picture': {'medium': 'https://api-cdn.myanimelist.net/images/anime/8/19473.jpg', 'large': 'https://api-cdn.myanimelist.net/images/anime/8/19473l.jpg'}, 'genres': [{'id': 1, 'name': 'Action'}, {'id': 2, 'name': 'Adventure'}, {'id': 10, 'name': 'Fantasy'}, {'id': 27, 'name': 'Shounen'}]}}
Note
You can access dictionary properties using square brackets:
19for anime in anime_list:
20 print(f"Title: {anime['node']['title']}")
21 print(f"Genres: {anime['node']['genres']}\n")
Output
Title: Hunter x Hunter (2011)
Genres: [{'id': 1, 'name': 'Action'}, {'id': 2, 'name': 'Adventure'}, {'id': 10, 'name': 'Fantasy'}, {'id': 27, 'name': 'Shounen'}]
Title: Hunter x Hunter
Genres: [{'id': 1, 'name': 'Action'}, {'id': 2, 'name': 'Adventure'}, {'id': 10, 'name': 'Fantasy'}, {'id': 27, 'name': 'Shounen'}]
getAnimeListInJSON()
1from os import getenv
2from dotenv import load_dotenv
3
4from myanimelistpy.myanimelist import MyAnimeList
5
6load_dotenv()
7
8CLIENT_ID = getenv("CLIENT_ID")
9
10if __name__ == "__main__":
11 my_anime_list = MyAnimeList(client_id=CLIENT_ID)
12
13 anime_list = my_anime_list.getAnimeListInJSON(
14 anime_name = "Hunter x Hunter",
15 limit = 2,
16 fields = ["num_episodes"]
17 )
18
19 print(anime_list)
Output
{"data":[{"node": {"id": 11061, "title": "Hunter x Hunter (2011)", "main_picture": {"medium": "https://api-cdn.myanimelist.net/images/anime/1337/99013.jpg", "large": "https://api-cdn.myanimelist.net/images/anime/1337/99013l.jpg"}, "num_episodes": 148}}, {"node": {"id": 136, "title": "Hunter x Hunter", "main_picture": {"medium": "https://api-cdn.myanimelist.net/images/anime/8/19473.jpg", "large": "https://api-cdn.myanimelist.net/images/anime/8/19473l.jpg"}, "num_episodes": 62}}]}
Note
JSON Viewer
{
"data": [
{
"node": {
"id": 11061,
"title": "Hunter x Hunter (2011)",
"main_picture": {
"medium": "https://api-cdn.myanimelist.net/images/anime/1337/99013.jpg",
"large": "https://api-cdn.myanimelist.net/images/anime/1337/99013l.jpg"
},
"num_episodes": 148
}
},
{
"node": {
"id": 136,
"title": "Hunter x Hunter",
"main_picture": {
"medium": "https://api-cdn.myanimelist.net/images/anime/8/19473.jpg",
"large": "https://api-cdn.myanimelist.net/images/anime/8/19473l.jpg"
},
"num_episodes": 62
}
}
]
}
Reference
The following section outlines the reference of myanimelistpy.
MyAnimeList
- class myanimelist.MyAnimeList(client_id)
Methods |
---|
- Parameters:
client_id (str) - MyAnimeList Client ID.
Methods
- getAnimeList(anime_name, limit=100, offset=0, fields=[])
Returns a list of anime by name.
- Parameters:
anime_name(str) - Name of the anime/series.
limit(Optional[int]) - The maximum size of the list. The default value is 100.
offset(Optional[int]) - The list offset. The default value is 0.
fields(Optional[List [str]]) - List of fields used to show more information about the anime. If is empty, the default fields are id, title and main_picture.
- Raises:
ValueError - The ‘field’ is not a valid field!
- Returns:
List of animes.
- Return type:
- getAnimeListInDict(anime_name, limit=100, offset=0, fields=[])
Returns a list of dictionaries containing the anime by name.
- Parameters:
anime_name(str) - Name of the anime/series.
limit(Optional[int]) - The maximum size of the list. The default value is 100.
offset(Optional[int]) - The list offset. The default value is 0.
fields(Optional[List [str]]) - List of fields used to show more information about the anime. If is empty, the default fields are id, title and main_picture.
- Raises:
ValueError - The ‘field’ is not a valid field!
- Returns:
List of animes in dict type.
- Return type:
- getAnimeListInJSON(anime_name, limit=100, offset=0, fields=[])
Returns a JSON stringified containing the list of anime by name.
- Parameters:
anime_name(str) - Name of the anime/series.
limit(Optional[int]) - The maximum size of the list. The default value is 100.
offset(Optional[int]) - The list offset. The default value is 0.
fields(Optional[List [str]]) - List of fields used to show more information about the anime. If is empty, the default fields are id, title and main_picture.
- Raises:
ValueError - The ‘field’ is not a valid field!
- Returns:
List of animes in JSON format.
- Return type:
Services
Services that are used in the library.
Methods |
---|
- services.validateFields(fields)
Validate the fields provided.
Parameters: - fields(List [str]) - List of fields.
- Raises:
ValueError - The ‘field’ is not a valid field!
- Returns:
If the fields are valid or not.
- Return type:
Models
Models are classes that are received from MyAnimeList and are not meant to be created by the user of the library.
Danger
The classes listed below are not intended to be created by users and are also read-only.
For example, this means that you should not make your own Anime instances nor should you modify the Anime instance yourself.
AlternativeTitles
- class models.alternativeTitles.AlternativeTitles(synonyms, english, japanese)
Methods |
---|
- Parameters:
Methods
- getSynonyms()
- getEnglish()
English version.
- Return type:
- getJapanese()
Japanese version.
- Return type:
Anime
- class models.anime.Anime(node, fields)
Methods |
Methods |
---|---|
- Parameters:
Methods
- getId()
Anime ID.
- Return type:
- getTitle()
Anime title.
- Return type:
- getMainPicture()
Anime main picture.
- Return type:
- getAlternativeTitle()
The alternative title of the anime.
- Return type:
- getStartDate()
The anime start date. Format
YYYY-mm-dd
.
- Return type:
- getEndDate()
The anime end date. Format
YYYY-mm-dd
.
- Return type:
- getSynopsis()
Anime synopsis.
- Return type:
- getMean()
Mean score.
- Return type:
- getRank()
Anime rank.
- Return type:
- getPopularity()
Anime popularity.
- Return type:
- getNumUserList()
The number of users who have the anime in their list.
- Return type:
- getNumScoringUsers()
The number of users who rated the anime.
- Return type:
- getNsfwClassification()
Anime NSFW classification.
- Return type:
- getGenres()
- getCreatedAt()
Timestamp of anime creation in MyAnimeList database.
- Return type:
- getUpdatedAt()
Timestamp of anime update in MyAnimeList database.
- Return type:
- getMediaType()
Anime media type.
- Return type:
- getStatus()
Airing status.
- Return type:
- getNumEpisodes()
The total number of episodes of this series. If unknown, it is 0.
- Return type:
- getStartSeason()
Anime start season.
- Return type:
- getBroadcast()
- getSource()
Original work.
- Return type:
- getAvgEpisodeDurationInSeconds()
Average length of episode in seconds.
- Return type:
- getRating()
Anime rating.
- Return type:
- getStudios()
- getPictures()
- getBackground()
- getRelatedAnimes()
List of related animes.
Important
You cannot contain this field in a list.
- Return type:
List [RelatedNode] | None
- getRelatedMangas()
List of related mangas.
Important
You cannot contain this field in a list.
- Return type:
List [RelatedNode] | None
- getRecommendations()
Summary of recommended anime for those who like this anime.
Important
You cannot contain this field in a list.
- Return type:
List [Recommendation] | None
- getStatistics()
Anime statistics on MyAnimeList.
Important
You cannot contain this field in a list.
- Return type:
List [Statistics] | None
Broadcast
- class models.broadcast.Broadcast(day_of_the_week, start_time)
Methods |
---|
- Parameters:
day_of_the_week (DayWeekEnum) - Day of the week broadcast in Japan time.
start_time (str) - Time in hours format that is broadcasted.
Methods
- getDayOfTheWeek()
Broadcast day of the week.
- Return type:
- getStartTime()
Anime start time in JST.
- Return type:
Genre
- class models.genre.Genre(id, name)
Methods |
---|
Methods
- getId()
Genre ID.
- Return type:
- getName()
Genre name.
- Return type:
Node
- class models.node.Node(id, title, main_picture)
Methods |
---|
Methods
- getId()
Anime or manga ID.
- Return type:
- getTitle()
Anime or manga title.
- Return type:
- getMainPicture()
Anime or manga main picture.
- Return type:
Picture
- class models.picture.Picture(large, medium)
Methods |
---|
- Parameters:
Methods
- getLarge()
Large size picture.
- Return type:
- getMedium()
Medium size picture.
- Return type:
Recommendation
- class models.recommendation.Recommendation(id, title, main_picture, num_recommendations)
Methods |
---|
- Parameters:
Methods
- getId()
Anime ID.
- Return type:
- getTitle()
Anime title.
- Return type:
- getMainPicture()
Anime main picture.
- Return type:
- getNumRecommendations()
Number of recommendations.
- Return type:
Season
- class models.season.Season(year, season)
Methods |
---|
- Parameters:
year (int) - Year of season.
season (SeasonEnum) - Season name.
Methods
- getYear()
Year of season.
- Return type:
- getSeason()
Season name.
- Return type:
Statistics
- class models.statistics.Statistics(num_list_users, status)
Methods |
---|
- Parameters:
num_list_users (int) - Number of users who added the anime to their list.
status (StatisticsStatus) - Users list status.
Methods
- getNumUserLis()
The number of users who have the anime in their list.
- Return type:
- getStatus()
Anime status in the users list.
- Return type:
StatisticsStatus
- class models.statisticsStatus.StatisticsStatus(watching, completed, on_hold, dropped, plan_to_watch)
Methods |
---|
- Parameters:
Methods
- getNumWatching()
The number of users who are watching the anime.
- Return type:
- getNumCompleted()
The number of users who are completed the anime.
- Return type:
- getNumOnHold()
The number of users who are waiting for the anime.
- Return type:
- getNumDropped()
The number of users who are dropped the anime.
- Return type:
- getNumPlanToWatch()
The number of users who plan to watch the anime.
- Return type:
Studio
- class models.studio.Studio(id, name)
Methods |
---|
Methods
- getId()
Studio ID.
- Return type:
- getName()
Studio name.
- Return type:
Enumerations
The library provides some enumerations to avoid the API from being stringly typed in case the strings change in the future.
All enumerations are subclasses of enum.Enum.
Warning
The enumerations listed below are not intended to be used by users and are also read-only.
AiringStatusEnum
-
enum enums.airingStatusEnum.AiringStatusEnum
Key |
Value |
---|---|
finished_airing |
Finished airing |
currently_airing |
Currently airing |
not_yet_aired |
Not yet aired |
DayWeekEnum
-
enum enums.dayWeekEnum.DayWeekEnum
Key |
Value |
---|---|
sunday |
0 |
monday |
1 |
tuesday |
2 |
wednesday |
3 |
thursday |
4 |
friday |
5 |
saturday |
6 |
FieldsEnum
-
enum enums.fieldsEnum.FieldsEnum
Key |
Value |
Key |
Value |
---|---|---|---|
id |
0 |
media_type |
16 |
title |
1 |
status |
17 |
main_picture |
2 |
num_episodes |
18 |
alternative_title |
3 |
start_season |
19 |
start_date |
4 |
broadcast |
20 |
end_date |
5 |
source |
21 |
synopsis |
6 |
average_episode_duration |
22 |
mean |
7 |
rating |
23 |
rank |
8 |
studios |
24 |
popularity |
9 |
pictures |
25 |
num_list_users |
10 |
background |
26 |
num_scoring_users |
11 |
related_anime |
27 |
nsfw |
12 |
related_manga |
28 |
genres |
13 |
recommendations |
29 |
created_at |
14 |
statistics |
30 |
updated_at |
15 |
Note
The keys pictures
, background
, related_anime
, related_manga
,
recommendations
, and statistics
cannot be in the fields parameter of
getAnimeList(), getAnimeListInDict() and
getAnimeListInJSON() methods.
MediaTypeEnum
-
enum enums.mediaTypeEnum.MediaTypeEnum
Key |
Value |
---|---|
unknown |
0 |
tv |
1 |
ova |
2 |
movie |
3 |
special |
4 |
ona |
5 |
music |
6 |
NsfwEnum
-
enum enums.nsfwEnum.NsfwEnum
Key |
Value |
---|---|
white |
This work is safe for work |
gray |
This work may be not safe for work |
black |
This work is not safe for work |
RatingEnum
-
enum enums.ratingEnum.RatingEnum
Key |
Value |
---|---|
g |
All Age |
pg |
Children |
pg_13 |
Teens 13 and Older |
r |
17+ (violence & profanity) |
r_plus |
Profanity & Mild Nudity |
rx |
Hentai |
RelationTypeEnum
-
enum enums.relationTypeEnum.RelationTypeEnum
Key |
Value |
---|---|
sequel |
Sequel |
prequel |
Prequel |
alternative_setting |
Alternative Setting |
alternative_version |
Alternative Version |
side_story |
Side Story |
parent_story |
Parent Story |
summary |
Summary |
full_story |
Full Story |
SeasonEnum
-
enum enums.seasonEnum.SeasonEnum
Key |
Value |
---|---|
winter |
Winter |
spring |
Spring |
summer |
Summer |
fall |
Fall |
SourceEnum
-
enum enums.sourceEnum.SourceEnum
Key |
Value |
---|---|
other |
Other |
original |
Original |
manga |
Manga |
four_koma_manga |
4 Koma manga |
web_manga |
Web manga |
digital_manga |
Digital manga |
novel |
Novel |
light_novel |
Light novel |
visual_novel |
Visual novel |
game |
Game |
card_game |
Card game |
book |
Book |
picture_book |
Picture book |
radio |
Radio |
music |
Music |
Installation
How to install the myanimelistpy library.
pip install myanimelistpy
or
# Linux/macOS
python3 -m pip install -U myanimelistpy
# Windows
py -m pip install -U myanimelistpy
Getting started
Is this your first time using the library? This is the place to get started!
Click here to check how to use myanimelispy and start developing with us.
Manuals
These pages go into great detail about everything the library can do.
Help
If you’re having any issues or questions with the library, head over to our GitHub issues page and let us know.