AnimeAPI Reference Docs

Synchronous Class (AnimeAPI)

class animeapi.AnimeAPI(base_url: Version | str = Version.V3, timeout: int | None = 10, headers: Dict[str, Any] | None = None, suppress_warnings: bool = False)

The main class for interacting with the aniapi API

__init__(base_url: Version | str = Version.V3, timeout: int | None = 10, headers: Dict[str, Any] | None = None, suppress_warnings: bool = False) None

Initializes the AnimeAPI class

Parameters:
  • base_url (Union[models.Version, str] (optional)) – The base URL to use for requests, defaults to models.Version.V3

  • timeout (int (optional)) – The timeout for requests, defaults to 10

  • headers (Dict[str, Any] (optional)) – The headers to use for requests, defaults to None

  • suppress_warnings (bool (optional)) – Suppress warnings about server version, defaults to False

get_anime_relations(title_id: str | int, platform: str | Platform, media_type: TraktMediaType | TmdbMediaType | str | None = None, title_season: int | None = None) AnimeRelation

Gets the relations for an anime

Parameters:
  • title_id (Union[str, int]) – The ID of the anime

  • platform (Union[str, models.Platform]) – The platform to get the relations from

  • media_type (Union[models.TraktMediaType, models.TmdbMediaType, str, None] (optional)) – The media type to get the relations from, defaults to None

  • title_season (Optional[int] (optional)) – The season of the anime in Trakt, defaults to None

Returns:

The relations for the anime

Return type:

models.AnimeRelation

Raises:
  • excepts.MissingRequirement – Raised if the platform is Trakt or TMDB but no media_type is provided

  • requests.HTTPError – Raised if the request fails

  • ValueError – Raised if the AnimeAPI does not support the feature

get_dict_anime_relations(platform: str | Platform) Dict[str, AnimeRelation]

Gets the relations for anime available on the platform as a dictionary

Parameters:

platform (Union[str, models.Platform]) – The platform to get the relations from

Returns:

The relations for the anime

Return type:

Dict[str, models.AnimeRelation]

Raises:
  • requests.HTTPError – Raised if the request fails

  • ValueError – Raised if the platform is trakt but the title_season is 0

get_heartbeat() Heartbeat

Gets the heartbeat of the API

Returns:

The heartbeat of the API

Return type:

models.Heartbeat

Raises:

requests.HTTPError – Raised if the request fails

get_list_anime_relations(platform: str | Platform) List[AnimeRelation]

Gets the relations for anime available on the platform as a list

Parameters:

platform (Union[str, models.Platform]) – The platform to get the relations from

Returns:

The relations for the anime

Return type:

List[models.AnimeRelation]

Raises:
  • ValueError – Raised if the platform is trakt but the title_season is 0

  • requests.HTTPError – Raised if the request fails

get_list_index() List[AnimeRelation]

Get AnimeAPI full list index of known anime in the database

Returns:

The list index of known anime in the database

Return type:

List[models.AnimeRelation]

Raises:

requests.HTTPError – Raised if the request fails

get_status() ApiStatus

Gets the status of the API

Returns:

The status of the API

Return type:

models.ApiStatus

Raises:

requests.HTTPError – Raised if the request fails

get_updated_time() Updated

Gets the time the database was last updated, a subset/simple request from /status endpoint

Returns:

The time the database was last updated

Return type:

models.Updated

Raises:

requests.HTTPError – Raised if the request fails

Asynchronous Class (AsyncAnimeAPI)

class animeapi.AsyncAnimeAPI(*args, **kwargs)

The main class for interacting with the aniapi API

__init__(*args, **kwargs) None

Initializes the AnimeAPI class

Parameters:
  • base_url (Union[models.Version, str] (optional)) – The base URL to use for requests, defaults to models.Version.V3

  • timeout (int (optional)) – The timeout for requests, defaults to 10

  • headers (Dict[str, Any] (optional)) – The headers to use for requests, defaults to None

  • suppress_warnings (bool (optional)) – Suppress warnings about server version, defaults to False

async close() None

Closes the session

async get_anime_relations(title_id: str | int, platform: str | Platform, media_type: TraktMediaType | TmdbMediaType | str | None = None, title_season: int | None = None) AnimeRelation

Gets the relations for an anime

Parameters:
  • title_id (Union[str, int]) – The ID of the anime

  • platform (Union[str, models.Platform]) – The platform to get the relations from

  • media_type (Union[models.TraktMediaType, models.TmdbMediaType, str, None] (optional)) – The media type to get the relations from, defaults to None

  • title_season (Optional[int] (optional)) – The season of the anime in Trakt, defaults to None

Returns:

The relations for the anime

Return type:

models.AnimeRelation

Raises:
  • aiohttp.ClientResponseError – Raised if the request to the API fails

  • excepts.MissingRequirement – Raised if the platform is trakt but no media_type is provided

  • RuntimeError – Raised if the session is not initialized

  • ValueError – Raised if the AnimeAPI does not support the feature

async get_dict_anime_relations(platform: str | Platform) Dict[str, AnimeRelation]

Gets the relations for anime available on the platform as a dictionary

Parameters:

platform (Union[str, models.Platform]) – The platform to get the relations from

Returns:

The relations for the anime

Return type:

Dict[str, models.AnimeRelation]

Raises:
  • aiohttp.ClientResponseError – Raised if the request to the API fails

  • RuntimeError – Raised if the session is not initialized

  • ValueError – Raised if the platform is trakt but the title_season is 0

async get_heartbeat() Heartbeat

Gets the heartbeat of the API

Returns:

The heartbeat of the API

Return type:

models.Heartbeat

Raises:
  • aiohttp.ClientResponseError – Raised if the request to the API fails

  • RuntimeError – Raised if the session is not initialized

async get_list_anime_relations(platform: str | Platform) List[AnimeRelation]

Gets the relations for anime available on the platform as a list

Parameters:

platform (Union[str, models.Platform]) – The platform to get the relations from

Returns:

The relations for the anime

Return type:

List[models.AnimeRelation]

Raises:
  • aiohttp.ClientResponseError – Raised if the request to the API fails

  • RuntimeError – Raised if the session is not initialized

  • ValueError – Raised if the platform is trakt but the title_season is 0

async get_list_index() List[AnimeRelation]

Get AnimeAPI full list index of known anime in the database

Returns:

The list index of known anime in the database

Return type:

List[models.AnimeRelation]

Raises:
  • aiohttp.ClientResponseError – Raised if the request to the API fails

  • RuntimeError – Raised if the session is not initialized

async get_status() ApiStatus

Gets the status of the API

Returns:

The status of the API

Return type:

models.ApiStatus

Raises:
  • aiohttp.ClientResponseError – Raised if the request to the API fails

  • RuntimeError – Raised if the session is not initialized

async get_updated_time() Updated

Gets the time the database was last updated, a subset/simple request from /status endpoint

Returns:

The time the database was last updated

Return type:

models.Updated

Raises:
  • aiohttp.ClientResponseError – Raised if the request to the API fails

  • RuntimeError – Raised if the session is not initialized

Models/Typings

animeapi.models

This module contains the dataclasses, enums, and other models used by the API.

class animeapi.models.AnimeRelation(title: str, anidb: int | None = None, anilist: int | None = None, animenewsnetwork: int | None = None, animeplanet: str | None = None, anisearch: int | None = None, annict: int | None = None, hikka: str | None = None, imdb: str | None = None, kaize: str | None = None, kaize_id: int | None = None, kitsu: int | None = None, livechart: int | None = None, myanimelist: int | None = None, nautiljon: str | None = None, nautiljon_id: int | None = None, notify: str | None = None, otakotaku: int | None = None, simkl: int | None = None, shoboi: int | None = None, shikimori: int | None = None, silveryasha: int | None = None, themoviedb: int | None = None, themoviedb_type: TmdbMediaType | None = None, trakt: int | None = None, trakt_season: int | None = None, trakt_type: TraktMediaType | None = None, letterboxd_lid: str | None = None, letterboxd_slug: str | None = None, letterboxd_uid: int | None = None, themoviedb_season_id: int | None = None, thetvdb: int | None = None, thetvdb_season_id: int | None = None, trakt_may_invalid: bool | None = None, trakt_season_id: int | None = None, trakt_slug: str | None = None)

Anime Relations Dataclass

letterboxd_lid: str | None = None

Letterboxd Letter ID, only used on 1st party API requests

letterboxd_slug: str | None = None

Letterboxd slug of the anime

letterboxd_uid: int | None = None

Letterboxd General ID, internally used

themoviedb_season_id: int | None = None

TheMovieDB season ID, only available for TV shows

thetvdb: int | None = None

The TVDB ID of the anime

thetvdb_season_id: int | None = None

The TVDB season ID

to_dict() TypedAnimeRelationDict

Converts the AnimeRelation object to a dictionary :return: The converted dictionary :rtype: TypedAnimeRelationDict

trakt_may_invalid: bool | None = None

Whether the entry is a split cour merged by Trakt/TMDB

trakt_season_id: int | None = None

Trakt Season ID

trakt_slug: str | None = None

Trakt slug of the anime

class animeapi.models.AnimeRelationBase(title: str, anidb: int | None = None, anilist: int | None = None, animenewsnetwork: int | None = None, animeplanet: str | None = None, anisearch: int | None = None, annict: int | None = None, hikka: str | None = None, imdb: str | None = None, kaize: str | None = None, kaize_id: int | None = None, kitsu: int | None = None, livechart: int | None = None, myanimelist: int | None = None, nautiljon: str | None = None, nautiljon_id: int | None = None, notify: str | None = None, otakotaku: int | None = None, simkl: int | None = None, shoboi: int | None = None, shikimori: int | None = None, silveryasha: int | None = None, themoviedb: int | None = None, themoviedb_type: TmdbMediaType | None = None, trakt: int | None = None, trakt_season: int | None = None, trakt_type: TraktMediaType | None = None)

Anime Relations Dataclass

anidb: int | None = None

aniDB ID of the anime, without the prefix

anilist: int | None = None

AniList ID of the anime

animenewsnetwork: int | None = None

Anime News Network ID of the anime

animeplanet: str | None = None

Anime-Planet slug of the anime

anisearch: int | None = None

aniSearch ID of the anime

annict: int | None = None

Annict ID of the anime

hikka: str | None = None

Hikka slug of the anime

imdb: str | None = None

IMDb ID of the anime, mostly for movies

kaize: str | None = None

Kaize slug of the anime

kaize_id: int | None = None

Kaize ID of the anime, used internally for the Kaize API

kitsu: int | None = None

Kitsu ID of the anime

livechart: int | None = None

LiveChart ID of the anime

myanimelist: int | None = None

MyAnimeList ID of the anime

nautiljon: str | None = None

Nautiljon slug in plus format of the anime

nautiljon_id: int | None = None

Nautiljon ID of the anime, used internally by Nautiljon

notify: str | None = None

Notify.moe Base64 of the anime

otakotaku: int | None = None

Otak Otaku ID of the anime

shikimori: int | None = None

Shikimori ID of the anime, without the prefix

shoboi: int | None = None

Shoboi ID of the anime

silveryasha: int | None = None

SilverYasha Database Tontonan Indonesia ID of the anime

simkl: int | None = None

SIMKL ID of the anime

themoviedb: int | None = None

TheMovieDB ID of the anime, can be movie or TV show

themoviedb_type: TmdbMediaType | None = None

TheMovieDB media type, can be movie or tv

title: str

Title of the anime

to_dict_base() TypedAnimeRelationBaseDict

Converts the AnimeRelationBase object to a dictionary :return: The converted dictionary :rtype: TypedAnimeRelationBaseDict

trakt: int | None = None

Trakt ID of the anime

trakt_season: int | None = None

Trakt Season number, None if its a movie

trakt_type: TraktMediaType | None = None

Trakt Media Type of the anime

class animeapi.models.ApiStatus(mainrepo: str, updated: UpdatedStruct, contributors: List[str], sources: List[str], license: str, website: str, counts: CountStruct, endpoints: Dict[str, str])

API Status Dataclass

contributors: List[str]

List of contributors of the API

counts: CountStruct

Counts of the API

endpoints: Dict[str, str]

Endpoints of the API

license: str

License of the API

mainrepo: str

Main repository of the API

sources: List[str]

List of sources used by the API

updated: UpdatedStruct

Last updated of the API

website: str

Website of the API

class animeapi.models.CountStruct(total: int, anidb: int | None = None, anilist: int | None = None, animenewsnetwork: int | None = None, animeplanet: int | None = None, anisearch: int | None = None, annict: int | None = None, hikka: int | None = None, imdb: int | None = None, kaize: int | None = None, kitsu: int | None = None, letterboxd: int | None = None, livechart: int | None = None, myanimelist: int | None = None, nautiljon: int | None = None, notify: int | None = None, otakotaku: int | None = None, simkl: int | None = None, shikimori: int | None = None, shoboi: int | None = None, silveryasha: int | None = None, themoviedb: int | None = None, thetvdb: int | None = None, trakt: int | None = None)

Count Struct Dataclass

anidb: int | None = None

aniDB count

anilist: int | None = None

AniList count

animenewsnetwork: int | None = None

Anime News Network count

animeplanet: int | None = None

Anime-Planet count

anisearch: int | None = None

aniSearch count

annict: int | None = None

Annict count

hikka: int | None = None

Hikka count

imdb: int | None = None

IMDb count

kaize: int | None = None

Kaize count

kitsu: int | None = None

Kitsu count

letterboxd: int | None = None

Letterboxd count

livechart: int | None = None

LiveChart count

myanimelist: int | None = None

MyAnimeList count

nautiljon: int | None = None

Nautiljon count

notify: int | None = None

Notify.moe count

otakotaku: int | None = None

Otak Otaku count

shikimori: int | None = None

Shikimori count

shoboi: int | None = None

Shoboi count

silveryasha: int | None = None

SilverYasha Database Tontonan Indonesia count

simkl: int | None = None

SIMKL count

themoviedb: int | None = None

TheMovieDB count

thetvdb: int | None = None

The TVDB count

total: int

Total count

trakt: int | None = None

Trakt count

class animeapi.models.Heartbeat(status: str, code: int, response_time: str, request_time: str, request_epoch: float)

Heartbeat Dataclass

code: int

Status code of the API

datetime(tz: timezone = datetime.timezone.utc) datetime

Returns a datetime object of the heartbeat’s request epoch

Parameters:

tz (timezone) – The timezone to use, defaults to timezone.utc

Returns:

The datetime object

Return type:

datetime

request_epoch: float

Request epoch of the API

request_time: str

Request time of the API

response_time: str

Response time of the API

status: str

Status of the API

class animeapi.models.IdsMoeAnimeRelation(title: str, anidb: int | None = None, anilist: int | None = None, animenewsnetwork: int | None = None, animeplanet: str | None = None, anisearch: int | None = None, annict: int | None = None, hikka: str | None = None, imdb: str | None = None, kaize: str | None = None, kaize_id: int | None = None, kitsu: int | None = None, livechart: int | None = None, myanimelist: int | None = None, nautiljon: str | None = None, nautiljon_id: int | None = None, notify: str | None = None, otakotaku: int | None = None, simkl: int | None = None, shoboi: int | None = None, shikimori: int | None = None, silveryasha: int | None = None, themoviedb: int | None = None, themoviedb_type: TmdbMediaType | None = None, trakt: int | None = None, trakt_season: int | None = None, trakt_type: TraktMediaType | None = None, themoviedb_season: int | None = None, data_hash: str | None = None)

Anime Relations Dataclass for ids.moe

data_hash: str | None = None

Data hash of the anime

themoviedb_season: int | None = None

TheMovieDB season number, only available for TV shows

to_dict() TypedIdsMoeAnimeRelationDict

Converts the IdsMoeAnimeRelation object to a dictionary :return: The converted dictionary :rtype: TypedIdsMoeAnimeRelationDict

class animeapi.models.Platform(value)

Supported Platforms Enum

ANIDB = 'anidb'

AniDB

ANILIST = 'anilist'

AniList

ANIMENEWSNETWORK = 'animenewsnetwork'

Anime News Network

ANIMEPLANET = 'animeplanet'

Anime-Planet

ANISEARCH = 'anisearch'

aniSearch, a German anime database

ANNICT = 'annict'

Annict, a Japanese anime database

HIKKA = 'hikka'

Hikka, Ukrainian anime database

IDS = 'ids'

ids.moe, a 3rd party, backward-compatible forked AnimeAPI server

IMDB = 'imdb'

IMDb, only for v3 API or above

KAIZE = 'kaize'

Kaize

KITSU = 'kitsu'

Kitsu

LETTERBOXD = 'letterboxd'

Letterboxd, only for v3 API or above

LIVECHART = 'livechart'

LiveChart, a TV schedule database

MYANIMELIST = 'myanimelist'

MyAnimeList

NAUTILJON = 'nautiljon'

Nautiljon, a French anime database

NOTIFYMOE = 'notify'

Notify.moe

OTAKOTAKU = 'otakotaku'

Otak Otaku, an Indonesian anime database

SHIKIMORI = 'shikimori'

Shikimori, a Russian anime database

SHOBOI = 'shoboi'

Shobocalendar, a TV schedule database in Japanese

SILVERYASHA = 'silveryasha'

SilverYasha Database Tontonan Indonesia, an Indonesian anime database for aggregated streaming links

SIMKL = 'simkl'

SIMKL

THEMOVIEDB = 'themoviedb'

TheMovieDB, only for v3 API or above

THETVDB = 'thetvdb'

The TVDB, only for v3 API or above

TRAKT = 'trakt'

Trakt

class animeapi.models.TmdbMediaType(value)

TheMovieDB Media Type Enum

MOVIE = 'movie'

Movie

TV = 'tv'

TV Show

class animeapi.models.TraktMediaType(value)

Trakt Media Type Enum

MOVIES = 'movies'

Movie

SHOWS = 'shows'

Show

class animeapi.models.TypedAnimeRelationBaseDict

Typed Anime Relation Dictionary, used when user explicitly wants to use a dictionary using AnimeRelation.to_dict() method

anidb: int | None

aniDB ID of the anime, without the prefix

anilist: int | None

AniList ID of the anime

animenewsnetwork: int | None

Anime News Network ID of the anime

animeplanet: str | None

Anime-Planet slug of the anime

anisearch: int | None

aniSearch ID of the anime

annict: int | None

Annict ID of the anime

hikka: str | None

Hikka slug of the anime

imdb: str | None

IMDb ID of the anime, mostly for movies

kaize: str | None

Kaize slug of the anime

kaize_id: int | None

Kaize ID of the anime, used internally for the Kaize API

kitsu: int | None

Kitsu ID of the anime

livechart: int | None

LiveChart ID of the anime

myanimelist: int | None

MyAnimeList ID of the anime

nautiljon: str | None

Nautiljon slug in plus format of the anime

nautiljon_id: int | None

Nautiljon ID of the anime, used internally by Nautiljon

notify: str | None

Notify.moe Base64 of the anime

otakotaku: int | None

Otak Otaku ID of the anime

shikimori: int | None

Shikimori ID of the anime, without the prefix

shoboi: int | None

Shoboi ID of the anime

silveryasha: int | None

SilverYasha Database Tontonan Indonesia ID of the anime

simkl: int | None

SIMKL ID of the anime

themoviedb: int | None

TheMovieDB ID of the anime, can be movie or TV show

themoviedb_type: Literal['movie', 'tv'] | None

TheMovieDB media type, can be movie or tv

title: str

Title of the anime

trakt: int | None

Trakt ID of the anime

trakt_season: int | None

Trakt Season number, None if its a movie

trakt_type: Literal['shows', 'movies'] | None

Trakt Media Type of the anime

class animeapi.models.TypedAnimeRelationDict

Typed Anime Relation Dictionary, used when user explicitly wants to use a dictionary using AnimeRelation.to_dict() method

letterboxd_lid: str

Letterboxd Letter ID, only used on 1st party API requests

letterboxd_slug: str

Letterboxd slug of the anime

letterboxd_uid: int

Letterboxd General ID, internally used

themoviedb_season_id: int

TheMovieDB season ID, only available for TV shows

thetvdb: int

The TVDB ID of the anime

thetvdb_season_id: int

The TVDB season ID

trakt_may_invalid: bool

Whether the entry is a split cour merged by Trakt/TMDB

trakt_season_id: int

Trakt Season ID

trakt_slug: str

Trakt slug of the anime

class animeapi.models.TypedIdsMoeAnimeRelationDict

Typed Anime Relation Dictionary for ids.moe, used when user explicitly wants to use a dictionary using IdsMoeAnimeRelation.to_dict() method

data_hash: str

Data hash of the anime

themoviedb_season: int

TheMovieDB season number, only available for TV shows

class animeapi.models.Updated(message: str)

Class model for “Updated” path

datetime() datetime

Convert str response to datetime class

Returns:

the datetime object

Return type:

datetime

class animeapi.models.UpdatedStruct(timestamp: int, iso: str)

Updated Struct Dataclass

datetime(tz: timezone = datetime.timezone.utc) datetime

Returns a datetime object of the timestamp

Parameters:

tz (timezone = timezone.utc) – The timezone to use, defaults to UTC

Returns:

The datetime object

Return type:

datetime

iso: str

ISO 8601 formatted timestamp of the update

timestamp: int

Timestamp of the update

class animeapi.models.Version(value)

API Version Enum

V3 = 'https://animeapi.my.id'

Version 3

Exceptions

animeapi.excepts

This module contains the set of AnimeAPI’s exceptions.

exception animeapi.excepts.MissingRequirement

Raised if there is an error with the request

exception animeapi.excepts.UnsupportedVersion

Raised if the version is unsupported

Internal Converter

animeapi.converter

This module contains the set of AnimeAPI’s converters, which are used to convert the API’s responses to objects.

This module is not meant to be used directly. Use the API’s methods instead.

animeapi.converter.convert_api_status(data: Dict[str, str | Dict[str, Any]]) ApiStatus

Converts a dict to an ApiStatus object

Parameters:

data (Dict[str, Union[str, Dict[str, Any]]]) – The dict to convert

Returns:

The converted ApiStatus object

Return type:

ApiStatus

animeapi.converter.convert_arm(data: Dict[str, str | int | None]) AnimeRelation | IdsMoeAnimeRelation

Converts a dict to an AnimeRelation or IdsMoeAnimeRelation object

Parameters:

data (Dict[str, Union[str, int, None]]) – The dict to convert

Returns:

The converted AnimeRelation or IdsMoeAnimeRelation object

Return type:

Union[AnimeRelation, IdsMoeAnimeRelation]

animeapi.converter.convert_from_dict(data: Dict[str, Dict[str, str | int | None]]) Dict[str, AnimeRelation | IdsMoeAnimeRelation]

Converts a dict of dicts to a dict of AnimeRelation objects

Parameters:

data (Dict[str, Dict[str, Union[str, int, None]]]) – The dict to convert

Returns:

The converted dict

Return type:

Dict[str, Union[AnimeRelation, IdsMoeAnimeRelation]]

animeapi.converter.convert_from_list(data: List[Dict[str, str | int | None]]) List[AnimeRelation | IdsMoeAnimeRelation]

Converts a list of dicts to a list of AnimeRelation objects

Parameters:

data (List[Dict[str, Union[str, int, None]]]) – The list to convert

Returns:

The converted list

Return type:

List[Union[AnimeRelation, IdsMoeAnimeRelation]]

animeapi.converter.convert_heartbeat(data: Dict[str, str | float | int]) Heartbeat

Converts a dict to a Heartbeat object

Parameters:

data (Dict[str, Union[str, float, int]]) – The dict to convert

Returns:

The converted Heartbeat object

Return type:

Heartbeat

Indices and tables