A simple Python 3 library for Anilist.
Find a file
2025-01-03 22:27:50 -03:00
.github/workflows chore(workflow): rollback ubuntu version to 20.04 2025-01-03 22:27:50 -03:00
anilist refactor: rollback type hints to py 3.8 2024-12-28 22:40:39 -03:00
tests Large refactoring to simplify code and remove duplicate code (#13) 2024-09-02 23:57:20 -03:00
.gitignore Fix gitignore 2021-11-13 02:12:54 -05:00
CHANGELOG.md Large refactoring to simplify code and remove duplicate code (#13) 2024-09-02 23:57:20 -03:00
LICENSE chore: update to satisfy rye 2024-12-28 21:55:12 -03:00
MANIFEST.in Fix setuptools resource detection 2021-11-13 02:12:51 -05:00
MANIFEST.in.license anilist: happy new year (too late i know) 2022-02-16 21:18:43 -03:00
pyproject.toml refactor: rollback type hints to py 3.8 2024-12-28 22:40:39 -03:00
README.md chore: min py 3.7 -> 3.8 2024-12-28 21:56:06 -03:00
requirements-dev.lock refactor: rollback type hints to py 3.8 2024-12-28 22:40:39 -03:00
requirements.lock chore: update to satisfy rye 2024-12-28 21:55:12 -03:00
requirements.txt anilist: happy new year (too late i know) 2022-02-16 21:18:43 -03:00
requirements_dev.txt anilist: happy new year (too late i know) 2022-02-16 21:18:43 -03:00
tox.ini anilist: happy new year (too late i know) 2022-02-16 21:18:43 -03:00

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.8 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.