Skip to content

mangadex-full-api version 5.2.0

Compare
Choose a tag to compare
@md-y md-y released this 20 Jun 10:26
· 138 commits to master since this release

'Includes' Parameter

(Edited to account for the changes from 5.3.0)

Changes between 5.2.0 and 5.3.0 The included objects are always returned as relationships as described below instead of normal objects with an extra resolve function. The actual objects that are resolved are the same however.

Implemented support for the includes[] parameter for endpoints. This endpoint will have the desired object return with additional objects referenced through relationships. For example includes[]=author for a manga request will return the manga object along with the author object (although without the author's relationships).

This is used by setting the includeSubObjects parameter to true for supported methods such as Manga.get(), Manga.getFeed(), Chapter.get(), and others. The result of these functions will be relationships, but the resolve function is replaced with an instantly resolving promise with the cached sub object. However, there are some things to note:

  • If there is an error, MD will return only the id, and therefore a normal Relationship object will be returned.
  • Some endpoints will not work at all with includes[] and some support it but do nothing with it. This may change in the future.
  • The only relationship sub-objects will have is the parent object. For example, the following code returns only one title under the authors name even though they have published more than one because the other relationships were never provided by the API:
// Get a manga:
let manga = await MFA.Manga.getByQuery('Ancient Magus Bride', true); // If false, more titles would be returned
let author = await manga.authors[0].resolve(); // Was only given one title (the result above)
let mangas = await author.manga.resolve(); // An actual resolution with API call
console.log(mangas.map(elem => elem.title));
  • Because of the previous point, the usage of this is recommended for situations that call for the basic related information for a manga or other object (a manga's author, artist, cover, etc), but without the requirement for the subsequent object's own relations (the author/artist's other manga for example).
  • By default, includeSubObjects is false because not all relationships are returned and the response payload will be larger with usually unnecessary information.

What's New?

  • All occurances of userName arrays (such as leaderName and memberNames in Groups) have been combined with their corresponding Relationship arrays (leader and members) and turned into actual User objects. This is because every user's relationship array seems to be empty, so there is no reason to have a Relationship so this data can be resolved—the username and id are given by default in requests, but since that is all Users have excluding the empty array, they can just become actual User objects.
  • The Auth protocol has been rewritten to support browsers (Browserify now works), multiple user caching, and JSON cache files. The tokens for each user along with each username are still stored in plaintext, so be careful or don't use caching at all.