# Searching for a manga

  GET /manga

# Search via a query

One of the first steps made to navigate Mangadex's manga, manhwa, manhua, and/or user-submitted comics is to search for them through a query. The query we often want is the Manga's title. Thus, we pass a title query parameter to the URL, with the title we want to search for.

# Request

Quering for the manga Kanojyo to Himitsu to Koimoyou.

title = "Kanojyo to Himitsu to Koimoyou"
import requests

base_url = "https://api.mangadex.org"

r = requests.get(
    f"{base_url}/manga",
    params={"title": title}
)

print([manga["id"] for manga in r.json()["data"]])
const title = 'Kanojyo to Himitsu to Koimoyou';
const axios = require('axios');

const baseUrl = 'https://api.mangadex.org';

const resp = await axios({
    method: 'GET',
    url: `${baseUrl}/manga`,
    params: {
        title: title
    }
});

console.log(resp.data.data.map(manga => manga.id));

# Advanced Manga search

Sometimes we may not be looking for a specific title, but many titles that are similar in some way. Sometimes we may be looking for action-romance stories, sometimes we're looking for that one amazing manga we forgot the title of, but remember ever so few characteristics about it. Our API provides a wide range of collection-filtering options, such as filtering by including or excluding tags, demographic, and more.

# Filtering by Tags

To filter a Manga collection by one or more Tags, we have to first understand how the Tag system works. We will use the includedTags[] and excludedTags[] query parameters to filter our list. Refer to the API reference for further details on the Tag system.

# Request

Let's look for a Manga with tags "Action" and "Romance," but not "Harem."

We declare our tag names in a list.

included_tag_names = ["Action", "Romance"]
excluded_tag_names = ["Harem"]

We then transform those lists into lists of UUIDs using the /manga/tags resource.

import requests

base_url = "https://api.mangadex.org"

tags = requests.get(
    f"{base_url}/manga/tag"
).json()

# ["391b0423-d847-456f-aff0-8b0cfc03066b", "423e2eae-a7a2-4a8b-ac03-a8351462d71d"]
included_tag_ids = [
    tag["id"]
    for tag in tags["data"]
    if tag["attributes"]["name"]["en"]
       in included_tag_names
]

# ["aafb99c1-7f60-43fa-b75f-fc9502ce29c7"]
excluded_tag_ids = [
    tag["id"]
    for tag in tags["data"]
    if tag["attributes"]["name"]["en"]
       in excluded_tag_names
]

Finally, we send the request.

r = requests.get(
    f"{base_url}/manga",
    params={
        "includedTags[]": included_tag_ids,
        "excludedTags[]": excluded_tag_ids,
    },
)

print([manga["id"] for manga in r.json()["data"]])

We declare our tag names in an array.

const includedTagNames = ['Action', 'Romance'];
const excludedTagNames = ['Harem'];

We then transform those arrays into arrays of UUIDs using the /manga/tags resource.

const axios = require('axios');

const baseUrl = 'https://api.mangadex.org';

const tags = await axios(`${baseUrl}/manga/tag`);

// ['391b0423-d847-456f-aff0-8b0cfc03066b', '423e2eae-a7a2-4a8b-ac03-a8351462d71d']
const includedTagIDs = tags.data.data
    .filter(tag => includedTagNames.includes(tag.attributes.name.en))
    .map(tag => tag.id);

// ['aafb99c1-7f60-43fa-b75f-fc9502ce29c7']
const excludedTagIDs = tags.data.data
    .filter(tag => excludedTagNames.includes(tag.attributes.name.en))
    .map(tag => tag.id);

Finally, we send the request.

const resp = await axios({
    method: 'GET',
    url: `${baseUrl}/manga`,
    params: {
        'includedTags': includedTagIDs,
        'excludedTags': excludedTagIDs
    }
});

console.log(resp.data.data.map(manga => manga.id));

# Sorting

You can apply sorting via the order field, see Manga order options.

# Request

We declare the order dictionary.

order = {
    "rating": "desc",
    "followedCount": "desc",
}

We transform the dictionary into a dictionary we can use for deep object query parameters.

final_order_query = {}

# { "order[rating]": "desc", "order[followedCount]": "desc" }
for key, value in order.items():
    final_order_query[f"order[{key}]"] = value

We send the request.

import requests

base_url = "https://api.mangadex.org"

r = requests.get(
    f"{base_url}/manga",
    params={
        **{
            "includedTags[]": included_tag_ids,
            "excludedTags[]": excluded_tag_ids,
        },
        **final_order_query,
    },
)

print([manga["id"] for manga in r.json()["data"]])

We declare the order object.

const order = {
    rating: 'desc',
    followedCount: 'desc'
};

We transform the object into an object we can use for deep object query parameters.

const finalOrderQuery = {};

// { "order[rating]": "desc", "order[followedCount]": "desc" }
for (const [key, value] of Object.entries(order)) {
    finalOrderQuery[`order[${key}]`] = value;
}
;

We send the request.

const axios = require('axios');

const baseUrl = 'https://api.mangadex.org'

const resp = await axios({
    method: 'GET',
    url: `${baseUrl}/manga`,
    params: {
        includedTags: includedTagIDs,
        excludedTags: excludedTagIDs,
        ...finalOrderQuery
    }
});

console.log(resp.data.data.map(manga => manga.id));

# Filtering by Demographic or Content Rating

You can filter the collection by specifying which demographics to include, what content rating to contain, its publication status and more. For the full list of what query parameters are available, refer to the API Reference.

# Request

Let's say we want to get all Seinen Manga with publication status completed, and suggestive content rating. We'll be using the publicationDemographic[], status[], and contentRating[] query parameters.

filters = {
    "publicationDemographic[]": ["seinen"],
    "status[]": ["completed"],
    "contentRating[]": ["suggestive"],
}
import requests

base_url = "https://api.mangadex.org"

r = requests.get(
    f"{base_url}/manga", params=filters
)

print([manga["id"] for manga in r.json()["data"]])
const filters = {
    publicationDemographic: ['seinen'],
    status: ['completed'],
    contentRating: ['suggestive']
};
const axios = require('axios');

const baseUrl = 'https://api.mangadex.org';

const resp = await axios({
    method: 'GET',
    url: `${baseUrl}/manga`,
    params: filters
});

console.log(resp.data.data.map(manga => manga.id));