AsyncDex API

This page contains all of the classes, attributes, and methods of the various parts of AsyncDex.

Client

class asyncdex.MangadexClient(*, username: Optional[str] = None, password: Optional[str] = None, refresh_token: Optional[str] = None, sleep_on_ratelimit: bool = True, session: Optional[aiohttp.client.ClientSession] = None, api_url: str = 'https://api.mangadex.org', anonymous: bool = False, **session_kwargs)[source]

The main client that runs preforms all of the method requests.

Warning

The client object should only be created under an async context. While it should be safe to initialize normally, the aiohttp ClientSession does not like this.

Warning

The client cannot ratelimit effectively if multiple clients are running on the same program. Furthermore, the ratelimit may not work if multiple other people are accessing the MangaDex API at the same time or the client is running on a shared network.

Parameters
  • username (str) – The username of the user to authenticate as. Leave blank to not allow login to fetch a new refresh token. Specifying the username without specifying the password is an error.

  • password (str) – The password of the user to authenticate as. Leave blank to not allow login to fetch a new refresh token. Specifying the password without specifying the username is an error.

  • refresh_token (str) – The refresh token to use. Leaving the username and password parameters blank but specifying this parameter allows the client to make requests using the refresh token for as long as it is valid. Once the refresh token is invalid, if the username and password are not specified, the client will throw Unauthorized, unless logout() is used to set the client to anonymous mode.

  • sleep_on_ratelimit (bool) – Whether or not to sleep when a ratelimit occurs or raise a Ratelimit. Defaults to True.

  • session (aiohttp.ClientSession) – The session object for the client to use. If one is not provided, the client will create a new session instead. This is useful for providing a custom session.

  • api_url (str) – The base URL for the MangaDex API. Useful for private instances or a testing environment. Should not include a trailing slash.

  • anonymous (bool) – Whether or not to force anonymous mode. This will clear the username and/or password.

  • session_kwargs – Optional keyword arguments to pass on to the aiohttp.ClientSession.

async __aenter__()[source]

Allow the client to be used with async with syntax similar to aiohttp.ClientSession.

async __aexit__(exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType])[source]

Exit the client. This will also close the underlying session object.

__repr__()str[source]

Provide a string representation of the client.

Returns

The string representation

Return type

str

async activate_account(code: str)[source]

Activate a MangaDex account.

New in version 0.5.

Parameters

code (str) – The code to activate.

anonymous_mode: bool

Whether or not the client is operating in Anonymous Mode, where it only accesses public endpoints.

api_base: str

The base URL for the MangaDex API, without a slash at the end.

async batch_authors(*authors: asyncdex.models.author.Author)[source]

Updates a lot of authors at once, reducing the time needed to update tens or hundreds of authors. This method requires the following permission: author.list

New in version 0.2.

Parameters

authors (Tuple[Author, ...]) – A tuple of all the authors (and artists) to update.

async batch_chapters(*chapters: asyncdex.models.chapter.Chapter)[source]

Updates a lot of chapters at once, reducing the time needed to update tens or hundreds of chapters. This method requires the following permission: chapter.list

New in version 0.3.

See also

ChapterList.get().

Parameters

chapters (Tuple[Chapter, ...]) – A tuple of all the chapters to update.

async batch_covers(*covers: asyncdex.models.cover_art.CoverArt)[source]

Updates a lot of covers at once, reducing the time needed to update tens or hundreds of covers. This method requires the following permission: cover.list

New in version 1.0.

Parameters

covers (Tuple[CoverArt, ...]) – A tuple of all the covers to update.

async batch_groups(*groups: asyncdex.models.group.Group)[source]

Updates a lot of groups at once, reducing the time needed to update tens or hundreds of groups. This method requires the following permission: scanlation_group.list

New in version 0.3.

Parameters

groups (Tuple[Group, ...]) – A tuple of all the groups to update.

async batch_manga_read(*mangas: asyncdex.models.manga.Manga)[source]

Find the read status for multiple mangas. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

mangas (Tuple[Manga, ...]) – A tuple of manga objects.

async batch_mangas(*mangas: asyncdex.models.manga.Manga)[source]

Updates a lot of mangas at once, reducing the time needed to update tens or hundreds of mangas. This method requires the following permission: manga.list

New in version 0.2.

Parameters

mangas (Tuple[Manga, ...]) – A tuple of all the mangas to update.

async close()[source]

Close the client.

New in version 0.4.

async convert_legacy(model: Type[asyncdex.client._LegacyModelT], ids: List[int])Dict[int, asyncdex.client._LegacyModelT][source]

Convert a list of legacy IDs to the new UUID system.

New in version 0.3.

Parameters
  • model (Type[Manga, Chapter, Tag, Group]) – The model that represents the type of conversion. The endpoint allows conversions of old mangas, chapters, tags, and groups.

  • ids (List[int]) – The list of integer IDs to convert.

Returns

A dictionary mapping old IDs to instances of the model with the new UUIDs.

Note

Except for tags, all other models will be lazy models. However, batch methods exist for all other models.

Return type

Dict[int, Model]

async create(username: str, password: str, email: str, login: bool = True, store_credentials: bool = True)[source]

Create an account.

New in version 0.5.

Parameters
  • username (str) – The username of the account.

  • password (str) – The password of the account.

  • email (str) – The email of the account.

  • login (bool) – Whether or not to log in to the API using the new account credentials. Defaults to True.

  • store_credentials (bool) –

    Whether or not to store the credentials inside the client class. Defaults to True.

    Note

    If the credentials are not stored but login is True, then the client will operate in refresh token only mode.

async create_author(name: str)asyncdex.models.author.Author[source]

Create a new author. This method requires authentication with the MangaDex API. This method requires the following permission: author.create

New in version 0.5.

Parameters

name (str) – The author’s name.

Returns

The new author.

Return type

Author

async create_cover(manga: Union[str, asyncdex.models.manga.Manga], file: Union[str, bytes, os.PathLike, BinaryIO])asyncdex.models.cover_art.CoverArt[source]

Create a new author. This method requires authentication with the MangaDex API. This method requires the following permission: cover.create

New in version 1.0.

Parameters
  • manga (Union[str, Manga]) – The manga that the cover should belong to. Either specify a manga object or the manga UUID.

  • file (Union[str, bytes, os.PathLike, BinaryIO]) – Either the path to a file or a binary file descriptor.

Returns

The new cover.

Return type

CoverArt

async create_group(name: str, members: Optional[List[asyncdex.models.user.User]], *, leader: Optional[asyncdex.models.user.User] = None)asyncdex.models.group.Group[source]

Create a scanlation group. This method requires authentication with the MangaDex API. This method requires the following permission: scanlation_group.create

New in version 0.5.

Parameters
  • name (str) – The name of the group.

  • members (List[User]) – The members of the group.

  • leader (User) – The leader of the group. Defaults to the logged in user.

Returns

A new group.

Return type

Group

async create_manga(*, title: Optional[Dict[str, str]] = None, alt_titles: Optional[List[Dict[str, str]]] = None, descriptions: Optional[Dict[str, str]] = None, authors: Optional[List[Union[str, asyncdex.models.author.Author]]] = None, artists: Optional[List[Union[str, asyncdex.models.author.Author]]] = None, links: Optional[asyncdex.models.manga.MangaLinks] = None, language: Optional[str] = None, last_volume: Optional[str] = None, last_chapter_number: Optional[str] = None, demographic: Optional[asyncdex.enum.Demographic] = None, status: Optional[asyncdex.enum.MangaStatus] = None, year: Optional[int] = None, rating: Optional[asyncdex.enum.ContentRating] = None, notes: Optional[str] = None, all_titles: Optional[Dict[str, asyncdex.models.title.TitleList]] = None)asyncdex.models.manga.Manga[source]

Create a manga. This method requires authentication with the MangaDex API. This method requires the following permission: manga.create

New in version 0.5.

Note

New mangas have to be approved by the mod team.

Parameters
  • title (Dict[str, str]) –

    The titles of the manga.

    Note

    See the documentation for the all_titles parameter to learn how to add all titles in one dictionary.

  • alt_titles (List[Dict[str, str]]) – Alternate titles to use.

  • all_titles (Dict[str, TitleList]) –

    A dictionary of a language code key and a TitleList as values.

    Warning

    Using title and all_titles will overwrite any values in the dictionary provided to title if a corresponding title for the same language code is found in all_titles.

    Using all_titles to set titles:

    from asyncdex import AttrDict, TitleList
    
    titles_en = ["Primary", "secondary", "tertiary"]
    titles_es = ["Primero, "segundo"]
    title_dict = AttrDict()
    title_dict["en"] = TitleList(titles_en)
    title_dict["es"] = TitleList(titles_es)
    
    manga = await client.create_manga(..., all_titles=title_dict)
    

  • descriptions (Dict[str, str]) – A dictionary of language codes to descriptions for that language.

  • authors (List[Author]) – A list of either Author objects or author UUIDs.

  • artists (List[Author]) – A list of either Author objects or author UUIDs.

  • links (MangaLinks) – An instance of MangaLinks containing the IDs for the manga.

  • language (str) – The original language of the manga.

  • last_volume (str) – The number of the last volume.

  • last_chapter_number (str) – The number of the last chapter.

  • demographic (Optional[Demographic]) – The manga’s demographic, or None to have no demographic.

  • status (Optional[MangaStatus]) – The manga’s status, or None to have no status.

  • year (int) – The year the manga started publication.

  • rating (Optional[CotentRating]) – The manga’s content rating, or None to use the default.

  • notes (str) – Optional notes to show to a moderator.

Raise

ValueError if the title field is None.

Returns

The new manga.

Return type

Manga

async finish_password_reset(code: str, new_password: str, store_new_password: bool = True)[source]

Finish the password reset process.

New in version 0.5.

Warning

The MangaDex API fails silently on password resets, meaning that if a password reset fails it will not tell you. Instead, future login attempts will fail. You can check if a reset is valid by calling login() with the username and new password. If it returns 401 then the password reset failed.

Parameters
  • code (str) – The code obtained from the sent email.

  • new_password (str) – The new password to set. Needs to be >8 characters.

  • store_new_password (bool) – Whether or not to store the password in the client. The password will not be stored if a corresponding username is not stored in the client class. Defaults to True.

Raises

ValueError if the password is <8 characters.

classmethod from_config(file_name: str, *, section_name: str = 'asyncdex')asyncdex.client.MangadexClient[source]

Create a new MangadexClient from values stored inside of a .ini config file.

The name of the keys should match the names of the parameters for the class constructor.

New in version 1.0.

Note

The config parser module used will not support interpolation in order to not cause weird bugs with any passwords that contain percentages.

Parameters
  • file_name (str) – The name of the config file. Can be an absolute or relative path.

  • section_name (str) – The name of the section containing login info. Defaults to AsyncDex.

Returns

A new instance of the client.

Return type

MangadexClient

classmethod from_environment_variables(*, username_variable_name: str = 'asyncdex_username', password_variable_name: str = 'asyncdex_password', refresh_token_variable_name: str = 'asyncdex_refresh_token', anonymous_variable_name: str = 'asyncdex_anonymous', sleep_on_ratelimit_variable_name: str = 'asyncdex_sleep_on_ratelimit', api_url_variable_name='asyncdex_api_url')asyncdex.client.MangadexClient[source]

Create a new MangadexClient from values stored inside environment variables.

New in version 1.0.

Note

If a value is missing for a parameter, the default value will be assumed.

Boolean Values These boolean values will be determined by the client to be a “false” value (case insensitive):

  • 0

  • false

  • off

  • no

  • n

  • -

All other values will be interrupted as a “true” value.

Parameters
  • username_variable_name (str) – The name of the environment variable that contains the username. Defaults to asyncdex_username.

  • password_variable_name (str) – The name of the environment variable that contains the password.

  • refresh_token_variable_name (str) – The name of the environment variable that contains the refresh token.

  • anonymous_variable_name (str) – The name of the environment variable that contains a boolean representing whether or not the client should operate in anonymous mode.

  • sleep_on_ratelimit_variable_name (str) – The name of the environment variable that contains a boolean representing whether or not the client should sleep on ratelimits.

  • api_url_variable_name (str) – The name of the environment variable that contains the base API url.

Returns

A new instance of the client.

Return type

MangadexClient

classmethod from_json(file_name: str)asyncdex.client.MangadexClient[source]

Create a new MangadexClient from values stored inside of a JSON file.

New in version 1.0.

Note

To use a JSON dict (not file), use ** to expand the dict, such as:

data = {"username": "Test", "password": "secret"}
client = MangadexClient(**data)
Parameters

file_name (str) – The name of the JSON file.

Returns

A new instance of the client.

Return type

MangadexClient

get_author(id: str)asyncdex.models.author.Author[source]

Get an author using it’s ID.

New in version 0.2.

Note

This method can also be used to get artists, since they are the same class.

Warning

This method returns a lazy Author instance. Call Author.fetch() on the returned object to see any values.

Parameters

id (str) – The author’s UUID.

Returns

A Author object.

Return type

Author

get_authors(*, name: Optional[str] = None, order: Optional[asyncdex.list_orders.AuthorListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.author.Author][source]

Creates a Pager for authors. This method requires the following permission: author.list

New in version 0.4.

Usage:

async for author in client.get_authors(name="Author Name"):
    ...
Parameters
  • name (str) – The name to search for.

  • order (AuthorListOrder) – The order to sort the authors 1.

  • limit (int) –

    Only return up to this many authors.

    Note

    Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Returns

A Pager for the authors.

Return type

Pager

get_chapter(id: str)asyncdex.models.chapter.Chapter[source]

Get a chapter using it’s ID.

New in version 0.3.

See also

ChapterList.get().

Warning

This method returns a lazy Chapter instance. Call Chapter.fetch() on the returned object to see any values.

Parameters

id (str) – The chapter’s UUID.

Returns

A Chapter object.

Return type

Chapter

get_chapters(*, title: Optional[str] = None, groups: Optional[Sequence[Union[str, asyncdex.models.group.Group]]] = None, uploader: Optional[Union[str, asyncdex.models.user.User]] = None, manga: Optional[Union[str, asyncdex.models.manga.Manga]] = None, volume: Optional[Union[str, List[Optional[str]]]] = None, chapter_number: Optional[Union[str, List[Optional[str]]]] = None, language: Optional[str] = None, created_after: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, published_after: Optional[datetime.datetime] = None, order: Optional[asyncdex.list_orders.ChapterListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.chapter.Chapter][source]

Gets a Pager of chapters. This method requires the following permission: chapter.list

New in version 0.4.

Usage:

async for chapter in client.get_chapters(chapter_number="1"):
    ...
Parameters
  • title (str) – The title of the chapter.

  • groups (List[Union[str, Group]]) – Chapters made by one of the groups in the given list. A group can either be the UUID of the group in string format or an instance of Group.

  • uploader (Union[str, User]) – The user who uploaded the chapter. A user can either be the UUID of the user in string format or an instance of User.

  • manga (Union[str, Manga]) –

    Chapters that belong to the given manga. A manga can either be the UUID of the manga in string format or an instance of Manga.

    Note

    If fetching all chapters for one manga, it is more efficient to use ChapterList.get() instead.

  • volume (Union[str, List[Optional[str]]]) –

    The volume that the chapter belongs to.

    Changed in version 1.1: Allowed passing in a list of volumes.

    Note

    If you only want to filter out chapters without a volume (null volume), you have to supply a list containing a None value.

  • chapter_number (Union[str, List[Optional[str]]]) –

    The number of the chapter.

    Changed in version 1.1: Allowed passing in a list of chapter numbers.

    Note

    If you only want to filter out chapters without a number (null number), you have to supply a list containing a None value.

  • language (str) – The language of the chapter.

  • created_after (datetime) –

    Get chapters created after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • updated_after (datetime) –

    Get chapters updated after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • published_after (datetime) –

    Get chapters published after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • order (ChapterListOrder) – The order to sort the chapters.

  • limit (int) –

    Only return up to this many chapters.

    Note

    Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Returns

A Pager for the chapters.

Return type

Pager

get_cover(id: str)asyncdex.models.cover_art.CoverArt[source]

Get a custom list using it’s ID.

New in version 1.0.

Warning

This method returns a lazy CoverArt instance. Call CoverArt.fetch() on the returned object to see any values.

Parameters

id (str) – The cover’s UUID.

Returns

A CoverArt object.

Return type

CoverArt

get_covers(*, mangas: Optional[List[Union[str, asyncdex.models.manga.Manga]]] = None, uploaders: Optional[List[Union[str, asyncdex.models.user.User]]] = None, order: Optional[asyncdex.list_orders.CoverListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.cover_art.CoverArt][source]

Gets a Pager of covers. This method requires the following permission: cover.list

New in version 1.0.

Usage:

async for cover in client.get_covers(uploaders=[client.user]):
    ...
Parameters
  • mangas (List[Union[str, Manga]]) – A list of mangas to get covers for .A cover may be represented by a string containing their UUID or an instance of CoverArt.

  • uploaders (List[Union[str, User]]) – Covers uploaded by the given users. An user may be represented by a string containing their UUID or an instance of User.

  • order (CoverListOrder) – The order to sort the covers.

  • limit (int) –

    Only return up to this many covers.

    Note

    Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Returns

A Pager with the cover entries.

Return type

Pager

get_group(id: str)asyncdex.models.group.Group[source]

Get a group using it’s ID.

New in version 0.3.

Warning

This method returns a lazy Group instance. Call Group.fetch() on the returned object to see any values.

Parameters

id (str) – The group’s UUID.

Returns

A Group object.

Return type

Group

get_groups(*, name: Optional[str] = None, order: Optional[asyncdex.list_orders.GroupListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.group.Group][source]

Creates a Pager for groups. This method requires the following permission: scanlation_group.list

New in version 0.4.

Usage:

async for group in client.get_groups(name="Group Name"):
    ...
Parameters
  • name (str) – The name to search for.

  • order (GroupListOrder) – The order to sort the groups 1.

  • limit (int) –

    Only return up to this many groups.

    Note

    Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Returns

A Pager for the groups.

Return type

Pager

get_list(id: str)asyncdex.models.custom_list.CustomList[source]

Get a custom list using it’s ID.

New in version 0.5.

Warning

This method returns a lazy CustomList instance. Call CustomList.fetch() on the returned object to see any values.

Parameters

id (str) – The custom list’s UUID.

Returns

A CustomList object.

Return type

CustomList

get_manga(id: str)asyncdex.models.manga.Manga[source]

Get a manga using it’s ID.

New in version 0.2.

See also

search().

Warning

This method returns a lazy Manga instance. Call Manga.fetch() on the returned object to see any values.

Parameters

id (str) – The manga’s UUID.

Returns

A Manga object.

Return type

Manga

get_mangas(*, title: Optional[str] = None, authors: Optional[List[Union[str, asyncdex.models.author.Author]]] = None, artists: Optional[List[Union[str, asyncdex.models.author.Author]]] = None, year: Optional[int] = None, included_tags: Optional[List[Union[str, asyncdex.models.tag.Tag]]] = None, included_tag_mode: asyncdex.enum.TagMode = <TagMode.AND: 'AND'>, excluded_tags: Optional[List[Union[str, asyncdex.models.tag.Tag]]] = None, excluded_tag_mode: asyncdex.enum.TagMode = <TagMode.OR: 'OR'>, status: Optional[List[asyncdex.enum.MangaStatus]] = None, languages: Optional[List[str]] = None, demographic: Optional[List[asyncdex.enum.Demographic]] = None, rating: Optional[List[asyncdex.enum.ContentRating]] = None, created_after: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, order: Optional[asyncdex.list_orders.MangaListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.manga.Manga][source]

Gets a Pager of mangas. This method requires the following permission: manga.list

New in version 0.4.

Usage:

async for manga in client.search(title="Solo Leveling"):
    ...
Parameters
  • title (str) – The title of the manga.

  • authors (List[Union[str, Author]]) – Mangas made by the given authors. An author may be represented by a string containing their UUID or an instance of Author.

  • artists (List[Union[str, Author]]) – Mangas made by the given artists. An artist may be represented by a string containing their UUID or an instance of Author.

  • year (int) – The year the manga was published.

  • included_tags (List[Union[str, Tag]]) – A list of tags that should be present. A tag may be represented by a string containing the tag’s UUID or an instance of Tag.

  • included_tag_mode (TagMode) – The mode to use for the included tags. Defaults to TagMode.AND.

  • excluded_tags (List[Union[str, Tag]]) – A list of tags that should not be present. A tag may be represented by a string containing the tag’s UUID or an instance of Tag.

  • excluded_tag_mode (TagMode) – The mode to use for the excluded tags. Defaults to TagMode.OR.

  • status (List[MangaStatus]) – A list of MangaStatuses representing possible statuses.

  • languages (List[str]) – A list of language coes.

  • demographic (List[Demographic]) – A list of Demographics representing possible demographics.

  • rating – A list of ContentRatings representing possible content ratings.

  • created_after (datetime) –

    Get mangas created after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • updated_after (datetime) –

    Get mangas updated after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • order (MangaListOrder) – The order to sort the mangas.

  • limit (int) –

    Only return up to this many mangas.

    Note

    Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Returns

A Pager with the manga entries.

Return type

Pager

async get_page(url: str)aiohttp.client_reqrep.ClientResponse[source]

A method to download one page of a chapter, using the URLs from pages(). This method is more low-level so that it is not necessary to download all pages at once. This method also respects the API rules on downloading pages.

Parameters

url (str) – The URL to download.

Raises

aiohttp.ClientResponseError if a 4xx or 5xx response code is returned.

Returns

The aiohttp.ClientResponse object containing the image.

Return type

aiohttp.ClientResponse

async get_session_token()[source]

Get the session token and store it inside the client.

async get_tag(id: str)asyncdex.models.tag.Tag[source]

Get a tag using it’s ID.

New in version 0.2.

Finding a Tag by Name

Finding a tag by name is a feature that many people want. However, there is no endpoint that exists in the API that lets us provide a name and get back a list of Tags that match the name. It is not needed, as there only exists a relatively amount of tags, which can be loaded from a single request.

The client maintains a cache of the tags in order to lower memory usage and allow tag updates to be easily distributed to all mangas, since there are a relatively small amount of tags compared to authors, chapters, mangas, and users. The client also provides a method to completely load the tag list and update the tag cache, refresh_tag_cache(). The tag cache is stored in tag_cache, Using this property, it is possible to iterate over the tag list and preform a simple name matching search to find the tag(s) that you want. An example implementation of a tag search method is provided as such:

from asyncdex import MangadexClient, Tag
from typing import List

def search_tags(client: MangadexClient, phrase: str) -> List[Tag]:
    phrase = phrase.replace(" ", "") # Remove spaces so "sliceoflife" and "slice of life" match.
    results: List[Tag] = []
    for tag in client.tag_cache:
        for name in tag.names.values():
            if phrase in name.replace(" ", "").lower():
                results.append(tag)
                break
    return results
Parameters

id (str) – The tag’s UUID.

Returns

A Tag object.

Return type

Tag

get_user(id: str)asyncdex.models.user.User[source]

Get a user using it’s ID.

New in version 0.3.

Warning

This method returns a lazy User instance. Call User.fetch() on the returned object to see any values.

Parameters

id (str) – The user’s UUID.

Returns

A User object.

Return type

User

async login(username: Optional[str] = None, password: Optional[str] = None)[source]

Logs in to the MangaDex API.

Parameters
  • username (str) – Provide a username in order to make the client stop running in anonymous mode. Specifying the username without specifying the password is an error.

  • password (str) – Provide a password in order to make the client stop running in anonymous mode. Specifying the password without specifying the username is an error.

async logout(delete_tokens: bool = True, clear_login_info: bool = True)[source]

Log out from the API.

Parameters
  • delete_tokens (bool) –

    Whether or not to delete the refresh/session tokens by calling the logout endpoint. Defaults to true.

    New in version 0.5.

  • clear_login_info (bool) –

    Whether or not to clear login info from the client, so that future logins are not possible without a new token or calling login() with the username and password parameters. Defaults to true.

    New in version 0.5.

password: Optional[str]

The password of the user that the client is logged in as. This will be None when the client is operating in anonymous mode.

async ping()[source]

Ping the server. This will throw an error if there is any error in making connections, whether with the client or the server.

New in version 0.3.

raise_exception_if_not_authenticated(method: str, path: str)[source]

Raise an exception if authentication is missing. This is ideally used before making requests that will always need authentication.

New in version 0.5.

Parameters
  • method (str) –

    The method to show.

    See also

    Unauthorized.method.

  • path (str) –

    The path to display.

    See also

    Unauthorized.path.

Raises

Unauthorized

async random_manga()asyncdex.models.manga.Manga[source]

Get a random manga.

New in version 0.2.

Returns

A random manga.

Return type

Manga

ratelimits: asyncdex.ratelimit.Ratelimits

The Ratelimits object that the client is using.

async refresh_tag_cache()[source]

Refresh the internal tag cache.

New in version 0.2.

See also

tag_cache

refresh_token: Optional[str]

The refresh token that the client has obtained. This will be None when the client is operating in anonymous mode, as well as if the client has not obtained a refresh token from the API.

async report_page(url: str, success: bool, response_length: int, duration: int, cached: bool)[source]

Report a page to the MangaDex@Home network.

New in version 0.4.

See also

MangadexClient.get_page(), which will automatically call this method for you.

Parameters
  • url (str) – The URL of the image.

  • success (bool) – Whether or not the URL was successfully retrieved.

  • response_length (int) – The length of the response, whether or not it was a success.

  • duration (int) – The time it took for the request, including downloading the content if it existed, in milliseconds.

  • cached (bool) – Whether or not the request was cached (The X-Cache header starting with the value HIT).

async request(method: str, url: str, *, params: Optional[Mapping[str, Optional[Union[str, Sequence[str], bool, float]]]] = None, json: Optional[Any] = None, with_auth: bool = True, retries: int = 3, allow_non_successful_codes: bool = False, add_includes: bool = False, **session_request_kwargs)aiohttp.client_reqrep.ClientResponse[source]

Perform a request.

Warning

All requests have to be released, otherwise connections will not be reused. Make sure to call aiohttp.ClientResponse.release() on the object returned by the method if you do not read data from the response.

Note

The request method will log all URLs that are requested. Enable logging on the asyncdex logger to view them. These requests are made under the INFO level. Retries are also logged on the WARNING level.

Changed in version 0.3: Added a global (shared between all requests made in the client) ratelimit.

Changed in version 0.4: Added better handling of string items.

Parameters
  • method (str) – The HTTP method to use for the request.

  • url (str) – The URL to use for the request. May be either an absolute URL or a URL relative to the base MangaDex API URL.

  • params (Mapping[str, Union[str, Sequence[str]]]) – Optional query parameters to append to the URL. If one of the values of the parameters is an array, the elements will be automatically added to the URL in the order that the array elements appear in.

  • json (Any) – JSON data to pass in a POST request.

  • with_auth (bool) – Whether or not to append the session token to the request headers. Requests made without the header will behave as if the client is in anonymous mode. Defaults to True.

  • retries (int) – The amount of times to retry. The function will recursively call itself, subtracting 1 from the original count until retries run out.

  • allow_non_successful_codes (bool) – Whether or not to allow non-success codes (4xx codes that aren’t 401/429) to pass through instead of raising an error. Defaults to False.

  • add_includes (bool) – Whether or not to add the list of allowed reference expansions to the request. Defaults to False.

  • session_request_kwargs – Optional keyword arguments to pass to aiohttp.ClientSession.request().

Raises

Unauthorized if the endpoint requires authentication and sufficient parameters for authentication were not provided to the client.

Raises

:class`aiohttp.ClientResponseError` if the response is a 4xx or 5xx code after multiple retries or if it will not be retried and allow_non_successful_codes is False.

Returns

The response.

Return type

aiohttp.ClientResponse

async resend_activation_code(email: str)[source]

Resend an activation email.

New in version 0.5.

Parameters

email (str) – The email to resend to

async reset_password_email(email: str)[source]

Start the process of resetting an account’s password.

New in version 0.5.

Parameters

email (str) – The email of the account to reset the password of.

search(*, title: Optional[str] = None, authors: Optional[List[Union[str, asyncdex.models.author.Author]]] = None, artists: Optional[List[Union[str, asyncdex.models.author.Author]]] = None, year: Optional[int] = None, included_tags: Optional[List[Union[str, asyncdex.models.tag.Tag]]] = None, included_tag_mode: asyncdex.enum.TagMode = <TagMode.AND: 'AND'>, excluded_tags: Optional[List[Union[str, asyncdex.models.tag.Tag]]] = None, excluded_tag_mode: asyncdex.enum.TagMode = <TagMode.OR: 'OR'>, status: Optional[List[asyncdex.enum.MangaStatus]] = None, languages: Optional[List[str]] = None, demographic: Optional[List[asyncdex.enum.Demographic]] = None, rating: Optional[List[asyncdex.enum.ContentRating]] = None, created_after: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, order: Optional[asyncdex.list_orders.MangaListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.manga.Manga]

Alias for get_mangas().

session: aiohttp.client.ClientSession

The aiohttp.ClientSession that the client will use to make requests.

property session_token: Optional[str]

The session token tht the client has obtained. This will be None when the client is operating in anonymous mode, as well as if the client has not obtained a refresh token from the API or if it has been roughly 15 minutes since the token was retrieved from the server.

sleep_on_ratelimit: bool

Whether or not to sleep when a ratelimit occurs.

async solve_captcha(answer: str)[source]

Solve the captcha.

New in version 0.5.

Parameters

answer (str) – The answer to the captcha.

Raises

InvalidCaptcha if the captcha is invalid.

tag_cache: asyncdex.models.tag.TagDict

A cache of tags. This cache will be used to lower the amount of tag objects, and allows for easily updating the attributes of tags. This cache can be refreshed manually by either calling refresh_tag_cache() or fetching data for any tag object.

New in version 0.2.

user: asyncdex.models.client_user.ClientUser

The user of the client.

New in version 0.5.

username: Optional[str]

The username of the user that the client is logged in as. This will be None when the client is operating in anonymous mode.

ClientUser

class asyncdex.models.client_user.ClientUser(client: MangadexClient, *, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A User representing the user of the client.

Note

This is not fully equivalent to a real user. If a client is unauthorized, then the client user object will not have a valid UUID.

New in version 0.5.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__hash__()

Return hash(self).

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

chapters: GenericModelList[‘Chapter’]

The chapters the user uploaded.

Deprecated since version 1.0: MangaDex will no longer send chapters back. The chapter list will always be empty.

client: MangadexClient

The client that created this model.

async fetch()[source]

Fetch data about the client user.

async fetch_user()[source]

Fetch data about the client user from MangaDex servers. This will get the user’s UUID. This method requires authentication with the MangaDex API.

groups(*, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.group.Group][source]

Get the groups that the logged in user follows. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

limit (int) –

Only return up to this many groups.

Note

Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Raise

Unauthorized is there is no authentication.

Returns

The group that the logged in user follows.

Return type

Pager[Group]

id: str

A UUID that represents this item.

lists(*, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.custom_list.CustomList][source]

Get the custom lists that the logged in user follows. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

limit (int) –

Only return up to this many custom lists.

Note

Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Raise

Unauthorized is there is no authentication.

Returns

The custom list that the logged in user follows.

Return type

Pager[CustomList]

async load_chapters()

Shortcut method that calls MangadexClient.batch_chapters() with the chapters that belong to the user.

Roughly equivalent to:

await client.batch_chapters(*user.chapters)
manga(*, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.manga.Manga][source]

Get the manga that the logged in user follows. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

limit (int) –

Only return up to this many mangas.

Note

Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Raise

Unauthorized is there is no authentication.

Returns

The manga that the logged in user follows.

Return type

Pager[Manga]

manga_chapters(*, languages: Optional[List[str]] = None, created_after: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, published_after: Optional[datetime.datetime] = None, order: Optional[asyncdex.list_orders.UserFollowsMangaFeedListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.chapter.Chapter][source]

Get the chapters from the manga that the logged in user is following. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters
  • languages (List[str]) – The languages to filter by.

  • created_after (datetime) –

    Get chapters created after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • updated_after (datetime) –

    Get chapters updated after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • published_after (datetime) –

    Get chapters published after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • order (UserFollowsMangaFeedListOrder) –

    The order to sort the chapters.

    Changed in version 1.1: The type for the order parameter was changed from MangaFeedListOrder to UserFollowsMangaFeedListOrder.

  • limit (int) –

    Only return up to this many chapters.

    Note

    Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Returns

A Pager with the chapters.

Return type

Pager[Chapter]

parse(data: Dict[str, Any])

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

permission_check(permission_name: str)bool[source]

Check if the client user has the given permission.

Parameters

permission_name (str) – The permission’s name.

Returns

Whether or not the client user has the permission.

Return type

bool

permission_exception(permission_name: str, method: str, path: str)[source]

Check if the client user has the given permission, otherwise throws an exception.

Parameters
  • permission_name (str) – The permission’s name.

  • method (str) –

    The method to show.

    See also

    Unauthorized.method.

  • path (str) –

    The path to display.

    See also

    Unauthorized.path.

Raises

PermissionMismatch if the permission does not exist.

permissions: List[str]

The permissions of the client user.

roles: List[str]

The roles of the client user.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

username: str

THe user’s username.

users(*, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.user.User][source]

Get the users that the logged in user follows. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

limit (int) –

Only return up to this many users.

Note

Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Raise

Unauthorized is there is no authentication.

Returns

The user that the logged in user follows.

Return type

Pager[User]

version: int

The version of the model.

Models

class asyncdex.models.abc.Model(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

An abstract model. Cannot be instantiated.

New in version 0.2.

Raises

Missing if there is no valid ID in the model after parsing provided data.

Parameters

data (Dict[str, Any]) – The data received from the server. May be None if there is no data yet.

__eq__(other: asyncdex.models.abc._T)bool[source]

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__hash__()[source]

Return hash(self).

__ne__(other: asyncdex.models.abc._T)bool[source]

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__repr__()str[source]

Returns a string version of the model useful for development.

__str__()str[source]

Returns a string representation of the model, usually it’s id.

client: MangadexClient

The client that created this model.

abstract async fetch()[source]

Fetch the data to complete any missing non-critical values.

Raises

InvalidID if an object with the ID does not exist.

id: str

A UUID that represents this item.

abstract parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

transfer(new_obj: asyncdex.models.abc._T)[source]

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

version: int

The version of the model.

class asyncdex.models.Author(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing an individual author.

Note

Artists and authors are stored identically and share all properties.

New in version 0.2.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__hash__()

Return hash(self).

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

biographies: asyncdex.utils.DefaultAttrDict[Optional[str]]

A DefaultAttrDict holding the biographies of the author.

client: MangadexClient

The client that created this model.

created_at: datetime

A datetime.datetime representing the object’s creation time.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

async delete()[source]

Delete the author. This method requires authentication with the MangaDex API.

New in version 0.5.

async fetch()[source]

Fetch data about the author. This method requires the following permission: author.view

Raises

InvalidID if an author with the ID does not exist.

id: str

A UUID that represents this item.

image: Optional[str]

An image of the author, if available.

async load_mangas()[source]

Shortcut method that calls MangadexClient.batch_mangas() with the mangas that belong to the author.

Roughly equivalent to:

await client.batch_mangas(*author.mangas)
mangas: asyncdex.models.manga_list.MangaList

A list of all the mangas that belong to the author.

Note

In order to efficiently get all mangas in one go, use:

await author.load_mangas()
property modified_at: datetime.datetime

The last time the object was modified. This will return the creation time if the object was never updated after creation, or the modification time if it has.

Returns

The last time the object was changed as a datetime.datetime object.

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

Return type

datetime.datetime

name: str

The name of the author.

parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

async update()[source]

Update the author. This method requires authentication with the MangaDex API.

New in version 0.5.

updated_at: Optional[datetime]

A datetime.datetime representing the last time the object was updated. May be None if the object was never updated after creation.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

version: int

The version of the model.

class asyncdex.models.Chapter(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing an individual chapter.

New in version 0.3.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__ge__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than or equal to the other model’s creation time.

Return type

bool

__gt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than the other model’s creation time.

Return type

bool

__hash__()

Return hash(self).

__le__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than or equal to the other model’s creation time.

Return type

bool

__lt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than the other model’s creation time.

Return type

bool

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

client: MangadexClient

The client that created this model.

created_at: datetime

A datetime.datetime representing the object’s creation time.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

data_saver_page_names: List[str]

A list of strings containing the filenames of the data saver pages.

See also

page_names

async download_chapter(*, folder_format: str = '{manga}/{chapter_num}{separator}{title}', file_format: str = '{num}', as_bytes_list: bool = False, overwrite: bool = True, retries: int = 3, use_data_saver: bool = False, ssl_only: bool = False)Optional[List[bytes]][source]

Download all of the pages of the chapter and either save them locally to the filesystem or return the raw bytes.

Parameters
  • folder_format (str) –

    The format of the folder to create for the chapter. The folder can already be existing. The default format is {manga}/{chapter_num}{separator}{chapter_title}.

    Note

    Specify . if you want to save the pages in the current folder.

    Available variables:

    • {manga}: The name of the manga. If the chapter’s manga object does not contain a title object, it will be fetched.

    • {chapter_num}: The number of the chapter, if it exists.

    • {separator}: A separator if both the chapter’s number and title exists.

    • {title}: The title of the chapter, if it exists.

  • file_format (str) –

    The format of the individual image file names. The default format is {num}.

    Note

    The file extension is applied automatically from the real file name. There is no need to include it.

    Available variables:

    • {num}: The numbering of the image files starting from 1. This respects the order the images are in inside of page_names.

    • {num0}: The same as {num} but starting from 0.

    • {name}: The actual filename of the image from page_names, without the file extension.

  • as_bytes_list (bool) – Whether or not to return the pages as a list of raw bytes. Setting this parameter to True will ignore the value of the folder_format parameter.

  • overwrite (bool) – Whether or not to override existing files with the same name as the page. Defaults to True.

  • retries (int) – How many times to retry a chapter if a MD@H node does not let us download the pages. Defaults to 3.

  • use_data_saver (bool) – Whether or not to use the data saver pages or the normal pages. Defaults to False.

  • ssl_only (bool) –

    Whether or not the given URL has port 443. Useful if your firewall blocks outbound connections to ports that are not port 443. Defaults to False.

    Note

    This will lower the pool of available clients and can cause higher download times.

Raises

aiohttp.ClientResponseError if there is an error after all retries are exhausted.

Returns

A list of byte strings if as_bytes_list is True else None.

Return type

Optional[List[bytes]]

async fetch()[source]

Fetch data about the chapter. This method requires the following permission: chapter.view

Raises

InvalidID if a chapter with the ID does not exist.

async get_read()[source]

Gets whether or not the chapter is read. The read status can then be viewed in read.

New in version 0.5.

groups: asyncdex.models.abc.GenericModelList[asyncdex.models.group.Group]

The groups that uploaded this chapter.

hash: str

The chapter’s hash.

id: str

A UUID that represents this item.

language: str

The language of the chapter.

async load_groups()[source]

Shortcut method that calls MangadexClient.batch_groups() with the groups that belong to the group.

Roughly equivalent to:

await client.batch_groups(*user.groups)
manga: Manga

The manga that this chapter belongs to.

async mark_read()[source]

Mark the chapter as read. This method requires authentication with the MangaDex API.

New in version 0.5.

async mark_unread()[source]

Mark the chapter as unread. This method requires authentication with the MangaDex API.

New in version 0.5.

property modified_at: datetime.datetime

The last time the object was modified. This will return the creation time if the object was never updated after creation, or the modification time if it has.

Returns

The last time the object was changed as a datetime.datetime object.

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

Return type

datetime.datetime

property name: str

Returns a nicely formatted name based on available fields. Includes the volume number, chapter number, and chapter title if any one or more of them exist.

Returns

Formatted name

Return type

str

number: Optional[str]

The number of the chapter. None if the chapter is un-numbered (such as in an anthology).

Note

A chapter can have a number, a title, or both. If a chapter’s number is None, it must have a title.

page_names: List[str]

A list of strings containing the filenames of the pages.

async pages(*, data_saver: bool = False, ssl_only: bool = False)List[str][source]

Get fully formatted page URLs.

Note

The given page URLs are only valid for a short timeframe. These URLs cannot be used for hotlinking.

Parameters
  • data_saver (bool) – Whether or not to return the pages for the data saver URLs. Defaults to False.

  • ssl_only (bool) –

    Whether or not the given URL has port 443. Useful if your firewall blocks outbound connections to ports that are not port 443. Defaults to False.

    Note

    This will lower the pool of available clients and can cause higher latencies.

Returns

A list of valid URLs in the order of the pages.

Return type

List[str]

parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

publish_time: datetime.datetime

A datetime.datetime representing the time the chapter was published.

See also

created_at

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

read: bool

Whether or not the chapter is read.

property sorting_number: float

Returns 0 if the chapter does not have a number, otherwise returns the chapter’s number.

Returns

A number usable for sorting.

Return type

float

title: Optional[str]

The title of the chapter. None if the chapter does not have a title.

Note

A chapter can have a number, a title, or both. If a chapter’s title is None, it must have a number.

async toggle_read()[source]

Toggle a chapter between being read and unread. Requires authentication.

New in version 0.5.

Note

This requires the read status of the chapter to be known. See get_read_status() or ChapterList.get_read().

Raises

Unauthorized is authentication is missing.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

updated_at: Optional[datetime]

A datetime.datetime representing the last time the object was updated. May be None if the object was never updated after creation.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

user: asyncdex.models.user.User

The user that uploaded this chapter.

version: int

The version of the model.

volume: Optional[str]

The volume of the chapter. None if the chapter belongs to no volumes.

class asyncdex.models.CoverArt(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing an individual cover art.

New in version 1.0.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__ge__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than or equal to the other model’s creation time.

Return type

bool

__gt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than the other model’s creation time.

Return type

bool

__hash__()

Return hash(self).

__le__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than or equal to the other model’s creation time.

Return type

bool

__lt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than the other model’s creation time.

Return type

bool

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

client: MangadexClient

The client that created this model.

created_at: datetime

A datetime.datetime representing the object’s creation time.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

async delete()[source]

Delete the cover. This method requires authentication with the MangaDex API.

description: str

The description of the cover art.

async fetch()[source]

Fetch data about the chapter. This method requires the following permission: cover.view

Raises

InvalidID if a cover with the ID does not exist.

file_name: Optional[str]

The name of the file that contains the cover art.

id: str

A UUID that represents this item.

manga: Optional[Manga]

The manga that this cover art belongs to.

property modified_at: datetime.datetime

The last time the object was modified. This will return the creation time if the object was never updated after creation, or the modification time if it has.

Returns

The last time the object was changed as a datetime.datetime object.

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

Return type

datetime.datetime

parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

async update()[source]

Update the cover. This method requires authentication with the MangaDex API.

updated_at: Optional[datetime]

A datetime.datetime representing the last time the object was updated. May be None if the object was never updated after creation.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

async url()str[source]

Get a URL to the cover.

Returns

The URL.

Return type

str

async url_256()str[source]

Get the <=256 px URL to the cover.

Returns

The URL.

Return type

str

async url_512()str[source]

Get the <=512 px URL to the cover.

Returns

The URL.

Return type

str

user: Optional[User]

The user that this cover art belongs to.

version: int

The version of the model.

volume: Optional[str]

The volume that this cover art represents.

class asyncdex.models.CustomList(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing a custom list.

New in version 0.5.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__hash__()

Return hash(self).

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

client: MangadexClient

The client that created this model.

async fetch()[source]

Fetch data about the list.

id: str

A UUID that represents this item.

async load_mangas()[source]

Shortcut method that calls MangadexClient.batch_mangas() with the mangas that belong to the author.

Roughly equivalent to:

await client.batch_mangas(*author.mangas)
manga_chapters(*, languages: Optional[List[str]] = None, created_after: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, published_after: Optional[datetime.datetime] = None, order: Optional[asyncdex.list_orders.MangaFeedListOrder] = None, limit: Optional[int] = None)asyncdex.models.pager.Pager[asyncdex.models.chapter.Chapter][source]

Get the chapters from the manga in the custom list. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters
  • languages (List[str]) – The languages to filter by.

  • created_after (datetime) –

    Get chapters created after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • updated_after (datetime) –

    Get chapters updated after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • published_after (datetime) –

    Get chapters published after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • order (MangaFeedListOrder) – The order to sort the chapters.

  • limit (int) –

    Only return up to this many chapters.

    Note

    Not setting a limit when you are only interested in a certain amount of responses may result in the Pager making more requests than necessary, consuming ratelimits.

Returns

A Pager with the chapters.

Return type

Pager[Chapter]

mangas: asyncdex.models.manga_list.MangaList

A list of all the mangas that belong to the custom list.

Note

In order to efficiently get all mangas in one go, use:

await clist.load_mangas()
name: str

The name of the custom list.

owner: asyncdex.models.user.User

The creator of the custom list.

parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

version: int

The version of the model.

class asyncdex.models.Group(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing an individual scanlation group.

New in version 0.3.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__ge__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than or equal to the other model’s creation time.

Return type

bool

__gt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than the other model’s creation time.

Return type

bool

__hash__()

Return hash(self).

__le__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than or equal to the other model’s creation time.

Return type

bool

__lt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than the other model’s creation time.

Return type

bool

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

chapters: asyncdex.models.abc.GenericModelList[Chapter]

A list of chapters uploaded by the group.

Deprecated since version 1.0: MangaDex will no longer send chapters back. The chapter list will always be empty.

client: MangadexClient

The client that created this model.

created_at: datetime

A datetime.datetime representing the object’s creation time.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

async delete()[source]

Delete the scanlation group. This method requires authentication with the MangaDex API.

New in version 0.5.

async fetch()[source]

Fetch data about the group. This method requires the following permission: group.view

Raises

InvalidID if a group with the ID does not exist.

async follow()[source]

Follow the scanlation group. This method requires authentication with the MangaDex API.

New in version 0.5.

id: str

A UUID that represents this item.

leader: asyncdex.models.user.User

The user who created the group.

async load_chapters()[source]

Shortcut method that calls MangadexClient.batch_chapters() with the chapters that belong to the group.

Roughly equivalent to:

await client.batch_chapters(*user.chapters)
members: asyncdex.models.abc.GenericModelList[asyncdex.models.user.User]

Users who are members of the group.

property modified_at: datetime.datetime

The last time the object was modified. This will return the creation time if the object was never updated after creation, or the modification time if it has.

Returns

The last time the object was changed as a datetime.datetime object.

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

Return type

datetime.datetime

name: str

The name of the group.

parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

async unfollow()[source]

Unfollow the scanlation group. This method requires authentication with the MangaDex API.

New in version 0.5.

async update()[source]

Update the scanlation group. This method requires authentication with the MangaDex API.

New in version 0.5.

updated_at: Optional[datetime]

A datetime.datetime representing the last time the object was updated. May be None if the object was never updated after creation.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

version: int

The version of the model.

class asyncdex.models.Manga(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing an individual manga.

New in version 0.2.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__ge__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than or equal to the other model’s creation time.

Return type

bool

__gt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is greater than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than the other model’s creation time.

Return type

bool

__hash__()

Return hash(self).

__le__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than or equal to the other model’s creation time.

Return type

bool

__lt__(other: asyncdex.models.mixins._T)bool

Compares the two object’s creation times to find if the current model’s creation time is less than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than the other model’s creation time.

Return type

bool

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

async add_to_list(custom_list: asyncdex.models.custom_list.CustomList)[source]

Add the manga to the custom list. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

custom_list (CustomList) – The list to add to.

async aggregate(languages: Optional[List[str]] = None)asyncdex.models.aggregate.MangaAggregate[source]

Get the aggregate of this manga.

Parameters

languages (List[str]) – The languages that should be part of the aggregate.

Returns

The manga’s aggregate.

Return type

MangaAggregate

artists: asyncdex.models.abc.GenericModelList[Author]

A list of Author objects that represent the manga’s artists.

See also

authors

Note

In order to efficiently get all authors and artists in one go, use load_authors().

authors: asyncdex.models.abc.GenericModelList[Author]

A list of Author objects that represent the manga’s authors.

See also

artists

Note

In order to efficiently get all authors and artists in one go, use load_authors().

chapters: asyncdex.models.chapter_list.ChapterList

A ChapterList representing the chapters of the manga.

New in version 0.3.

client: MangadexClient

The client that created this model.

cover: Optional[asyncdex.models.cover_art.CoverArt] = None

The cover of the manga, if one exists.

New in version 1.0.

covers: asyncdex.models.cover_list.CoverList

An instance of CoverList allowing easy retrieval of manga covers.

New in version 1.0.

created_at: datetime

A datetime.datetime representing the object’s creation time.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

async delete()[source]

Delete the manga. This method requires authentication with the MangaDex API.

New in version 0.5.

demographic: asyncdex.enum.Demographic

The manga’s demographic.

descriptions: asyncdex.utils.DefaultAttrDict[Optional[str]]

A DefaultAttrDict holding the descriptions of the manga.

Note

If a language is missing a description, None will be returned.

async fetch()[source]

Fetch data about the manga. This method requires the following permission: manga.view

Raises

InvalidID if a manga with the ID does not exist.

async follow()[source]

Follow the manga. This method requires authentication with the MangaDex API.

New in version 0.5.

async get_reading_status()[source]

Gets the manga’s reading status. This method requires authentication with the MangaDex API.

New in version 0.5.

id: str

A UUID that represents this item.

last_chapter: Optional[str]

The last chapter of the manga. None if it is not specified or does not exist.

Changed in version 0.3: Changed to a string in order to better match the API specification.

last_volume: Optional[str]

The last volume of the manga. None if it is not specified or does not exist.

Changed in version 0.3: Changed to a string in order to better match the API specification.

An instance of MangaLinks with the manga’s links.

New in version 0.5.

async load_authors()[source]

Shortcut method that calls MangadexClient.batch_authors() with the authors and artists that belong to the manga.

Roughly equivalent to:

await client.batch_authors(*manga.authors, *manga.artists)
locked: bool

A locked manga. Usually means that chapter details cannot be modified.

property modified_at: datetime.datetime

The last time the object was modified. This will return the creation time if the object was never updated after creation, or the modification time if it has.

Returns

The last time the object was changed as a datetime.datetime object.

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

Return type

datetime.datetime

original_language: str

The original language that the manga was released in.

parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

rating: asyncdex.enum.ContentRating

The manga’s content rating.

reading_status: Optional[asyncdex.enum.FollowStatus]

A value of FollowStatus representing the logged in user’s reading status.

New in version 0.5.

async remove_from_list(custom_list: asyncdex.models.custom_list.CustomList)[source]

Remove the manga from the custom list. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

custom_list (CustomList) – The list to remove from.

async set_reading_status(status: Optional[asyncdex.enum.FollowStatus])[source]

Sets the manga’s reading status. This method requires authentication with the MangaDex API.

New in version 0.5.

Parameters

status (Optional[FollowStatus]) – The new status to set. Can be None to remove reading status.

status: asyncdex.enum.MangaStatus

The manga’s status.

tags: asyncdex.models.abc.GenericModelList[asyncdex.models.tag.Tag]

A list of Tag objects that represent the manga’s tags. A manga without tags will have an empty list.

titles: asyncdex.utils.DefaultAttrDict[asyncdex.models.title.TitleList]

A DefaultAttrDict holding the titles of the manga.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

async unfollow()[source]

Unfollow the manga. This method requires authentication with the MangaDex API.

New in version 0.5.

async update(notes: Optional[str])[source]

Update the manga using values from the class. This method requires authentication with the MangaDex API.

New in version 0.5.

Updating manga:

To update the manga, just set attributes to the values you want to be updated.

Warning

When updating the titles, use list.append() and list.extend() instead of assigning a list directly.

Example:

manga.titles.en.append("Another english title")
manga.titles.es.extend(["Spanish title", "Alternate spanish title"]) # Using list.extend
manga.descriptions.en = "English description"
manga.last_volume = "2"
manga.authors = await client.get_authors(name="Author name").as_list()
manga.year = 2021
await manga.update("Added some detailed information about the manga")
Parameters

notes (str) – Optional notes to show to moderators

updated_at: Optional[datetime]

A datetime.datetime representing the last time the object was updated. May be None if the object was never updated after creation.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

version: int

The version of the model.

year: Optional[int]

The year the manga started publication. May be None if publication hasn’t started or is unknown.

class asyncdex.models.Tag(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing a tag in a Manga.

New in version 0.2.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__hash__()

Return hash(self).

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

client: MangadexClient

The client that created this model.

descriptions: asyncdex.utils.DefaultAttrDict[Optional[str]]

A DefaultAttrDict holding the descriptions of the tag.

New in version 0.4.

Note

If a language is missing a description, None will be returned.

async fetch()[source]

Fetch the data to complete any missing non-critical values.

Raises

InvalidID if an object with the ID does not exist.

group: Optional[str]

The group that the tag belongs to.

New in version 0.4.

id: str

A UUID that represents this item.

names: asyncdex.utils.DefaultAttrDict[Optional[str]]

A DefaultAttrDict holding the names of the tag.

Note

If a language is missing a name, None will be returned.

parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

version: int

The version of the model.

class asyncdex.models.User(client: MangadexClient, *, id: Optional[str] = None, version: int = 0, data: Optional[Dict[str, Any]] = None)[source]

A Model representing an individual user.

New in version 0.3.

__eq__(other: asyncdex.models.abc._T)bool

Check if two models are equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__hash__()

Return hash(self).

__ne__(other: asyncdex.models.abc._T)bool

Check if two models are not equal to each other.

Parameters

other (Model) – Another model. Should be the same type as the model being compared.

Returns

Whether or not the models are equal.

Return type

bool

__str__()str

Returns a string representation of the model, usually it’s id.

chapters: asyncdex.models.abc.GenericModelList[Chapter]

The chapters the user uploaded.

Deprecated since version 1.0: MangaDex will no longer send chapters back. The chapter list will always be empty.

client: MangadexClient

The client that created this model.

async fetch()[source]

Fetch the data to complete any missing non-critical values.

Raises

InvalidID if an object with the ID does not exist.

id: str

A UUID that represents this item.

async load_chapters()[source]

Shortcut method that calls MangadexClient.batch_chapters() with the chapters that belong to the user.

Roughly equivalent to:

await client.batch_chapters(*user.chapters)
parse(data: Dict[str, Any])[source]

Parse the data received from the server.

Parameters

data (Dict[str, Any]) – The data from the server.

transfer(new_obj: asyncdex.models.abc._T)

Transfer data from a new object to the current object.

Parameters

new_obj (Model) – The new object. Should be the same type as the current model.

username: str

THe user’s username.

version: int

The version of the model.

Exceptions

exception asyncdex.exceptions.AsyncDexException[source]

Base exception class for all exceptions by the package.

exception asyncdex.exceptions.Captcha(site_key: str, method: str, path: str, response: aiohttp.client_reqrep.ClientResponse)[source]

An exception raised if a captcha solve is required to proceed.

New in version 0.5.

Solving reCaptchas with AsyncDex:

AsyncDex will raise the Captcha exception to any request that prompts for a captcha. Afterwards, it is necessary to call solve_captcha() with the correct captcha response, and then retry whatever request caused the captcha.

site_key: str

The captcha sitekey to solve.

exception asyncdex.exceptions.HTTPException(method: str, path: str, response: Optional[aiohttp.client_reqrep.ClientResponse], *, json: Optional[Dict[str, List[Dict[str, str]]]] = None, msg: str = 'HTTP Error on {method} for {path}.')[source]

Exceptions for HTTP status codes.

json: Optional[Dict[str, List[asyncdex.utils.AttrDict[str]]]]

The JSON object returned by the server if there is a response.

method: str

The HTTP method that caused the exception.

New in version 0.5.

path: str

The URL taken that hit the error.

response: Optional[aiohttp.client_reqrep.ClientResponse]

The aiohttp.ClientResponse object from the request. May be None.

Changed in version 1.0: The response may be None.

exception asyncdex.exceptions.InvalidCaptcha(response: aiohttp.client_reqrep.ClientResponse, *, json: Optional[Dict[str, List[Dict[str, str]]]] = None)[source]

An exception raised if an attempt to solve a captcha was invalid.

New in version 0.5.

exception asyncdex.exceptions.InvalidID(id: str, model: Type[Model])[source]

An exception raised if an invalid ID is given to any of the get_* methods representing that an item with this ID does not exist.

New in version 0.2.

id: str

The given ID

model: Type[Model]

The model that would have been returned had the ID been valid.

exception asyncdex.exceptions.Missing(attribute: str, model: Optional[str] = None)[source]

An exception raised if a response is missing a critical element for a model.

New in version 0.2.

Parameters

model (str) – The name of the model that requires the attribute. Can be empty.

attribute: str

The name of the attribute that is missing.

exception asyncdex.exceptions.PermissionMismatch(permission: str, method: str, path: str, response: Optional[aiohttp.client_reqrep.ClientResponse])[source]

An exception raised if the current user does not have a certain permission.

New in version 0.5.

permission: str

The permission node the user is lacking.

response: Optional[aiohttp.client_reqrep.ClientResponse]

The aiohttp.ClientResponse object from the request. May be None if a user tries to login without stored credentials.

exception asyncdex.exceptions.Ratelimit(path: str, ratelimit_amount: int, ratelimit_expires: datetime.datetime)[source]

An exception raised if MangadexClient.sleep_on_ratelimit is set to False.

path: str

The route that was taken that hit the ratelimit. This will match the path in the MangaDex API Documentation.

ratelimit_amount: int

How many calls to this path can be made once the ratelimit expires without being ratelimited again.

ratelimit_expires: datetime.datetime

A datetime.datetime object in UTC time representing when the ratelimit will expire.

exception asyncdex.exceptions.Unauthorized(method: str, path: str, response: Optional[aiohttp.client_reqrep.ClientResponse], *, json: Optional[Dict[str, List[Dict[str, str]]]] = None)[source]

An exception raised if a request to an endpoint requiring authorization is made where the client cannot authorize using provided information.

response: Optional[aiohttp.client_reqrep.ClientResponse]

The aiohttp.ClientResponse object from the request. May be None if a user tries to login without stored credentials.

Enums

MangaDex Enums

class asyncdex.enum.ContentRating(value)[source]

An Enum representing the content in a manga. Source: https://api.mangadex.org/docs.html#section/Static-data/Manga-content-rating

New in version 0.2.

EROTICA = 'erotica'

A manga that is erotica.

Note

This type of content represents content tagged with the Smut tag.

NO_RATING = 'none'

A manga that has no content rating.

New in version 1.0.

PORNOGRAPHIC = 'pornographic'

A manga that is pornographic.

Note

This type of content was the only type of content that MangaDex’s old 18+ filter used to block. This type of content was also the type of content that old MangaDex APIs used to call “hentai”.

SAFE = 'safe'

A manga that is safe.

Note

This is the only content rating that means a manga is safe for work. All other values are not safe for work (NSFW).

SUGGESTIVE = 'suggestive'

A manga that is suggestive.

Note

This type of content represents content tagged with the Ecchi tag.

class asyncdex.enum.Demographic(value)[source]

An Enum representing the various demographics. Source: https://api.mangadex.org/docs.html#section/Static-data/Manga-publication-demographic.

New in version 0.2.

JOSEI = 'josei'

A Josei Manga.

Changed in version 0.3: The typo for this field has been corrected.

NONE = 'none'

A manga without a demographic.

New in version 0.4.

SEINEN = 'seinen'

A Seinen Manga.

SHOUJO = 'shoujo'

A Shoujo Manga.

SHOUNEN = 'shounen'

A Shounen Manga.

Note

In the developer documentation as of May 7, 2021, there is a typo in the word Shounen, where it is spelled without the u. However, the actual API will only recognize the variant including a u. For the library, both variations can be used for the enum.

class asyncdex.enum.FollowStatus(value)[source]

An Enum representing the status that the user has marked the manga has. Source: https://api.mangadex.org/docs.html#section/Static-data/Manga-reading-status

New in version 0.2.

COMPLETED = 'completed'

A manga that the user has marked as completed.

Warning

When a manga is marked as completed, the MangaDex API drops all chapter read markers. Setting a manga as completed will result in the deletion of data. Be very careful!

DROPPED = 'dropped'

A manga that the user has marked as dropped.

ON_HOLD = 'on_hold'

A manga that the user has marked as “on hold”.

PLAN_TO_READ = 'plan_to_read'

A manga that the user has marked as “plan to read”.

READING = 'reading'

A manga that the user has marked as reading.

RE_READING = 're_reading'

A manga that the user has marked as rereading.

class asyncdex.enum.MangaStatus(value)[source]

An Enum representing the various statuses a manga can have. Source: https://api.mangadex.org/docs.html#section/Static-data/Manga-status

New in version 0.2.

Note

The status of the manga does not dictate whether or not the chapter list will be stable. Scanlation teams may have not published all chapters up to the completion of updates, so the manga may still get new chapters, especially in different languages. The only way to know if a manga has actually finished updating is by checking if the “end chapter” is present in the current language. Even this is not a guarantee, as an author may add additional media accompanying the work, such as a extra page related to the manga on Twitter or Pixiv, especially for manga that are mainly published online. The labels shown for a manga’s status should not dictate the policy for update checking, as they are only meant to be an aid for end users and not actually representative of the immutability of the manga’s chapter list.

CANCELLED = 'cancelled'

A manga where the author has intentionally stopped publishing new chapters.

Changed in version 0.3: The MangaDex API changed the value from abandoned to cancelled. MangaStatus.ABANDONED will continue to represent the right value, but calling the enum with abandoned will not.

COMPLETED = 'completed'

A manga that has finished publication.

HIATUS = 'hiatus'

A manga where the author is on a known hiatus.

ONGOING = 'ongoing'

A manga that is actively being published, in volume format, in a magazine like Weekly Shonen, or online.

class asyncdex.enum.Visibility(value)[source]

An enum representing the visibility of an CustomList. Source: https://api.mangadex.org/docs.html#section/Static-data/CustomList-visibility

New in version 0.2.

PRIVATE = 'private'

A private CustomList.

PUBLIC = 'public'

A public CustomList.

class asyncdex.enum.Relationship(value)[source]

An enum representing the different types of relationship types. Source: https://api.mangadex.org/docs.html#section/Static-data/Relationship-types

New in version 0.2.

ARTIST = 'artist'

A Author resource.

AUTHOR = 'author'

A Author resource.

CHAPTER = 'chapter'

A Chapter resource.

COVER_ART = 'cover_art'

A CoverArt resource.

New in version 1.0.

CUSTOM_LIST = 'custom_list'

A CustomList resource.

MANGA = 'manga'

A Manga resource.

SCANLATION_GROUP = 'scanlation_group'

A Group resource.

TAG = 'tag'

A Tag resource.

USER = 'user'

A User resource.

Filtering

class asyncdex.enum.DuplicateResolutionAlgorithm(value)[source]

An enum representing the various methods of resolving duplicate chapters in the same language.

New in version 0.3.

Note

The filtering algorithms are short-circuiting, meaning that once the chapters for a certain chapter number is lowered down to one item, it will be returned.

Operation order:

  1. Previous group

  2. Specific Group

  3. Specific User

  4. Creation Date ascending/descending/Views ascending/descending

Note

It is an error to specify more than one of the lowest-priority operations, since they all return only one value. Doing so will raise an error.

CREATION_DATE_ASC = 4

A resolution strategy that will select the chapter that was created first.

CREATION_DATE_DESC = 5

A resolution strategy that will select the chapter that was created last.

PREVIOUS_GROUP = 1

A resolution strategy that attempts to use the same group for the chapter as the previous chapter. This needs an accompanying strategy to determine the initial group.

See also

SPECIFIC_GROUP

SPECIFIC_GROUP = 2

A resolution strategy that attempts to only select certain groups. This needs an accompanying strategy for chapters where the group is not present.

See also

SPECIFIC_USER

SPECIFIC_USER = 3

A resolution strategy that attempts to only select chapters by certain users. This needs an accompanying strategy for chapters where the user ia not present.

See also

SPECIFIC_GROUP

VIEWS_ASC = 6

A resolution strategy that will select the chapter with the least views.

Warning

This is not implemented yet as the API does not return view counts.

See also

VIEWS_DESC

VIEWS_DESC = 7

A resolution strategy that will select the chapter with the most views.

Warning

This is not implemented yet as the API does not return view counts.

See also

VIEWS_ASC

Sorting & Searching

class asyncdex.enum.OrderDirection(value)[source]

An enum representing the various directions that can be used for ordering a list of items.

New in version 0.4.

ASCENDING = 'asc'

Order items from smallest to largest.

DESCENDING = 'desc'

Order items from largest to smallest.

class asyncdex.enum.TagMode(value)[source]

An enum representing the various ways tag inclusion/exclusion can be read by the server.

New in version 0.4.

AND = 'AND'

Manga is included/excluded only if all tags are present.

OR = 'OR'

Manga is included/excluded if any tag is present.

Constants

asyncdex.constants.invalid_folder_name_regex

The regex for invalid folder names.

Contains:

  • Windows/MacOS/Linux restricted characters:
    • <

    • >

    • :

    • "

    • /

    • \

    • |

    • ?

    • *

  • All control characters from 0x0 through 0x31 inclusive.

  • Windows restricted filename:
    • CON

    • PRN

    • AUX

    • NUL

    • COM1

    • COM2

    • COM3

    • COM4

    • COM5

    • COM6

    • COM7

    • COM8

    • COM9

    • LPT1

    • LPT2

    • LPT3

    • LPT4

    • LPT5

    • LPT6

    • LPT7

    • LPT8

    • LPT9

Source: https://stackoverflow.com/a/31976060/12248328

New in version 0.3.

A mapping of the MangaDex link attribute name to the AsyncDex attribute name.

New in version 0.5.

asyncdex.constants.permission_model_mapping: Dict[str, str]

A mapping containing permission names to the type of model. Used for reference expansion.

New in version 1.1.

asyncdex.constants.ratelimit_data: List[asyncdex.ratelimit.PathRatelimit]

These are the ratelimit rules taken from the API Docs.

Note

The API rules given here do not reflect all possible API ratelimit rules. The client will automatically ratelimit when appropriate headers are sent by the API. Check the latest API rules at the official API documentation.

Changed in version 0.3.

asyncdex.constants.routes: Dict[str, str]

The various predefined routes for the client. If the API changes for a given destination, the route can easily be modified without copy-pasting the route to the functions using it.

Changed in version 0.4: mdah renamed to md@h.

Misc

Aggregates

class asyncdex.models.aggregate.MangaAggregate[source]

Represents the aggregate of the volumes in a manga.

New in version 0.5.

Note

Use None to get the aggregate for chapters without a volume number.

Usage:

print(aggregate["N/A"]["1"]) # Prints the number of chapters for the chapter with number ``1``.
__repr__()str[source]

Provide a string representation of the object.

Returns

The string representation

Return type

str

parse(data: Dict[str, Any])[source]

Parse aggregate data.

total()int[source]

Get the total amount of chapters contained in this aggregate, or the sum of the individual volume aggregates.

Returns

The sum of chapters in the aggregate

Return type

int

volumes()List[Optional[str]][source]

Get the volumes contained in the aggregate.

Returns

The list of volume numbers (including None if chapters without a volume name exist)

Return type

List[Optional[str]]

class asyncdex.models.aggregate.VolumeAggregate[source]

Represents the aggregate of the chapters in a volume.

New in version 0.5.

Note

The data returned from the server does not have an aggregate for chapters without a name. However, a total count is given including the no-number chapters, which can be used to infer the number of chapters without a number. This number is stored as the None key.

Changed in version 1.1: The server now returns the actual count for chapters without a number. This can still be found in the None key.

Usage:

print(aggregate["1"]) # Prints the number of chapters for the chapter with number ``1``.
__repr__()str[source]

Provide a string representation of the object.

Returns

The string representation

Return type

str

chapters()List[Optional[str]][source]

Get the chapters contained in the aggregate.

Returns

The list of chapter numbers (including None if chapters without a chapter number exist)

Return type

List[Optional[str]]

parse(data: Dict[str, Any])[source]

Parse aggregate data.

total()int[source]

Get the total amount of chapters contained in this aggregate, or the sum of the individual chapter aggregates.

Returns

The sum of chapters in the aggregate

Return type

int

Attribute Dictionaries

class asyncdex.utils.AttrDict[source]

A dict where keys can be accessed by attributes.

New in version 0.2.

__getattr__(item: str)asyncdex.utils._VT[source]

Get a key of the dictionary by calling the attribute representing it.

Parameters

item (str) – The key to get.

Returns

The value that is held inside the dictionary.

Return type

Any

Raises

AttributeError if the attribute does not exist in the dict.

__repr__()str[source]

Provide a string representation of the object.

Returns

The string representation

Return type

str

__setattr__(key: str, value: asyncdex.utils._VT)[source]

Sets a key of the dictionary.

Parameters
  • key (str) – The key to set.

  • value (Any) – The value for the key.

first()asyncdex.utils._VT[source]

Return the first entry in the dictionary.

Returns

The first entry.

Raises

KeyError if there are no entries in the dictionary.

Return type

Any

class asyncdex.utils.DefaultAttrDict(mapping_or_iterable: Optional[Union[Mapping[str, asyncdex.utils._VT], Iterable[Tuple[str, asyncdex.utils._VT]]]] = None, *, default: Callable[], asyncdex.utils._VT])[source]

An AttrDict with a default.

New in version 0.2.

__missing__(key: str)asyncdex.utils._VT[source]

Apply the default if a key does not exist.

Parameters

key (str) – The key that is missing

Returns

The new default

Return type

Any

default

A callable that accepts no arguments and returns an instance of the value’s class.

Filtering Utilities

class asyncdex.utils.InclusionExclusionPair(include: List[asyncdex.utils._T] = <factory>, exclude: List[asyncdex.utils._T] = <factory>)[source]

A class representing an inclusion and exclusion pair.

New in version 0.3.

Note

It is an error to both include and exclude something.

exclude: List[asyncdex.utils._T]

Values that should not be present.

include: List[asyncdex.utils._T]

Values that should be present.

matches_include_exclude_pair(item: asyncdex.utils._T)bool[source]

Returns whether or not the item is inside the include and exclude pairs.

Parameters

item (Any) – The item to check.

Returns

Whether or not it matches the given bounds (in the include list or not in the exclude list).

Return type

bool

class asyncdex.utils.Interval(min: Optional[asyncdex.utils._T] = None, max: Optional[asyncdex.utils._T] = None, inclusive: bool = True)[source]

A class representing an interval.

New in version 0.3.

inclusive: bool = True

Whether or not the interval includes the min and max values or only values after and before respectively are considered.

max: Optional[asyncdex.utils._T] = None

The maximum value of the interval.

min: Optional[asyncdex.utils._T] = None

The minimum value of the interval.

List Orders

class asyncdex.list_orders.AuthorListOrder(name: Optional[asyncdex.enum.OrderDirection] = None)[source]

An object representing the various options for ordering a author list returned from MangadexClient.get_authors().

New in version 0.4.

name: Optional[asyncdex.enum.OrderDirection] = None

The name of an author.

class asyncdex.list_orders.ChapterListOrder(creation_time: Optional[asyncdex.enum.OrderDirection] = None, update_time: Optional[asyncdex.enum.OrderDirection] = None, publish_time: Optional[asyncdex.enum.OrderDirection] = None, title: Optional[asyncdex.enum.OrderDirection] = None, volume: Optional[asyncdex.enum.OrderDirection] = None, number: Optional[asyncdex.enum.OrderDirection] = None)[source]

An object representing the various options for ordering a chapter list returned from MangadexClient.get_chapters().

New in version 0.4.

creation_time: Optional[asyncdex.enum.OrderDirection] = None

The time a chapter was created.

number: Optional[asyncdex.enum.OrderDirection] = None

The chapter’s number.

publish_time: Optional[asyncdex.enum.OrderDirection] = None

The time a chapter was published.

title: Optional[asyncdex.enum.OrderDirection] = None

The title of the chapter 1.

update_time: Optional[asyncdex.enum.OrderDirection] = None

The time a chapter was updated.

volume: Optional[asyncdex.enum.OrderDirection] = None

The chapter’s volume.

class asyncdex.list_orders.CoverListOrder(creation_time: Optional[asyncdex.enum.OrderDirection] = None, update_time: Optional[asyncdex.enum.OrderDirection] = None, volume: Optional[asyncdex.enum.OrderDirection] = None)[source]

An object representing the various options for ordering a cover list returned from MangadexClient.get_covers().

New in version 1.0.

creation_time: Optional[asyncdex.enum.OrderDirection] = None

The time a cover was created.

update_time: Optional[asyncdex.enum.OrderDirection] = None

The time a cover was updated.

volume: Optional[asyncdex.enum.OrderDirection] = None

The cover’s volume

class asyncdex.list_orders.GroupListOrder(name: Optional[asyncdex.enum.OrderDirection] = None)[source]

An object representing the various options for ordering a group list returned from MangadexClient.get_groups().

New in version 0.5.

name: Optional[asyncdex.enum.OrderDirection] = None

The name of the scanlation group 1.

class asyncdex.list_orders.MangaListOrder(creation_time: Optional[asyncdex.enum.OrderDirection] = None, update_time: Optional[asyncdex.enum.OrderDirection] = None, titles: Optional[asyncdex.enum.OrderDirection] = None, year: Optional[asyncdex.enum.OrderDirection] = None)[source]

An object representing the various options for ordering a manga list returned from MangadexClient.search().

New in version 0.4.

creation_time: Optional[asyncdex.enum.OrderDirection] = None

The time a manga was created.

titles: Optional[asyncdex.enum.OrderDirection] = None

The titles of a manga 1.

update_time: Optional[asyncdex.enum.OrderDirection] = None

The time a manga was updated.

year: Optional[asyncdex.enum.OrderDirection] = None

The year a manga was published.

See also

Manga.year

class asyncdex.list_orders.MangaFeedListOrder(volume: Optional[asyncdex.enum.OrderDirection] = None, chapter: Optional[asyncdex.enum.OrderDirection] = None)[source]

An object representing the various options for ordering a manga feed list returned from the various manga feed endpoints.

New in version 0.5.

chapter: Optional[asyncdex.enum.OrderDirection] = None

The chapter number of a chapter.

volume: Optional[asyncdex.enum.OrderDirection] = None

The volume number of a chapter.

class asyncdex.list_orders.UserFollowsMangaFeedListOrder(volume: Optional[asyncdex.enum.OrderDirection] = None, chapter: Optional[asyncdex.enum.OrderDirection] = None, creation_time: Optional[asyncdex.enum.OrderDirection] = None, update_time: Optional[asyncdex.enum.OrderDirection] = None, publish_time: Optional[asyncdex.enum.OrderDirection] = None)[source]

An object representing the various options for ordering a manga feed list returned from the user followed manga feed.

New in version 1.1.

creation_time: Optional[asyncdex.enum.OrderDirection] = None

The time a chapter was created.

publish_time: Optional[asyncdex.enum.OrderDirection] = None

The time a chapter was published.

update_time: Optional[asyncdex.enum.OrderDirection] = None

The time a chapter was updated.

Model Containers

class asyncdex.models.abc.ModelList(iterable=(), /)[source]

An ABC representing a list of models.

Note

Models of different types should not be combined, meaning placing a Manga and a Chapter into the same list is invalid and will lead to undefined behavior.

New in version 0.5.

async fetch_all()[source]

Fetch all models.

New in version 0.5.

Changed in version 1.0: Added support for batching covers.

id_map()Dict[str, asyncdex.models.abc._T][source]

Return a mapping of item UUID to items.

New in version 0.5.

Returns

A dictionary where the keys are strings and the values are Model objects.

Return type

Dict[str, Model]

class asyncdex.models.abc.GenericModelList(iterable=(), /)[source]

A class representing a generic list of models with no special methods.

New in version 0.5.

class asyncdex.models.title.TitleList(iterable=(), /)[source]

An object representing a list of titles.

New in version 0.2.

__repr__()str[source]

Provide a string representation of the object.

Returns

The string representation

Return type

str

parts()Tuple[str, List[str]][source]

Return the parts of this Title List.

New in version 0.5.

Returns

The first title and a list of all remaining titles.

Return type

Tuple[str, List[str]]

property primary: Optional[str]

Returns the primary title for the language if it exists or else returns None.

Returns

The first title in the list.

Return type

str

class asyncdex.models.ChapterList(manga: Manga, *, entries: Optional[Iterable[asyncdex.models.chapter.Chapter]] = None)[source]

An object representing a list of chapters from a manga.

New in version 0.3.

Parameters

entries (Iterable[Chapter]) – Pre-fill the ChapterList with the given entries.

__repr__()str[source]

Provide a string representation of the object.

Returns

The string representation

Return type

str

calculate_aggregate()asyncdex.models.aggregate.MangaAggregate[source]

Calculates an aggregate of the chapters contained.

New in version 0.5.

Returns

The aggregate of the chapters.

Return type

MangaAggregate

async download_all(*, skip_bad: bool = True, folder_format: str = '{manga}/{chapter_num}{separator}{title}', file_format: str = '{num}', as_bytes_list: bool = False, overwrite: bool = True, retries: int = 3, use_data_saver: bool = False, ssl_only: bool = False)Dict[asyncdex.models.chapter.Chapter, Optional[List[str]]][source]

Download all chapters in the list.

New in version 0.4.

Parameters
  • skip_bad (bool) – Whether or not to skip bad chapters. Defaults to True.

  • folder_format (str) –

    The format of the folder to create for the chapter. The folder can already be existing. The default format is {manga}/{chapter_num}{separator}{chapter_title}.

    Note

    Specify . if you want to save the pages in the current folder.

    Available variables:

    • {manga}: The name of the manga. If the chapter’s manga object does not contain a title object, it will be fetched.

    • {chapter_num}: The number of the chapter, if it exists.

    • {separator}: A separator if both the chapter’s number and title exists.

    • {title}: The title of the chapter, if it exists.

  • file_format (str) –

    The format of the individual image file names. The default format is {num}.

    Note

    The file extension is applied automatically from the real file name. There is no need to include it.

    Available variables:

    • {num}: The numbering of the image files starting from 1. This respects the order the images are in inside of page_names.

    • {num0}: The same as {num} but starting from 0.

    • {name}: The actual filename of the image from page_names, without the file extension.

  • as_bytes_list (bool) – Whether or not to return the pages as a list of raw bytes. Setting this parameter to True will ignore the value of the folder_format parameter.

  • overwrite (bool) – Whether or not to override existing files with the same name as the page. Defaults to True.

  • retries (int) – How many times to retry a chapter if a MD@H node does not let us download the pages. Defaults to 3.

  • use_data_saver (bool) – Whether or not to use the data saver pages or the normal pages. Defaults to False.

  • ssl_only (bool) –

    Whether or not the given URL has port 443. Useful if your firewall blocks outbound connections to ports that are not port 443. Defaults to False.

    Note

    This will lower the pool of available clients and can cause higher download times.

Raises

aiohttp.ClientResponseError if there is an error after all retries are exhausted.

Returns

A dictionary mapping consisting of Chapter objects as keys and the data from that chapter’s download_chapter() method. If skip_bad is True, chapters with exceptions will have None instead of a list of bytes.

Return type

List[Optional[List[bytes]]]

async fetch_all()[source]

Fetch all models.

New in version 0.5.

Changed in version 1.0: Added support for batching covers.

filter(*, languages: Optional[List[str]] = None, creation_time: Optional[asyncdex.utils.Interval[datetime.datetime]] = None, update_time: Optional[asyncdex.utils.Interval[datetime.datetime]] = None, publish_time: Optional[asyncdex.utils.Interval[datetime.datetime]] = None, views: Optional[asyncdex.utils.Interval[int]] = None, has_number: Optional[bool] = None, chapter_number_range: Optional[asyncdex.utils.Interval[float]] = None, chapter_numbers: Optional[asyncdex.utils.InclusionExclusionPair[Optional[float]]] = None, remove_duplicates: bool = False, duplicate_strategy: Optional[List[asyncdex.enum.DuplicateResolutionAlgorithm]] = None, duplicate_strategy_groups: Optional[List[asyncdex.models.group.Group]] = None, duplicate_strategy_users: Optional[List[asyncdex.models.user.User]] = None, groups: Optional[asyncdex.utils.InclusionExclusionPair[asyncdex.models.group.Group]] = None, users: Optional[asyncdex.utils.InclusionExclusionPair[asyncdex.models.user.User]] = None, read: Optional[bool] = None, volumes: Optional[asyncdex.utils.InclusionExclusionPair[int]] = None)asyncdex.models.chapter_list.ChapterList[source]

Filter the chapter list and return a new ChapterList. Calling this method without specifying any additional filtering mechanisms will return a shallow copy of the list.

The order of the filter will be as follows:

  1. Filter the datetimes first

  2. Filter by the intervals

  3. Filter by the inclusion and exclusion pairs

  4. Filter duplicates

Changed in version 0.5: Parameter locales was renamed to languages

Deprecated since version 0.5: Parameter locales

Changed in version 1.0: Parameter locales was removed.

Parameters
  • languages (List[str]) – The languages that should be present in the chapters.

  • creation_time (Interval[datetime]) –

    An Interval representing the bounds of the chapter’s creation time. Interval.min will select all chapters created after the given time, and Interval.max will select all chapters created before the given time.

    Note

    The datetime objects needs to be a non-timezone aware datetime in UTC time. A datetime in any timezone can be converted to a naive UTC timezone by:

    from datetime import timezone
    # dt is the datetime object.
    utc_naive = dt.astimezone(timezone.utc).replace(tzinfo=None)
    

    Example intervals:

    from asyncdex import Interval
    min_interval = Interval(min=datetime.datetime(2021, 1, 1))
    max_interval = Interval(max=datetime.datetime(2021, 1, 1))
    both = Interval(datetime.datetime(2021, 1, 1), datetime.datetime(2021, 5, 1))
    

  • update_time (Interval[datetime]) –

    An Interval representing the bounds of the chapter’s update time. Interval.min will select all chapters updated after the given time, and Interval.max will select all chapters updated before the given time.

    Note

    The datetime objects needs to be a non-timezone aware datetime in UTC time. A datetime in any timezone can be converted to a naive UTC timezone by:

    from datetime import timezone
    # dt is the datetime object.
    utc_naive = dt.astimezone(timezone.utc).replace(tzinfo=None)
    

    Example intervals:

    from asyncdex import Interval
    min_interval = Interval(min=datetime.datetime(2021, 1, 1))
    max_interval = Interval(max=datetime.datetime(2021, 1, 1))
    both = Interval(datetime.datetime(2021, 1, 1), datetime.datetime(2021, 5, 1))
    

  • publish_time (Interval[datetime]) –

    An Interval representing the bounds of the chapter’s publish time. Interval.min will select all chapters published after the given time, and Interval.max will select all chapters published before the given time.

    Note

    The datetime objects needs to be a non-timezone aware datetime in UTC time. A datetime in any timezone can be converted to a naive UTC timezone by:

    from datetime import timezone
    # dt is the datetime object.
    utc_naive = dt.astimezone(timezone.utc).replace(tzinfo=None)
    

    Example intervals:

    min_interval = Interval(min=datetime.datetime(2021, 1, 1))
    max_interval = Interval(max=datetime.datetime(2021, 1, 1))
    both = Interval(datetime.datetime(2021, 1, 1), datetime.datetime(2021, 5, 1))
    

  • views (Interval[int]) –

    An Interval of the views that a manga can have.

    Warning

    The MangaDex API does not return views yet, so specifying something for this parameter will result in NotImplementedError being raised.

    Example intervals:

    from asyncdex import Interval
    min_interval = Interval(min=100)
    max_interval = Interval(max=25000)
    both = Interval(100, 25000)
    

  • has_number (bool) – Only select chapters with valid numbers.

  • chapter_number_range (Interval[float]) –

    An Interval of the number of the chapter.

    Note

    Chapters without a number will be given a provisional number of 0 when sorted.

    Example intervals:

    from asyncdex import Interval
    min_interval = Interval(min=2)
    max_interval = Interval(max=20.5)
    both = Interval(2, 20.5)
    

  • chapter_numbers (InclusionExclusionPair[float]) –

    An InclusionExclusionPair denoting the chapter numbers that are either included or excluded.

    Note

    Chapters without a number will be given a provisional number of 0 when sorted.

    Example inclusion/exclusion pairs:

    from asyncdex import InclusionExclusionPair
    include = InclusionExclusionPair(include=[5, 6])
    exclude = InclusionExclusionPair(exclude=[7, 8, 9.5])
    

  • remove_duplicates (bool) –

    Whether or not to remove duplicate chapters, ie chapters with the same chapter number.

    Note

    This will not take languages into consideration. Make sure to specify a locale in the languages parameter if you want duplicates filtered for a specific locale.

  • duplicate_strategy (List[DuplicateResolutionAlgorithm]) –

    The list of strategies used to resolve duplicates. See the values in DuplicateResolutionAlgorithm to find the possible algorithms. By default, the strategy of choosing the previous group and the strategy of choosing the first chapter chronologically when there is no previous group will be used.

    Note

    If an adequate strategy is not found for dealing with certain chapters, the fallback mechanism of selecting the chapter that was created first will be used.

  • duplicate_strategy_groups (List[Group]) –

    The groups to use for DuplicateResolutionAlgorithm.SPECIFIC_GROUP.

    Note

    If the group is not present in all the chapters for a specific number, an alternate resolution algorithm will be used. Use the include_groups param if you only want chapters from that group.

  • duplicate_strategy_users (List[User]) –

    The users to use for DuplicateResolutionAlgorithm.SPECIFIC_USER.

    Note

    If the user is not present in all the chapters for a specific number, an alternate resolution algorithm will be used. Use the include_users param if you only want chapters from that user.

  • users (InclusionExclusionPair[User]) – An InclusionExclusionPair denoting the users to include/exclude from the listing.

  • groups (InclusionExclusionPair[Group]) – An InclusionExclusionPair denoting the groups to include/exclude from the listing.

  • read (bool) –

    Whether or not the manga is read.

    New in version 0.5.

  • volumes (InclusionExclusionPair[int]) –

    An InclusionExclusionPair denoting the volumes to include/exclude from the listing.

    New in version 0.5.

Returns

A filtered ChapterList.

Note

The filtered list is not cached in Manga.chapters.

Return type

ChapterList

async get(*, languages: Optional[List[str]] = None, created_after: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, published_after: Optional[datetime.datetime] = None, order: Optional[asyncdex.list_orders.MangaFeedListOrder] = None, limit: Optional[int] = None)[source]

Gets the list of chapters.

Changed in version 0.5: * Parameter locales was renamed to languages

Deprecated since version 0.5: Parameter locales

Changed in version 1.0: Parameter locales was removed.

Parameters
  • languages (List[str]) – The languages to filter by.

  • created_after (datetime) –

    Get chapters created after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • updated_after (datetime) –

    Get chapters updated after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • published_after (datetime) –

    Get chapters published after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • order

    The order to sort the chapters.

    New in version 0.5.

  • limit (int) – Only return up to this many chapters.

async get_new(*, languages: Optional[List[str]] = None, created_after: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, published_after: Optional[datetime.datetime] = None, order: Optional[asyncdex.list_orders.MangaFeedListOrder] = None, limit: Optional[int] = None)asyncdex.models.chapter_list.ChapterList[source]

A method that gets chapters but returns a new ChapterList.

New in version 0.5.

Parameters
  • languages (List[str]) – The languages to filter by.

  • created_after (datetime) –

    Get chapters created after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • updated_after (datetime) –

    Get chapters updated after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • published_after (datetime) –

    Get chapters published after this date.

    Note

    The datetime object needs to be in UTC time. It does not matter if the datetime if naive or timezone aware.

  • order (MangaFeedListOrder) – The order to sort the chapters.

  • limit (int) – Only return up to this many chapters.

Returns

A new chapter list.

Return type

ChapterList

async get_read()[source]

Gets the list of chapters which are read. Chapters whose IDs are found in this list will be set as read. This method requires authentication with the MangaDex API.

New in version 0.5.

group_by_numbers()Dict[Optional[str], asyncdex.models.chapter_list.ChapterList][source]

Creates a dictionary mapping chapter numbers to chapters.

New in version 0.5.

Returns

A dictionary where the keys are chapter numbers and the values are a list of Chapter objects.

Return type

Dict[Optional[str], ChapterList]

group_by_volume_and_chapters()Dict[Tuple[Optional[str], Optional[str]], asyncdex.models.chapter_list.ChapterList][source]

Creates a dictionary mapping volume numbers and chapter numbers to chapters.

New in version 0.5.

Returns

A dictionary where the keys are a tuple of volume and chapter numbers and the values are a list of Chapter objects.

Return type

Dict[Tuple[Optional[str], Optional[str]], ChapterList]

group_by_volumes()Dict[Optional[str], asyncdex.models.chapter_list.ChapterList][source]

Creates a dictionary mapping volume numbers to chapters.

New in version 0.5.

Returns

A dictionary where the keys are volume numbers and the values are a list of Chapter objects.

Return type

Dict[Optional[str], ChapterList]

languages()List[str][source]

Get the list of languages that exist in the chapter list.

New in version 0.5.

Returns

A list of languages.

Return type

List[str]

manga: Manga

The Manga that this chapter list belongs to.

sort(*, key: Optional[Callable[[asyncdex.models.chapter.Chapter], Any]] = None, reverse: bool = False)[source]

Sort the ChapterList. This uses a natural sorting algorithm to sort the chapters.

Parameters
  • key (Callable[[Chapter], Any]) – An optional key if you want to override the sorting key used by the class.

  • reverse (bool) – Whether or not to reverse the list.

class asyncdex.models.CoverList(manga: Manga, *, entries: Optional[Iterable[asyncdex.models.cover_art.CoverArt]] = None)[source]

An object representing a list of covers from a manga.

New in version 1.0.

Parameters

entries (Iterable[CoverArt]) – Pre-fill the CoverList with the given entries.

async get()[source]

Get the covers for the manga.

manga: Manga

The Manga that this covers list belongs to.

class asyncdex.models.MangaList(client: MangadexClient, *, entries: Optional[Iterable[Manga]] = None)[source]

An object representing a list of manga.

New in version 0.5.

client: MangadexClient

The client that this manga list belongs to.

async fetch_all()[source]

Fetch all models.

New in version 0.5.

Changed in version 1.0: Added support for batching covers.

async get_covers()[source]

Fetches cover data for all primary covers in the manga list. This is an easy way to get the covers for 50 different mangas without making 50 network requests.

New in version 1.0.

async get_reading_status()[source]

Get the reading status of all manga in the list. This method requires authentication with the MangaDex API.

async set_reading_status(status: Optional[asyncdex.enum.FollowStatus])[source]

Sets the reading status of all manga in the list. Requires authentication.

Parameters

status (Optional[FollowStatus]) – The new status to set. Can be None to remove reading status.

Raises

Unauthorized is authentication is missing.

class asyncdex.models.tag.TagDict[source]

An object representing a dictionary of tag UUIDs to tag objects.

New in version 0.4.

__repr__()str[source]

Provide a string representation of the object.

New in version 0.5.

Returns

The string representation

Return type

str

groups()Dict[str, asyncdex.models.abc.GenericModelList[asyncdex.models.tag.Tag]][source]

Categorizes the tags contained into a dictionary of the groups the tags belong to.

Returns

A dictionary of group name to the list of tags that contain the name.

Return type

Dict[str, List[Tag]]

Model Mixins

class asyncdex.models.mixins.DatetimeMixin[source]

A mixin for models with created_at and updated_at attributes.

New in version 0.2.

__ge__(other: asyncdex.models.mixins._T)bool[source]

Compares the two object’s creation times to find if the current model’s creation time is greater than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than or equal to the other model’s creation time.

Return type

bool

__gt__(other: asyncdex.models.mixins._T)bool[source]

Compares the two object’s creation times to find if the current model’s creation time is greater than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is greater than the other model’s creation time.

Return type

bool

__le__(other: asyncdex.models.mixins._T)bool[source]

Compares the two object’s creation times to find if the current model’s creation time is less than or equal to the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than or equal to the other model’s creation time.

Return type

bool

__lt__(other: asyncdex.models.mixins._T)bool[source]

Compares the two object’s creation times to find if the current model’s creation time is less than the other model’s creation time.

New in version 0.3.

Parameters

other (DatetimeMixin) – The other model.

Returns

Whether or not the current model’s creation time is less than the other model’s creation time.

Return type

bool

created_at: datetime.datetime

A datetime.datetime representing the object’s creation time.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

property modified_at: datetime.datetime

The last time the object was modified. This will return the creation time if the object was never updated after creation, or the modification time if it has.

Returns

The last time the object was changed as a datetime.datetime object.

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

Return type

datetime.datetime

updated_at: Optional[datetime.datetime]

A datetime.datetime representing the last time the object was updated. May be None if the object was never updated after creation.

See also

modified_at()

Note

The datetime is timezone aware as it is parsed from an ISO-8601 string.

Pager

class asyncdex.models.pager.Pager(url: str, model: Type[asyncdex.models.pager._ModelT], client: MangadexClient, *, params: Optional[MutableMapping[str, Any]] = None, param_size: int = 150, limit_size: int = 100, limit: Optional[int] = None)[source]

A pager object which automatically paginates responses with an offset and limit combo.

New in version 0.3.

Parameters

limit_size (int) – The maximum limit for each request. Defaults to 100.

__aiter__()AsyncIterator[asyncdex.models.pager._ModelT][source]

Return an async iterator (itself)

Returns

The Pager class.

Return type

Pager

async __anext__()asyncdex.models.pager._ModelT[source]

Return a model from the queue. If there are no items remaining, a request is made to fetch the next set of items.

Changed in version 0.4: This method will no longer hang to complete all requests.

Changed in version 0.5: This method will fully respect limits even if the API does not.

Returns

The new model.

Return type

Model

__repr__()str[source]

Provide a string representation of the object.

Returns

The string representation

Return type

str

async as_list()asyncdex.models.abc.ModelList[asyncdex.models.pager._ModelT][source]

Returns all items in the Pager as a list.

Changed in version 0.5: If model is Manga, this method will return MangaList. Otherwise, this method will return a GenericModelList.

Returns

A ModelList with the total models.

Changed in version 0.5: Prior to 0.5, this method returned a normal list.

Return type

ModelList

client: MangadexClient

The client that is associated with the Pager.

limit: Optional[int]

The Pager will only return up to these many items.

New in version 0.4.

model: Type[asyncdex.models.pager._ModelT]

A subclass of Model to transform the results into.

param_size: int

How many parameters can be included in a given request.

New in version 1.0.

params: MutableMapping[str, Any]

Additional params to include in every request.

returned: int

How many items were returned so far.

New in version 0.5.

url: str

The URL to paginate against.

Ratelimit

class asyncdex.ratelimit.Path(name: str, path_regex: re.Pattern, method: Optional[str] = None)[source]

A Path object representing a various path.

method: Optional[str] = None

The HTTP method for the path. Leave None if ratelimit applies to all methods.

name: str

The name of the path. This will be the value provided by Ratelimit.path.

path_regex: re.Pattern

A compiled regex pattern matching the path, used when the path has a variable, such as /action/{id}.

class asyncdex.ratelimit.PathRatelimit(path: asyncdex.ratelimit.Path, ratelimit_amount: int, ratelimit_time: int)[source]

An object that allows the request method to check the ratelimit before making a response.

can_call(method: str)bool[source]

Returns whether or not this route can be used right now.

Parameters

method (str) – The HTTP method being used.

Returns

Whether or not this route can be used without ratelimit.

Return type

bool

expire()[source]

Expire the ratelimit.

path: asyncdex.ratelimit.Path

A Path object.

ratelimit_amount: int

Analogous to Ratelimit.ratelimit_amount

ratelimit_enqueued: int = 0

How many requests are currently sleeping. This is used to up the sleep time to prevent a number of requests more than double the ratelimit_time amount of requests.

ratelimit_expires: datetime.datetime = datetime.datetime(1, 1, 1, 0, 0)

Analogous to Ratelimit.ratelimit_expires

ratelimit_time: int

The amount of time needed for the ratelimit to expire after the first use.

ratelimit_used: int = 0

How many times the path has been called since the last ratelimit expire.

time_until_expire()datetime.timedelta[source]

Returns a datetime.timedelta representing the amount of seconds for the ratelimit to expire.

update(response: aiohttp.client_reqrep.ClientResponse)[source]

Update the path’s ratelimit based on the headers.

Parameters

response (aiohttp.ClientResponse) – The response object.

class asyncdex.ratelimit.Ratelimits(*ratelimits: asyncdex.ratelimit.PathRatelimit)[source]

An object holding all of the various ratelimits.

Parameters

ratelimits (PathRatelimit) – The PathRatelimit object.

__repr__()str[source]

Provide a string representation of the object.

Returns

The string representation

Return type

str

add(obj: asyncdex.ratelimit.PathRatelimit)[source]

Add a new ratelimit. If the path is the same as an existing path, it will be overwritten.

Parameters

obj (PathRatelimit) – The new ratelimit object to add.

async check(url: str, method: str)Tuple[float, Optional[asyncdex.ratelimit.PathRatelimit]][source]

Check if a path is ratelimited.

Parameters
  • url (str) – The path, starting with /

  • method (str) – The HTTP method being used.

Returns

A number representing the amount of seconds before ratelimit expire or -1 if there is no need to ratelimit as well as the PathRatelimit object if found.

Return type

float

ratelimit_dictionary: Dict[re.Pattern, asyncdex.ratelimit.PathRatelimit]

A dictionary where the keys are regex patterns representing the paths and the values are PathRatelimit objects.

remove(obj: asyncdex.ratelimit.PathRatelimit)[source]

Remove a ratelimit.

Parameters

obj (PathRatelimit) – The new ratelimit object to remove.

async sleep(url: str, method: str)Optional[asyncdex.ratelimit.PathRatelimit][source]

Helper function that sleeps the amount of time returned by check().

Parameters
  • url (str) – The path, starting with /

  • method (str) – The HTTP method being used.

Returns

The PathRatelimit object if found

Return type

PathRatelimit

Misc Functions

asyncdex.utils.copy_key_to_attribute(source_dict: dict, key: str, obj: Any, attribute_name: Optional[str] = None, *, default: Any = Sentinel, transformation: Optional[Callable[[str], Any]] = None)[source]

Copies the value of a dictionary’s key to an object.

New in version 0.2.

Parameters
  • source_dict (dict) – The dictionary with the key and value.

  • key (str) – The key that has the value.

  • obj (Any) – The object to set the attribute of.

  • attribute_name (str) – The name of the attribute to set if the name of the key and the name of the attribute are different.

  • default (Any) – A default value to add if the value is not found.

  • transformation (Callable[[str], Any]) – A callable that will be executed on the value of the key. It should accept a str and can return anything.

asyncdex.utils.parse_relationships(data: dict, obj: Model)[source]

Parse the relationships available in a model.

New in version 0.2.

Changed in version 0.3: Added support for Chapter, User, and :class:.Group` objects.

Parameters
  • data (dict) – The raw data received from the API.

  • obj (Model) – The object to add the models to.

asyncdex.utils.remove_prefix(prefix: str, string: str)str[source]

Remove a prefix from a string. This is a polyfill for Python versions <3.9.

Parameters
  • prefix (str) – The prefix to remove

  • string (str) – The string to remove the prefix from

Returns

The string without the prefix

Return type

str

asyncdex.utils.return_date_string(datetime_obj: datetime.datetime)[source]

Get a representation of a datetime object suitable for the MangaDex API.

New in version 0.3.

Changed in version 0.4: The method was changed from a private method to a seperate utility.

Parameters

datetime_obj (datetime) – The datetime object.

Returns

A string representation suitable for the API.

Return type

str

References

  • 1(1,2,3,4,5)

    This parameter is undocumented in the API as of May 16, 2021. The inclusion of this parameter can be found in the changelog of the v5.0.6 release of the API, found in the MangaDex Discord.