npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mangadex-full-api

v6.0.0

Published

A MangaDex api based around the official API.

Downloads

1,594

Readme

MangaDex Full API

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

Documentation

Version License Downloads

npm install [email protected]
// 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',
});