6.0.0 • Published 4 months ago

mangadex-full-api v6.0.0

Weekly downloads
219
License
MIT
Repository
github
Last release
4 months ago

MangaDex Full API

An unofficial MangaDex API built with the official JSON API. Supports Node.js and browsers.

Documentation

Version License Downloads

npm install mangadex-full-api@6.0.0-beta.0
// Demo
Manga.search({
    title: 'One Piece',
    limit: Infinity, // API Max is 100 per request, but this function accepts more
    hasAvailableChapters: true,
}).then((mangas) => {
    console.log('There are', mangas.length, 'mangas with One Piece in the title!');
    mangas.forEach((manga) => {
        console.log(manga.localTitle);
    });
});

Tutorials

View more info on the documentation website.

Authentication

To login with a personal account, you must have a Client ID and Secret.

await loginPersonal({
    clientId: 'id',
    clientSecret: 'secret',
    password: 'password',
    username: 'username',
});

Page Images

// Get a manga with chapters
const manga = await Manga.getByQuery({ order: { followedCount: 'desc' }, availableTranslatedLanguage: ['en'] });
if (!manga) throw new Error('No manga found!');

// This will get the first English chapter for this manga
const chapters = await manga.getFeed({ translatedLanguage: ['en'], limit: 1 });
const chapter = chapters[0];

// Get the image URLs for this chapter
const pages = await chapter.getReadablePages();
console.log(pages);

Relationships

MangaDex will return Relationship objects for associated data objects instead of the entirety of each object.

For example, authors and artists will be returned as Relationship<Author> when requesting a manga. To request the author data, use the resolve method.

Additionally, you can supply 'author' to the includes parameter to include the author data alongside the manga request. You will still need to call the resolve method, but the promise will return instantly.

const manga = await Manga.getRandom();
const firstAuthor = await manga.authors[0].resolve();
console.log('The first author is', firstAuthor.name);

// Use resolveArray to resolve an array of Relationships more efficiently
const allAuthors = await resolveArray(manga.authors);
console.log('All authors are', allAuthors.map((a) => a.name).join(', '));

// Because authors are included, the author relationships are cached
const otherManga = await Manga.getByQuery({ includes: ['author'] });
if (otherManga) {
    console.log('The authors for this manga are included and cached:', otherManga.authors[0].cached);
    const author = await otherManga.authors[0].resolve();
    console.log('The author is', author.name);
}

Finding Manga

The most common way to find manga is to use the search method. However, there are a few other ways as well:

// Basic Search
Manga.search({
    title: 'One Piece',
    limit: Infinity, // API Max is 100 per request, but this function accepts more
    hasAvailableChapters: true,
}).then((mangas) => {
    console.log('There are', mangas.length, 'mangas with One Piece in the title!');
    mangas.forEach((manga) => {
        console.log(manga.localTitle);
    });
});

// This will return the first result from a search
Manga.getByQuery({ title: 'One Piece' }).then((manga) => {
    if (manga) console.log('Found a One Piece manga with id', manga.id);
    else console.log('No One Piece manga found');
});

// You can get a random manga
Manga.getRandom().then((manga) => console.log('Random:', manga.localTitle));

// You can get manga directly by UUID
Manga.get('manga-uuid-here').then((manga) => console.log(manga));

Uploading Chapters

// Login with your credentials
await loginPersonal({
    clientId: 'id',
    clientSecret: 'secret',
    password: 'password',
    username: 'username',
});

// Create a new chapter upload session for a manga
const session = await UploadSession.begin('manga-id', ['group-id']);

// Upload pages as Blobs
await session.uploadPages([
    new Blob([fs.readFileSync('path/to/page1.jpg')], new Blob([fs.readFileSync('path/to/page2.jpg')])),
]);

// Commit the chapter
await session.commit({
    chapter: '1',
    title: 'A new chapter!',
    translatedLanguage: 'en',
    volume: '1',
});
6.0.0

4 months ago

6.0.0-beta.0

10 months ago

5.12.1

2 years ago

5.11.1

3 years ago

5.11.0

3 years ago

5.8.0

3 years ago

5.10.0

3 years ago

5.9.0

3 years ago

5.7.0

3 years ago

5.6.1

3 years ago

5.6.0

3 years ago

5.5.1

3 years ago

5.5.0

3 years ago

5.4.0

3 years ago

5.3.0

3 years ago

5.2.0

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

5.0.0-rc1

3 years ago

4.4.0

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

3.10.0

4 years ago

3.9.0

4 years ago

3.8.0

4 years ago

3.7.0

4 years ago

3.6.2

4 years ago

3.6.1

5 years ago

3.6.0

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

1.0.2

6 years ago