Skip to main content

MAL API An unofficial MyAnimeList API for Python 3

Project description

Mal4py API Banner Python Lang

MAL4Py

MAL API An unofficial MyAnimeList API for Python 3.

Currently, MAL4Py is a small package for download and sync information from MyAnimeList.

Contributing Welcome Tests Status

Version 0.1.5

API Documentation

MAL API v2 Beta Documentation

Installation and Usage

To install the library:


pip install -U mal4py

To import the library:

from mal4py import *

Example

To call the API, first you need to create an object Auth.

Auth Login Example

import  asyncio
from mal4py import Auth, get_new_code_verifier, MalToken

"""
	For all cases you must declarate Auth object
"""
# ID Client MAL App Android, recomend replace for own ID Client
auth = Auth("6114d00ca681b7701d1e15fe11a4987e") 
# if your APP has a Client Secret; OMIT in all other cases (i.e. you selected "Android", "iOS", or "Other" as App Type)
auth = Auth("my_clientID","my_clientSecret") 

# UNOFFICIAL WAY TO LOGIN
"""
	This way login can execute basic querys to MAL API, but only unstable_login can you edit user info.
"""

# If you use this way, must load Id Client MAL "6114d00ca681b7701d1e15fe11a4987e" others Id Client Don't Support way

# login with user and password unstable way
account = asyncio.run(auth.unstable_login("my_user","my_password"))

# Guest login without user and password unstable way
account = asyncio.run(auth.guest_login())


# OFFICIAL WAY TO LOGIN (recomended)
""" 
	OAUTH Way generate Code
"""
code_verifier = get_new_code_verifier()
url = auth.get_oauth_url(code_verifier)
print(url)

# Open returned url, accept oauth and use returned code to authorize

authorization_code = input('Copy-paste the Authorization Code: ').strip()
account = asyncio.run(auth.authorize_with_code(authorization_code,code_verifier))

"""
	Load Token saved previously
"""

# Load Token from saved String

jsontoken = '{"token_type":"Bearer","expires_in":xxx,"access_token":"my_access_Token","refresh_token":"my_refresh_token"}'
account = auth.authorize_with_json_string(jsontoken)

# Load Token from saved Dict

token = {"token_type":"Bearer","expires_in":xxx,"access_token":"my_access_Token","refresh_token":"my_refresh_token"}
account = auth.authorize_with_json_obj(token)

# Other way to Load Token load from MalToken object saved

mal_token = MalToken._from_json_string(jsontoken)
# Or
mal_token = MalToken._from_json_obj(token)
# Load MalToken
account = auth.load_token(mal_token)

You can generate Token and load usign this script of ZeroCrystal

Search Query Example

from mal import MalAccount


# Query Anime for all login types
# the query 'q' value must be minimum 3 characters

search = account.anime.get_details(anime_id=44511)
search = account.anime.get_list("chainsaw",limit=3)
search = account.anime.get_seasonal(2022,"winter",limit=3)
search = account.anime.get_ranking(limit=3)


# Query Anime for oAuth only or password and login user

search = account.anime.get_suggested(limit=3)


# Query Manga for all login types

search = account.manga.get_details(manga_id=13)
search = account.manga.get_list("chainsaw",limit=3)
search = account.manga.get_ranking(limit=3)


# Query Forum for all login types
# Actually MAL API have problems with integrity the object returned. (THIS BETA)

search = account.forum.get_board()
search = account.forum.get_topic_detail(topic_id=41)
search = account.forum.get_topics(q="love",subboard_id=2,board_id=0)


# Query User for only oAuth or user and password login 

search = account.user.get_my_info()
search = account.user.update_mangalist_status(13,{"status":"reading","is_rereading":False,"score":8,"num_volumes_read":1,"num_chapters_read":2,"priority":1,"num_times_reread":0,"reread_value":0,"tags":"Myread","comments":"Amazing Manga"})
search = account.user.delete_mangalist_item(13)
search = account.user.get_mangalist()
search = account.user.update_animelist_status(21,{"status":"on_hold","is_rewatching":False,"score":9,"num_watched_episodes":110,"priority":0,"num_times_rewatched":0,"rewatch_value":0,"tags":"","comments":"Me gusta la serie"})
search = account.user.delete_animelist_item(21)
search = account.user.get_animelist(status="watching")

References

For each parameter required in any query you can review the documentation at MAL API

This project was inspired by Node-MyAnimeList and Python MAL API projects.

Thanks to them.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mal4py-0.1.5.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mal4py-0.1.5-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mal4py-0.1.5.tar.gz.

File metadata

  • Download URL: mal4py-0.1.5.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mal4py-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a951ac4eaccf91c4a5716f2968afb6fd1ec3e7e47c8e464912587ffbcf982c68
MD5 008a124fcafccdcbc4c9596870cf61cd
BLAKE2b-256 c4146bd98d9b048a138d488fb35ee9d8782e1a6cba6de4872ba10f879e3bacae

See more details on using hashes here.

File details

Details for the file mal4py-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: mal4py-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mal4py-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8d3790c9afc523c3613580af0dde7afbe059c92e53167d5043749d8a11a1a9d6
MD5 74ac8613676ffbba97dbcab337d7f57c
BLAKE2b-256 5c2a4afa3fad00328d24f8c551e6f762576f0a578f0d67c86a5a8c406627c834

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page