Skip to content

AmanoTeam/python-anilist

Repository files navigation

python-anilist

License Tests Code style Contributors PyPi

A simple wrapper with full support for asyncio made in Python 3 for Anilist using httpx.

Requirements

  • Python 3.7 or higher.
  • httpx 0.14 or higher.

Installation

NOTE: If python3 is "not a recognized command" try using python instead.

For the latest stable version:

python3 -m pip install python-anilist

For the latest development version:

python3 -m pip install git+https://github.com/AmanoTeam/python-anilist.git#egg=python-anilist

Basic starting guide

First, import the module

import anilist

Next, define the client to interact with the API

client = anilist.Client()

You can search for the name of something on the site using:

  • client.search_user(name, limit=10)
  • client.search_anime(name, limit=10)
  • client.search_manga(name, limit=10)
  • client.search_character(name, limit=10)
  • client.search_staff(name, limit=10)

If you know the ID of something, then use the get() commands instead:

  • client.get_user(ID)
  • client.get_anime(ID) etc.

Example code usage:

import anilist

client = anilist.Client()

# a search returns a tuple (A, B) with A being the main data of the search,
# and B being a PageInfo object containing info about the page of the search result
search_result: tuple[list, PageInfo] = client.search_anime("madoka", limit=10)

madoka_list: list[Anime] = search_result[0]  # taking "A" from the above tuple, this is a list of "Anime" objects

madoka_magica: Anime = madoka_list[0]  # this chooses the first anime in the list of search results

print(madoka.title, madoka.id)  # print that anime's title and anilist.co ID

>>> {'romaji': 'Mahou Shoujo Madoka☆Magica', 'english': 'Puella Magi Madoka Magica', 'native': '魔法少女まどか☆マギカ'} 9756

What's left to do?

  • Write the API Documentation.
  • Show some examples.

Credits

License

Copyright © 2021-2023 AmanoTeam and the python-anilist contributors

Licensed under the Expat/MIT license. This project is also REUSE compliant. See individual files for more copyright information.