Releases: md-y/mangadex-full-api
mangadex-full-api version 5.6.0
What's New?
- Updated JSDoc and
index.d.ts
to support generic types with Relationships soresolve
now has the return type of the appropriate object. The old script for compilingindex.d.ts
has also been replaced by dts-bundle-generator. - Added new Manga search parameters
- Added User searches, role array, and group relationships
- Optimized a few Util methods that were used by almost every class.
getMultiple
now returns results in the same order as the ids that the function was provided with, but missing or invalid ids will still cause it to return less results than the amount of ids provided.
mangadex-full-api version 5.5.1
What's New?
- Added a hotfix to account for the new structure for array results from the API (
results
becamedata
). #44
mangadex-full-api version 5.5.0
What's New?
- Migrated relationships to new location (
data.relationships
) - Fixed internal chapters being marked as external chapters
- Updated chapter/manga search typedef with
originalLanguage
andtranslatedLanguage
parameters - Added
verified
andofficial
property to groups getLoggedInUserLists
andgetUserLists
now only requires one request- Fixed
localizedString
forzh-hk
mangadex-full-api version 5.4.0
What's New?
- External chapters are now supported with
Chapter.isExternal
andChapter.externalUrl
. If a chapter is external, it will have no pages andChapter.getReadablePages
will return an error. - Chapter uploads are now supported. Here is an example of how to do so:
(If you have any issues with chapter uploading please submit an issue)
/*
Upload a chapter with node modules:
*/
const MFA = require('mangadex-full-api');
const fs = require('fs');
const path = require('path');
MFA.login('username', 'password123', './bin/.md_cache').then(async () => {
let currentSession = await MFA.Manga.getCurrentUploadSession();
if (currentSession) {
await currentSession.close();
console.log('Closed existing session.');
}
let mangaId = 'f9c33607-9180-4ba6-b85c-e4b5faee7192'; // Official test manga
let session = await MFA.Manga.createUploadSession(mangaId);
console.log('Created new upload session.');
let chapterDir = './chapter'; // Directory to retrieve page images
let files = fs.readdirSync(chapterDir)
await session.uploadPages(files.map(name => {
return {
data: fs.readFileSync(path.join(chapterDir, name)), // Buffer-like data
name: name // The name of this image
};
}));
console.log('Uploaded pages.');
let chapter = await session.commit({
chapter: '0', // Change chapter number
volume: null, // Change volume number
title: 'New Chapter', // Change chapter name
translatedLanguage: 'en'
});
console.log(`Uploaded new chapter at: https://mangadex.org/chapter/${chapter.id}`);
}).catch(console.error);
mangadex-full-api version 5.3.0
What's New?
- Functions that support
includeSubObjects
will always return Relationships, but the resolve function promise for successfully included objects will instantly return. This means that included sub objects cannot be used as normal objects until they are resolved since they are now Relationships. The last release is now updated. - API requests will now automatically be delayed to avoid the rate limit of 5 requests per second. This means that
Promise.all()
can be used for concurrent requests, and functions that allow its use have been updated to do so (mainly search functions for limits above 200). - Limits for all requests are now capped at 10,000 since this is the hard limit set by MD for the offset parameter.
- Added
Manga.getAllReadingStatuses()
- Volume and Chapter identifiers (such as
Chapter.chapter
andManga.volume
) are now all strings as defined by the official API specifications. - Group objects now have the new information that MD provides such as group website links, IRC information, and descriptions.
List.get()
andGroup.get()
now supportincludeSubObjects
List.getLoggedInUserLists()
,List.getUserLists()
, andGroup.getFollowedGroups()
now work as intended- Made user information for Lists (owner) and Groups (leader and members) Relationships since the official API returns them as such now.
mangadex-full-api version 5.2.0
'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 asleaderName
andmemberNames
in Groups) have been combined with their corresponding Relationship arrays (leader
andmembers
) 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.
mangadex-full-api version 5.1.0
What's New?
- Added
getMultiple
andgetAggregate
methods - Made
Manga.lastChapter
a number type - Object parameters in queries can now be normal Javascript objects (ie order now works as intended). See #35
- Fixed a bug with the Chapter test
- Optimized JSDoc/Types for methods that allow either ids or Relationships
mangadex-full-api version 5.0.0
See previous version for the changes brought by the new Mangadex API and this rewrite.
const MFA = require('mangadex-full-api');
MFA.login('username', 'password123', './bin/.md_cache').then(() => {
MFA.Manga.search({
title: 'isekai',
limit: Infinity // API Max is 100 per request, but this function accepts more
}).then(results => {
console.log(`There are ${results.length} manga with 'isekai' in the title:`);
results.forEach((elem, i) => console.log(`[${i + 1}] ${elem.title}`));
}).catch(console.error);
}).catch(console.error);
What's New?
- Improved authorization and added an authorization Mocha test
- Fixed bugs with some endpoints that required authorization
- Added (currently) non-working, but
ok
-returning endpoints
mangadex-full-api version 5.0.0-rc1
The v5 Rewrite
As you may know, Mangadex has been completely rewritten with an official API for their v5. Coincidentally, this repository is now on version 5.0.0 with its own rewrite to account for these changes.
This is a release candidate for the rewrite. View all of the changes in the documentation and a summary of the major changes at the bottom.
npm install mangadex-full-api@next
Here are some examples of the new API in action:
const MFA = require('mangadex-full-api');
MFA.login('username', 'password123', './bin/.md_cache').then(() => {
MFA.Manga.search({
title: 'isekai',
limit: Infinity // API Max is 100 per request, but this function accepts more
}).then(results => {
console.log(`There are ${results.length} manga with 'isekai' in the title:`);
results.forEach((elem, i) => console.log(`[${i + 1}] ${elem.title}`));
}).catch(console.error);
}).catch(console.error);
const MFA = require('mangadex-full-api');
MFA.login('username', 'password123', './bin/.md_cache').then(async () => {
// Get a manga:
let manga = await MFA.Manga.getByQuery('Ancient Magus Bride');
// Get the manga's chapters:
let chapters = await manga.getFeed({ translatedLanguage: ['en'] });
let chapter = chapters[0];
// Get the chapter's pages:
let pages = await chapter.getReadablePages();
// Get who uploaded the chapter:
let uploader = await chapter.uploader.resolve();
// Get the names of the groups who scanlated the chapter:
let groupNames = [];
for (let i of chapter.groups) {
let group = await i.resolve();
groupNames.push(group.name);
}
console.log(`Manga "${manga.title}" has a chapter titled "${chapter.title}" that was uploaded by ${uploader.username} and scanlated by ${groupNames.join('and')}.`);
console.log(`Here is the first page: ${pages[0]}`);
}).catch(console.error);
What's New?
- No more web parsing
- No more enums
- Added Mocha Tests
- Types are now in one file (index.d.ts)
- There are now only 7 main classes (Author, Chapter, Cover, Group, List, Manga, and User) that are exposed by default along with a few functions, mainly
login()
(no more Agent class) - Instead of creating an object and filling it with
fill()
, you simply need to callget()
,getByQuery()
, or any otherget
/search
function. fill()
isn't needed at all anymore, and has been removed. Every object is 100% filled when first created, and any object that isn't is represented as a Relationship. This contains its id and a function calledresolve()
that will return the complete object.- Almost every function is now asynchronous, meaning it is highly recommended that
await
is used as seen in the second example. - The rest of the specific changes can be seen in the new and improved documentation.
mangadex-full-api version 4.4.0
What's new?
- Fixed cross-type references (#32)
- Added
User.list
andMDList.owner