Media
The Media
family of queries will most likely be your most used ones. In turn, they are also some of the most flexible and powerful queries we have.
Media
encompasses both anime and manga entries, so if you are looking for a specific type of media, you will need to use the type
argument. IDs are not unique across either type of media. If ID 1
is an anime entry, there will never be a manga entry with the same ID.
::: tip The ID of an anime or manga entry can be found in the URL of the AniList page. For example, in the URL https://anilist.co/anime/1/Cowboy-Bebop
, the ID is 1
. :::
::: warning If you are filtering by type
(ANIME
for example) and request an ID that is actually used for the other type (MANGA
in this case), you will receive a 404
response code. :::
Get media by ID
This is one of the most barebones queries you can make. It will directly return the media with the specified ID. If the ID does not match up with a media, you will receive a 404
response code.
Search anime by title
This query will search for anime entries based on a search query. In this case, the search
argument is a String!
type, which means it is required and the query will fail if it is not provided.
Notice how it is now wrapped in a Page
object. This allows it to return multiple results, and also allows you to paginate through the results. For more information on pagination, check out the pagination guide.
We've also hardcoded the type
argument to ANIME
to only return anime entries. This could be a variable as well, but this shows how you can mix and match as needed.
::: info "Getting an anime by name" is not something you can do. Titles are not unique, so there is no 1:1 relationship between a title and a media entry. The best you can do is search for the title and hope the first result is the correct one. :::
Get the relations of a media
In many cases, you might want to know all the related media of an entry: prequels, sequels, side stories, and more. We can do this with the relations
field.
Since relations
is a connection, we will need to use the edges
field to know how the related media are connected. You can read more about how connections work here.
Get all light novels from 2020
It's time to get a bit more advanced with our queries. In this example, we will be getting all the light novels that started publishing in 2020.
Light novels are found under the MANGA
type with the NOVEL
format. We can use the format
argument to filter by the format of the media.
To get a range of dates, we will use the startDate_greater
and startDate_lesser
arguments. These arguments are of the FuzzyDateInt
type, which means they are integers that represent a date.
Also notice how instead of making the page
argument required, we are setting it to 1
by default.
::: info FuzzyDateInt
is in the format of YYYYMMDD
. :::
Advanced browse page
This is a trimmed down version of the query made by AniList's browse page to show just how powerful the API can be.
Last updated