-
Notifications
You must be signed in to change notification settings - Fork 6
MangaDex
Represents the MangaDex API Client.
Yields:
-
api
str
The URL of the MangaDex API. -
net_api
str
The URL of the MangaDex Network API. -
session
Requests.Session
The Session object used to store cookies and headers. -
login_success
bool
Whether or not login has succeeded. -
session_token
str
The Session token used by the MangaDex API to authenticate the user. -
refresh_token
str
The Refresh token used to regenerate a Session token after it has expired. -
rate_limit
float
The rate limit to apply to for loops. 0.2 means a request every 0.2 seconds, meaning 5 rqps. 0.25 is the default to stay safe.
Logs in to MangaDex using an username and a password.
You might need to verify your email address in order to use the API or certain API calls, so bear that in mind if it isn't verified.
Logging in isn't required, but some features requires that you do.
Please note that the wrapper only sends credentials to MangaDex. Your credentials are never stored locally.
Returns: True
if successful.
Raises: LoginError
if credentials are invalid, APIError
if something went wrong.
Arguments:
-
username
: Your MangaDex username. -
password
: Your MangaDex password.
Logs in to MangaDex using a refresh token.
Returns: True
if successful.
Raises: LoginError
if credentials are invalid, APIError
if something went wrong.
Arguments:
-
token
: A valid MangaDex refresh token.
Resets the MangaDex
object.
Returns: Nothing
Refreshes the session using the refresh token.
Returns: True
if successful.
Raises: LoginError
if token has expired, APIError
if something went wrong.
Arguments:
-
token
: The refresh token.
Checks if the stored Authorization token is still valid.
Returns: True
if the token is valid, False
if it has expired
Raises: APIError
if something went wrong.
Gets a manga with the specified UUID.
Returns: Manga
Raises:
-
NoContentError
when the UUID didn't return anything (404) -
APIError
as a generic error (500s, ...)
Arguments:
-
uuid
: The UUID of the Manga. -
includes
: Relationships to populate (e.g. ['author', 'artist'] will give direct reference for Author and Artist in the Manga object)
Gets a chapter with the specified UUID.
Returns: Chapter
Raises:
-
NoContentError
when the UUID didn't return anything (404) -
APIError
as a generic error (500s, ...)
Arguments:
-
uuid
: The UUID of the Chapter. -
includes
: Relationships to populate (e.g. ['scanlation_group', 'user'] will give direct reference for Group and User in the Chapter object)
Gets a chapter with the specified UUID.
Returns: Array[Chapter
]
Raises:
-
NoResultsError
when no objects were found (204) -
APIError
as a generic error (500s, ...)
Arguments:
-
ids
: A list of Chapter UUIDs. -
includes
: Relationships to populate (e.g. ['scanlation_group', 'user'] will give direct reference for Group and User in Chapters objects)
Gets all chapters associated with a specific Manga.
Returns: Array[Chapter
]
Raises:
-
NoResultsError
when no objects were found (204) -
APIError
as a generic error (500s, ...)
Arguments:
-
mg
: Manga -
params
: Custom dictionary of parameters to pass to the search utility. -
includes
: Relationships to populate (e.g. ['scanlation_group', 'user'] will give direct reference for Group and User in Chapters objects)
Gets all covers associated with a specific Manga.
Returns: Array[Cover
]
Raises:
-
NoResultsError
when no objects were found (204) -
APIError
as a generic error (500s, ...)
Arguments:
-
mg
: Manga -
params
: Custom dictionary of parameters to pass to the search utility.
Gets a cover with the specified UUID.
Returns: Cover
Raises:
-
NoContentError
when the UUID didn't return anything (404) -
APIError
as a generic error (500s, ...)
Arguments:
-
uuid
: The UUID of the Cover.
Pulls a chapter from the MD@H Network. more info
Returns: NetworkChapter
Raises: APIError
Arguments:
-
ch
: Chapter -
force_443
: Forces the backend to get a node with the standard HTTPS port
Reports statistics for a chapter pulled from the MD@H Network. more info
Returns: True
on success
Raises: APIError
Arguments:
-
url
: The full URL of the retrieved image. -
success
: Whether or not the image was retrieved successfully. -
cache_header
: Whether or not the X-Cache header returned HIT. -
req_bytes
: Bytes transferred during the request. -
req_duration
: The duration of the request.
Gets a group with the specified UUID.
Returns: Group
Raises:
-
NoContentError
when the UUID didn't return anything (404) -
APIError
as a generic error (500s, ...)
Arguments:
-
uuid
: The UUID of the Group. -
includes
: Relationships to populate (e.g. ['scanlation_group', 'user'] will give direct reference for Group and User in Chapters objects)
Gets an user with the specified UUID.
Returns: User
Raises:
-
NoContentError
when the UUID didn't return anything (404) -
APIError
as a generic error (500s, ...)
Arguments:
-
uuid
: The UUID of the User. Leave empty to select the currently logged in user.
Gets the current user's list.
You must be logged in to use this call.
Returns: Array[Manga
, ...]
Raises:
-
NotLoggedInError
when no user is logged in (!=login_success) -
NoResultsError
when no objects were found (204) -
APIError
as a generic error (500s, ...)
Arguments:
-
limit
: How much Mangas to retrieve. Note that each multiple of 100 will make a new request to the API, bear that in mind when it comes to ratelimiting.
Gets the current user's manga feed.
You must be logged in to use this call.
Returns: Array[Chapter
, ...]
Raises:
-
NotLoggedInError
when no user is logged in (!=login_success) -
NoResultsError
when no objects were found (204) -
APIError
as a generic error (500s, ...)
Arguments:
-
limit
: How much Chapters to retrieve. Note that each multiple of 100 will make a new request to the API, bear that in mind when it comes to ratelimiting. -
params
: Custom dictionary of parameters to pass to the search utility.
Gets an author/artist with the specified UUID.
Note: authors and artists are the same API-wise
Returns: Author
Raises:
-
NoContentError
when the UUID didn't return anything (404) -
APIError
as a generic error (500s, ...)
Arguments:
-
uuid
: The UUID of the Author.
Alias for get_author() above.
Transforms legacy IDs to UUIDs.
Returns: Array{int: str, ...}
Raises: APIError
Arguments:
-
obj
: What to convert (can be either 'manga', 'chapter', 'group', 'tag'). -
content
: An array of legay IDs.
Searches an object through the API.
Returns: Array[Object]
Raises:
-
NoResultsError
when no objects were found (204) -
APIError
as a generic error (500s, ...)
Arguments:
-
obj
: Object to search (can be either 'manga', 'chapter', 'group', 'author', 'cover', 'user'). -
params
: Parameters to pass to the search utility. -
limit
: How much objects to retrieve. Note that each multiple of 100 will make a new request to the API, bear that in mind when it comes to ratelimiting.
Base class for exceptions.
Represents an API Error.
-
status
int
The HTTP code returned by the request made to the API. -
data
dict(Response)/str
Data representing what happened with the API. Can be a dictionary.
'Logging in failed'-type error.
A search request returned nothing.