Skip to content

๐ŸŒธ Python's future Jikan API wrapper! With proper rate limiting! [WIP]

License

Notifications You must be signed in to change notification settings

THEGOLDENPRO/anmoku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Anmoku ๅฎ‰้ป™

A peaceful and fully typed MyAnimeList / Jikan Python API wrapper with caching and proper rate limiting.

Pypi Version Python Versions Pypi Downloads


Note

Anmoku is currently a work in progress so the features below may not be complete yet or experimental.

Features โœจ

  • Rate limiting ๐ŸŽ€ (with actual waiting).
  • Supports caching. โšก
  • Fully type hinted. ๐ŸŒŒ yes you heard me correctly

Examples โš—๏ธ

Anmoku is probably the simplest Jikan API wrapper you'll ever use. All you need is the client and the resource. ๐ŸŒŠ

from anmoku import Anmoku, AnimeCharacters

client = Anmoku(debug = True)

anime_characters = client.get(AnimeCharacters, id = 28851) # ID for the anime film "A Silent Voice".

for character in anime_characters:
    print(f"{character.name} ({character.url})")

client.close()

We also have an async client:

import asyncio
from anmoku import AsyncAnmoku, AnimeCharacters

async def main():

    client = AsyncAnmoku(debug = True)

    anime_characters = await client.get(AnimeCharacters, id = 28851) # ID for the anime film "A Silent Voice".

    for character in anime_characters:
        print(f"{character.name} ({character.url})")

    await client.close()

asyncio.run(main())

Output:

[DEBUG] (anmoku) - [AsyncAnmoku] GET --> https://api.jikan.moe/v4/anime/28851/characters
Ishida, Shouya (https://myanimelist.net/character/80491/Shouya_Ishida)
Nishimiya, Shouko (https://myanimelist.net/character/80243/Shouko_Nishimiya)
Headteacher (https://myanimelist.net/character/214351/Headteacher)
Hirose, Keisuke (https://myanimelist.net/character/97569/Keisuke_Hirose)
Ishida, Maria (https://myanimelist.net/character/97943/Maria_Ishida)
Ishida, Sister (https://myanimelist.net/character/118723/Sister_Ishida)
# ... more characters below but I cut them off for the convenience of this readme

Searching! ๐Ÿคฉ

Here are some searching examples you can try:

from anmoku import Anmoku, Character

client = Anmoku(debug = True)

characters = client.search(Character, "anya forger")

for character in characters:
    print(f"{character.name} ({character.image.url})")

client.close()

Merge that with gradio and you have a GUI.

import gradio # pip install gradio
from anmoku import Anime, Anmoku, RatelimitError
client = Anmoku(debug = True)
def search_anime(query: str):
anime_list = []
try:
anime_list = client.search(Anime, query)
except RatelimitError as e: # NOTE: This is here because rate limiting hasn't been implemented yet in this version.
raise gradio.Error(e.message)
return [(x.image.get_image(), str(x.name)) for x in anime_list]
demo = gradio.Interface(
search_anime,
inputs = "text",
outputs = gradio.Gallery(height = 600)
)
if __name__ == "__main__":
demo.launch(show_api = False)

gradio_gui.mp4

Type hinting support! ๐ŸŒŒ

API responses in our library are strongly typed.

On top of that, we even provide class interfaces if you wish for stability and ease of use.


Python's future Jikan API wrapper.