Mangadex-api
This is Mangadex website api wrapper.
WIP on V5 version
Installation
npm i mangadex-api
yarn add mangadex-api
Example
Mangadex.convertLegacyId([12], 'group')
.then((result) => {
if (result.result === 'error') {
console.log(
`Got error on convertLegacyId request! ${result.errors
.map((err) => err.title)
.join(', ')}`
)
return
}
const { newId } = result.data.attributes
console.log(`New group id: ${newId}`)
})
Mangadex.manga
.getManga(
'c26269c7-0f5d-4966-8cd5-b79acb86fb7a',
{
withRelationShips: true
}
)
.then(({ result, data, errors }) => {
if (result === 'error') {
}
const { title, originalLanguage } = data.attributes
console.log(`Manga ${title.en} published in ${originalLanguage}`)
Mangadex.manga
.getMangaFeed('c26269c7-0f5d-4966-8cd5-b79acb86fb7a', {
limit: 10
})
.then(({ results: chapters }) => {
console.log(`Manga ${title.en} has ${chapters.length} chapters`)
const { volume, chapter } = chapters[0].data.attributes
console.log(`Latest chapter: Vol ${volume} Ch ${chapter}`)
})
})
Mangadex.chapter.getChapter(8857).then((chapter) => {
if (chapter.result === 'error') {
console.log(
`Got errors on chapter request! ${chapter.errors
.map((err) => err.title)
.join(', ')}`
)
return
}
console.log(
`Chapter title is "${chapter.data.attributes.title}" and it is ${chapter.data.attributes.chapter} chapter from ${chapter.volume} volume.`
)
})
Mangadex.manga.search({ title: 'senko' }).then(({ total }) => {
console.log(`Found ${total} titles.`)
})
Mangadex.manga
.search({
title: 'gotoubun',
contentRating: ['pornographic']
})
.then((result) => {
console.log(`Found ${result.results.length} hentai manga (☞ ͡ ͡° ͜ ʖ ͡ ͡°)☞`)
})
Mangadex.group.getGroup(12).then((group) => {
if (group.result === 'error') {
console.log(
`Got errors from group request! ${group.errors
.map((err) => err.title)
.join(', ')}`
)
return
}
const { name, members } = group.data.attributes
console.log(`Group ${name} has ${members} members`)
})
Authorization example
const { Mangadex } = require('mangadex-api')
const client = new Mangadex()
const loginResult = await client.auth.login('username', 'password')
if (loginResult.result === 'error') {
}
const result = await client.manga.search('To Be Winner')
console.log(result)
Cached session example
const loginResult = await client.auth.login('username', 'password')
if (loginResult.result === 'error') {
}
await client.agent.saveSession('/path/to/session'))
await client.agent.loginWithSession('/path/to/session')
const me = await client.user.getMe()
console.log(me)
API
API section is available on the website.
Additional resources
- mangadex-heroku is a GraphQL public endpoint. (not updated to V5 yet)
Supports caching (in memory) and all public MD-API's that doesn't require authorization. (playground) - Example webapp that uses mangadex-heroku for API calls. (not updated to V5 yet)
Contact
My telegram and a group where you can ask your questions or suggest something.