MDApi
public class MDApi : NSObject
The main MangaDex API class, which should be used to access the framework’s capabilities
-
Base URL for the MangaDex website
Declaration
Swift
public static let websiteBaseURL: String
-
Base URL for the MangaDex API
Declaration
Swift
public static let apiBaseURL: String
-
Base URL for the MangaDex network API
Declaration
Swift
public static let networkBaseURL: String
-
Base URL for MangaDex uploaded resources
Declaration
Swift
public static let uploadsBaseURL: String
-
Default value appended after the default User-Agent for all requests made by the MangaDexLib
Declaration
Swift
public static let defaultUserAgent: String
-
Instance of
MDRequestHandler
used to perform all requestsDeclaration
Swift
public let requestHandler: MDRequestHandler
-
Session token provided by the API after login
Note
This token is valid for 15 minutes and must be refreshed afterwardsDeclaration
Swift
public internal(set) var sessionJwt: String? { get set }
-
Refresh token provided by the API after login
Note
This token is valid for 1 month and can be used to obtain a newsessionJwt
Declaration
Swift
public internal(set) var refreshJwt: String? { get }
-
Setter for the User-Agent to use for requests
Declaration
Swift
public func setUserAgent(_ userAgent: String)
-
Create a new account with the given information
Declaration
Swift
public func createAccount(info: MDAccountInfo, completion: @escaping (MDResult<MDUser>?, MDApiError?) -> Void)
Parameters
info
The account information
completion
The completion block called once the request is done
-
Activate an account
Declaration
Swift
public func activateAccount(activationCode: String, completion: @escaping (MDApiError?) -> Void)
Parameters
activationCode
The activation code sent to the provided email address
completion
The completion block called once the request is done
-
Ask for an activation code to be resent
Declaration
Swift
public func resendActivationCode(email: String, completion: @escaping (MDApiError?) -> Void)
Parameters
email
The account email
completion
The completion block called once the request is done
-
Start the recovery process for an account
Declaration
Swift
public func requestAccountRecovery(email: String, completion: @escaping (MDApiError?) -> Void)
Parameters
email
The account email
completion
The completion block called once the request is done
-
Commplete the recovery process for an account
Precondition
Having calledrequestAccountRecovery
Declaration
Swift
public func completeAccountRecovery(recoveryCode: String, newPassword: String, completion: @escaping (MDApiError?) -> Void)
Parameters
recoveryCode
The recovery code sent to the account’s email address
newPassword
The new password to set for the account
completion
The completion block called once the request is done
-
Login to MangaDex
Precondition
The user must not be logged-inDeclaration
Swift
public func login(credentials: MDAuthCredentials, completion: @escaping (MDApiError?) -> Void)
Parameters
credentials
The user’s credentials
completion
The completion block called once the request is done
-
Logout of MangaDex
Precondition
The user must be logged-inDeclaration
Swift
public func logout(completion: @escaping (MDApiError?) -> Void)
Parameters
completion
The completion block called once the request is done
-
Check that the current session token is valid and get its information
Declaration
Swift
public func checkToken(completion: @escaping (MDAuthInfo?, MDApiError?) -> Void)
Parameters
completion
The completion block called once the request is done
-
Refresh the current session token
This should be called every 15 minutes, as the session JWT will have expired
Precondition
The user must be logged-inDeclaration
Swift
public func refreshToken(completion: @escaping (MDApiError?) -> Void)
Parameters
completion
The completion block called once the request is done
-
Get the list of authors
Declaration
Swift
public func getAuthorList(filter: MDAuthorFilter? = nil, includes: [MDObjectType]? = nil, completion: @escaping (MDResultList<MDAuthor>?, MDApiError?) -> Void)
Parameters
filter
The filter to use
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Create an author with the specified information
Precondition
The user must be logged-inDeclaration
Swift
public func createAuthor(info: MDAuthor, completion: @escaping (MDResult<MDAuthor>?, MDApiError?) -> Void)
Parameters
info
The author information
completion
The completion block called once the request is done
-
View the specified author’s information
Declaration
Swift
public func viewAuthor(authorId: String, includes: [MDObjectType]? = nil, completion: @escaping (MDResult<MDAuthor>?, MDApiError?) -> Void)
Parameters
authorId
The id of the author
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Update the specified author’s information
Precondition
The user must be logged-inDeclaration
Swift
public func updateAuthor(authorId: String, info: MDAuthor, completion: @escaping (MDResult<MDAuthor>?, MDApiError?) -> Void)
Parameters
authorId
The id of the author
info
The author information
completion
The completion block called once the request is done
-
Delete the specified author
Precondition
The user must be logged-inDeclaration
Swift
public func deleteAuthor(authorId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
authorId
The id of the author
completion
The completion block called once the request is done
-
Get the list of latest published chapters
Declaration
Swift
public func getChapterList(filter: MDChapterFilter? = nil, includes: [MDObjectType]? = nil, completion: @escaping (MDResultList<MDChapter>?, MDApiError?) -> Void)
Parameters
filter
The filter to use
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
View the specified chapter’s information
Declaration
Swift
public func viewChapter(chapterId: String, includes: [MDObjectType]? = nil, completion: @escaping (MDResult<MDChapter>?, MDApiError?) -> Void)
Parameters
chapterId
The id of the chapter
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Update the specified chapter’s information
Precondition
The user must be logged-inDeclaration
Swift
public func updateChapter(chapterId: String, info: MDChapter, completion: @escaping (MDResult<MDChapter>?, MDApiError?) -> Void)
Parameters
chapterId
The id of the chapter
info
The chapter information
completion
The completion block called once the request is done
-
Delete the specified chapter
Precondition
The user must be logged-inDeclaration
Swift
public func deleteChapter(chapterId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
chapterId
The id of the chapter
completion
The completion block called once the request is done
-
Mark the specified chapter as read
Precondition
The user must be logged-inDeclaration
Swift
public func markChapterRead(chapterId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
chapterId
The id of the chapter
completion
The completion block called once the request is done
-
Mark the specified chapter as unread
Precondition
The user must be logged-inDeclaration
Swift
public func markChapterUnread(chapterId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
chapterId
The id of the chapter
completion
The completion block called once the request is done
-
Get the list of latest published covers
Declaration
Swift
public func getCoverList(filter: MDCoverFilter? = nil, includes: [MDObjectType]? = nil, completion: @escaping (MDResultList<MDCover>?, MDApiError?) -> Void)
Parameters
filter
The filter to use
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
View the specified cover’s information
Declaration
Swift
public func viewCover(coverId: String, includes: [MDObjectType]? = nil, completion: @escaping (MDResult<MDCover>?, MDApiError?) -> Void)
Parameters
coverId
The id of the cover
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Update the specified cover’s information
Precondition
The user must be logged-inDeclaration
Swift
public func updateCover(coverId: String, info: MDCover, completion: @escaping (MDResult<MDCover>?, MDApiError?) -> Void)
Parameters
coverId
The id of the cover
info
The cover information
completion
The completion block called once the request is done
-
Delete the specified cover
Precondition
The user must be logged-inDeclaration
Swift
public func deleteCover(coverId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
coverId
The id of the cover
completion
The completion block called once the request is done
-
Create a custom list with the specified information
Precondition
The user must be logged-inDeclaration
Swift
public func createCustomList(info: MDCustomList, completion: @escaping (MDResult<MDCustomList>?, MDApiError?) -> Void)
Parameters
info
The list information
completion
The completion block called once the request is done
-
View the specified custom list’s information
Precondition
The user must be logged-inDeclaration
Swift
public func viewCustomList(listId: String, completion: @escaping (MDResult<MDCustomList>?, MDApiError?) -> Void)
Parameters
listId
The id of the custom list
completion
The completion block called once the request is done
-
Update the specified custom list’s information
Precondition
The user must be logged-inDeclaration
Swift
public func updateCustomList(listId: String, info: MDCustomList, completion: @escaping (MDResult<MDCustomList>?, MDApiError?) -> Void)
Parameters
listId
The id of the custom list
info
The custom list information
completion
The completion block called once the request is done
-
Delete the specified custom list
Precondition
The user must be logged-inDeclaration
Swift
public func deleteCustomList(listId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
listId
The id of the custom list
completion
The completion block called once the request is done
-
Get the specified custom list’s feed (aka its list of chapters)
Precondition
The user must be logged-inDeclaration
Swift
public func getCustomListFeed(listId: String, filter: MDFeedFilter? = nil, completion: @escaping (MDResultList<MDChapter>?, MDApiError?) -> Void)
Parameters
listId
The id of the custom list
filter
The filter to apply
completion
The completion block called once the request is done
-
Get the list of scanlation groups
Declaration
Swift
public func getGroupList(filter: MDGroupFilter? = nil, includes: [MDObjectType]? = nil, completion: @escaping (MDResultList<MDGroup>?, MDApiError?) -> Void)
Parameters
filter
The filter to use
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Create a scanlation group with the specified information
Precondition
The user must be logged-inDeclaration
Swift
public func createGroup(info: MDGroup, completion: @escaping (MDResult<MDGroup>?, MDApiError?) -> Void)
Parameters
info
The scanlation group information
completion
The completion block called once the request is done
-
View the specified scanlation group’s information
Declaration
Swift
public func viewGroup(groupId: String, includes: [MDObjectType]? = nil, completion: @escaping (MDResult<MDGroup>?, MDApiError?) -> Void)
Parameters
groupId
The id of the scanlation group
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Update the specified scanlation group’s information
Precondition
The user must be logged-inDeclaration
Swift
public func updateGroup(groupId: String, info: MDGroup, completion: @escaping (MDResult<MDGroup>?, MDApiError?) -> Void)
Parameters
groupId
The scanlation group’s id
info
The scanlation group information
completion
The completion block called once the request is done
-
Delete the specified scanlation group
Precondition
The user must be logged-inDeclaration
Swift
public func deleteGroup(groupId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
groupId
The id of the scanlation group
completion
The completion block called once the request is done
-
Follow the specified scanlation group
Precondition
The user must be logged-inDeclaration
Swift
public func followGroup(groupId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
groupId
The id of the scanlation group
completion
The completion block called once the request is done
-
Unfollow the specified scanlation group
Precondition
The user must be logged-inDeclaration
Swift
public func unfollowGroup(groupId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
groupId
The id of the scanlation group
completion
The completion block called once the request is done
-
Get the MD@Home node URL hosting the specified chapter’s page images
If you do not want to use a MD@Home node, you can use one of the values of the
MDImageServer
enum Also seeMDChapter.getPageUrls
Precondition
The user must be logged-inDeclaration
Swift
public func getChapterServer(chapterId: String, forcePort443: Bool = false, completion: @escaping (MDAtHomeNode?, MDApiError?) -> Void)
Parameters
chapterId
The id of the chapter
forcePort443
Force selecting from MangaDex@Home servers that use the standard HTTPS port 443. This might be useful for networks with aggressive firewalls (e.g. school/office networks)
completion
The completion block called once the request is done
-
Send a report after fetching an image from a MD@Home node
Declaration
Swift
public func sendAtHomeReport(info: MDAtHomeReport, completion: @escaping (MDApiError?) -> Void)
Parameters
info
The report information
completion
The completion block called once the request is done
-
Get the mapping between legacy object IDs and new object IDs
Declaration
Swift
public func getLegacyMapping(query: MDMappingQuery, completion: @escaping ([MDResult<MDMapping>]?, MDApiError?) -> Void)
Parameters
query
The mappings to ask for
completion
The completion block called once the request is done
-
Ping the MangaDex website to ensure it is up
Declaration
Swift
public func ping(completion: @escaping (MDApiError?) -> Void)
Parameters
completion
The completion block called once the request is done
-
Solve a captcha challenge sent by MangaDex
Declaration
Swift
public func solveCaptcha(challenge: String, completion: @escaping (MDApiError?) -> Void)
Parameters
challenge
The solution to the challenge
completion
The completion block called once the request is done
-
Get the list of latest updated mangas
Declaration
Swift
public func getMangaList(filter: MDMangaFilter? = nil, includes: [MDObjectType]? = nil, completion: @escaping (MDResultList<MDManga>?, MDApiError?) -> Void)
Parameters
filter
The filter to use
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Get the list of existing tags for mangas
Declaration
Swift
public func getMangaTagList(completion: @escaping ([MDResult<MDTag>]?, MDApiError?) -> Void)
Parameters
completion
The completion block called once the request is done
-
Get a random manga
Declaration
Swift
public func getRandomManga(includes: [MDObjectType]? = nil, completion: @escaping (MDResult<MDManga>?, MDApiError?) -> Void)
Parameters
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Create a new manga with the specified information
Precondition
The user must be logged-inDeclaration
Swift
public func createManga(info: MDManga, completion: @escaping (MDResult<MDManga>?, MDApiError?) -> Void)
Parameters
info
The manga information
completion
The completion block called once the request is done
-
View the specified manga’s information
Declaration
Swift
public func viewManga(mangaId: String, includes: [MDObjectType]? = nil, completion: @escaping (MDResult<MDManga>?, MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Update the specified manga’s information
Precondition
The user must be logged-inDeclaration
Swift
public func updateManga(mangaId: String, info: MDManga, completion: @escaping (MDResult<MDManga>?, MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
info
The manga information
completion
The completion block called once the request is done
-
Delete the specified manga
Precondition
The user must be logged-inDeclaration
Swift
public func deleteManga(mangaId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
completion
The completion block called once the request is done
-
Follow the specified manga
Precondition
The user must be logged-inDeclaration
Swift
public func followManga(mangaId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
completion
The completion block called once the request is done
-
Unfollow the specified manga
Precondition
The user must be logged-inDeclaration
Swift
public func unfollowManga(mangaId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
completion
The completion block called once the request is done
-
Add the specified manga to the logged-in user’s custom list
Precondition
The user must be logged-inDeclaration
Swift
public func addMangaToCustomList(mangaId: String, listId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
listId
The id of the custom list
completion
The completion block called once the request is done
-
Remove the specified manga from the logged-in user’s custom list
Precondition
The user must be logged-inDeclaration
Swift
public func removeMangaFromCustomList(mangaId: String, listId: String, completion: @escaping (MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
listId
The id of the custom list
completion
The completion block called once the request is done
-
Get the specified manga’s feed (aka its list of chapters)
Declaration
Swift
public func getMangaFeed(mangaId: String, filter: MDFeedFilter? = nil, includes: [MDObjectType]? = nil, completion: @escaping (MDResultList<MDChapter>?, MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
filter
The filter to apply
includes
The additional relationships to load (see Reference Expansion)
completion
The completion block called once the request is done
-
Get the specified manga’s aggregation of volumes and chapters
Declaration
Swift
public func getMangaVolumesAndChapters(mangaId: String, languages: [Locale]? = nil, completion: @escaping (MDAggregate?, MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
languages
The list of translated languages to filter on
Return Value
The MangaDex URL
-
Get a list of chapter ids that are marked as read for the specified manga and the logged-in user
Precondition
The user must be logged-inDeclaration
Swift
public func getMangaReadMarkers(mangaId: String, completion: @escaping (MDReadMarkers?, MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
completion
The completion block called once the request is done
-
Get a list of chapter ids that are marked as read for the specified mangas and the logged-in user
Precondition
The user must be logged-inDeclaration
Swift
public func getMangasReadMarkers(mangaIds: [String], completion: @escaping (MDReadMarkers?, MDApiError?) -> Void)
Parameters
mangaIds
The list of manga ids
completion
The completion block called once the request is done
-
Get all of the logged-in user’s reading statuses
Precondition
The user must be logged-inDeclaration
Swift
public func getReadingStatuses(filter: MDReadingStatus? = nil, completion: @escaping (MDReadingStatuses?, MDApiError?) -> Void)
Parameters
filter
The filter to apply
completion
The completion block called once the request is done
-
Get all of the logged-in user’s reading statuses
Precondition
The user must be logged-inDeclaration
Swift
public func getMangaReadingStatus(mangaId: String, completion: @escaping (MDReadingStatus?, MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
completion
The completion block called once the request is done
-
Update the logged-in user’s reading status for the specified manga
Precondition
The user must be logged-inNote
Setting the reading status tonil
will remove itDeclaration
Swift
public func updateMangaReadingStatus(mangaId: String, status: MDReadingStatus?, completion: @escaping (MDApiError?) -> Void)
Parameters
mangaId
The id of the manga
status
The new reading status
completion
The completion block called once the request is done
-
Get the list of users
Precondition
The user must be logged-inDeclaration
Swift
public func getUserList(filter: MDUserFilter? = nil, completion: @escaping (MDResultList<MDUser>?, MDApiError?) -> Void)
Parameters
filter
The filter to use
completion
The completion block called once the request is done
-
View the specified user’s information
Declaration
Swift
public func viewUser(userId: String, completion: @escaping (MDResult<MDUser>?, MDApiError?) -> Void)
Parameters
userId
The id of the user
completion
The completion block called once the request is done
-
View the specified user’s custom lists
Precondition
The user must be logged-inDeclaration
Swift
public func getUserCustomLists(userId: String, pagination: MDPaginationFilter? = nil, completion: @escaping (MDResultList<MDCustomList>?, MDApiError?) -> Void)
Parameters
userId
The id of the user
pagination
The pagination filter to apply
completion
The completion block called once the request is done
-
View the logged-in user’s information
Precondition
The user must be logged-inDeclaration
Swift
public func viewLoggedUser(completion: @escaping (MDResult<MDUser>?, MDApiError?) -> Void)
Parameters
completion
The completion block called once the request is done
-
Update the logged-in user’s password
Precondition
The user must be logged-inDeclaration
Swift
public func updateLoggedUserPassword(old: String, new: String, completion: @escaping (MDApiError?) -> Void)
Parameters
old
The user’s old password
new
The user’s new password
completion
The completion block called once the request is done
-
Update the logged-in user’s email address
Precondition
The user must be logged-inDeclaration
Swift
public func updateLoggedUserEmail(email: String, completion: @escaping (MDApiError?) -> Void)
Parameters
new
The user’s new email address
completion
The completion block called once the request is done
-
Get the list of mangas followed by the logged-in user
Precondition
The user must be logged-inDeclaration
Swift
public func getLoggedUserFollowedMangaList(pagination: MDPaginationFilter? = nil, completion: @escaping (MDResultList<MDManga>?, MDApiError?) -> Void)
Parameters
pagination
The pagination filter to apply
completion
The completion block called once the request is done
-
Get the logged-in user’s followed manga feed (aka their list of recent chapters)
Precondition
The user must be logged-inDeclaration
Swift
public func getLoggedUserFollowedMangaFeed(filter: MDFeedFilter? = nil, completion: @escaping (MDResultList<MDChapter>?, MDApiError?) -> Void)
Parameters
filter
The filter to apply
completion
The completion block called once the request is done
-
Get the list of scanlation groups followed by the logged-in user
Precondition
The user must be logged-inDeclaration
Swift
public func getLoggedUserFollowedGroupList(pagination: MDPaginationFilter? = nil, completion: @escaping (MDResultList<MDGroup>?, MDApiError?) -> Void)
Parameters
pagination
The pagination filter to apply
completion
The completion block called once the request is done
-
Get the list of users followed by the logged-in user
Precondition
The user must be logged-inDeclaration
Swift
public func getLoggedUserFollowedUserList(pagination: MDPaginationFilter? = nil, completion: @escaping (MDResultList<MDUser>?, MDApiError?) -> Void)
Parameters
pagination
The pagination filter to apply
completion
The completion block called once the request is done
-
Get the logged-in user’s custom lists
Precondition
The user must be logged-inDeclaration
Swift
public func getLoggedUserCustomLists(pagination: MDPaginationFilter? = nil, completion: @escaping (MDResultList<MDCustomList>?, MDApiError?) -> Void)
Parameters
pagination
The pagination filter to apply
completion
The completion block called once the request is done