animeapi-python is a Python wrapper for the AnimeAPI made by nattadasu.
The wrapper is released with type hints and async support in mind for ease of use and is compatible with Python 3.7 or higher.
pip install animeapi-pyDepending on your system, you may need to use pip3 instead of
pip, or sudo pip instead of pip.
- Python 3.7 or higher
- aiohttp (for async support)
- dacite
- requests
- typing_extensions (for Python <= 3.8)
import animeapi
with animeapi.AnimeAPI() as api:
# Get anime relation data for the anime with ID 1 on MyAnimeList
mal = api.get_anime_relations(1, animeapi.Platform.MYANIMELIST)
print(mal)
# Get list of anime available on AniList
anilist = api.get_list_anime_relations(animeapi.Platform.ANILIST)
print(anilist[:2]) # Print first two results
# Get dictionary of anime available on Kitsu
kitsu = api.get_dict_anime_relations(animeapi.Platform.KITSU)
print(kitsu['1']) # Print data for Cowboy BebopWe recommend using the with statement to create an instance of
AnimeAPI as we designed the wrapper to be easy to switch between
sync and async, although you can also use AnimeAPI directly on
sync methods only.
Similarly, for async, you just need to replace AnimeAPI with
AsyncAnimeAPI and use await on the methods.
You must use the wrapper in with statement, or you will receive
RuntimeError exception.
import asyncio
import animeapi
async def main():
async with animeapi.AsyncAnimeAPI() as api:
# Get anime relation data for the anime with ID 1 on MyAnimeList
mal = await api.get_anime_relations(1, animeapi.Platform.MYANIMELIST)
print(mal)
# Get list of anime available on AniList
anilist = await api.get_list_anime_relations(animeapi.Platform.ANILIST)
print(anilist[:2]) # Print first two results
# Get dictionary of anime available on Kitsu
kitsu = await api.get_dict_anime_relations(animeapi.Platform.KITSU)
print(kitsu['1']) # Print data for Cowboy Bebop
if __name__ == "__main__":
asyncio.run(main())You can find the documentation for the wrapper here
get_anime_relations(title_id: str | int, platform: str | Platform, media_type: str | TraktMediaType | TmdbMediaType | None = None, title_season: int | None) -> AnimeRelation
This method equals to the /:platform/:title_id endpoint on the API.
# Get anime relation data for the anime with ID 1 on MyAnimeList
mal = api.get_anime_relations(1, animeapi.Platform.MYANIMELIST)
print(mal)
# Get anime relation data for Trakt shows with season
trakt = api.get_anime_relations(152334, animeapi.Platform.TRAKT,
media_type=animeapi.TraktMediaType.SHOWS,
title_season=3)
print(trakt)
# Get anime relation data for TMDB TV shows
tmdb = api.get_anime_relations(12345, animeapi.Platform.THEMOVIEDB,
media_type=animeapi.TmdbMediaType.TV)
print(tmdb)
# Get anime relation data for The TVDB with season
tvdb = api.get_anime_relations(76885, animeapi.Platform.THETVDB,
title_season=1)
print(tvdb)This method equals to the /:platform endpoint on the API. Use this
method if you want to get complete data for all anime available on a
platform and wanted to be able to access the data by the anime ID
faster.
# Get dictionary of anime available on Kitsu
kitsu = api.get_dict_anime_relations(animeapi.Platform.KITSU)
print(kitsu['1']) # Print data for Cowboy BebopThis method equals to the /:platform() endpoint on the API.
# Get list of anime available on AniList
anilist = api.get_list_anime_relations(animeapi.Platform.ANILIST)
print(anilist[:2]) # Print first two resultsThis method equals to the /animeapi endpoint on the API.
# Get list of anime available on AnimeAPI
animeapi_list = api.get_list_index()
print(animeapi_list[:2]) # Print first two resultsThis method equals to the /status endpoint on the API.
# Get status of AnimeAPI
status = api.get_status()
print(status)This method equals to the /heartbeat endpoint on the API.
# Get heartbeat of AnimeAPI
heartbeat = api.get_heartbeat()
print(heartbeat)This method equals to the /updated endpoint on the API.
# Get last updated time of AnimeAPI
updated = api.get_updated_time()
print(updated)
print(updated.datetime()) # Convert to datetime classanimeapi-py is licensed under the GNU Affero General Public License
v3.0.