Skip to main content
The AnimeThemes API provides powerful filtering, sorting, and field selection capabilities to help you retrieve exactly the data you need.

Filtering

Filters allow you to narrow down results based on field values.

Basic Filtering

Use the filter parameter to filter resources by field values:
curl "https://api.animethemes.moe/api/anime?filter[year]=2020"
This returns all anime from the year 2020.

Multiple Filters

You can apply multiple filters simultaneously:
curl "https://api.animethemes.moe/api/anime?filter[year]=2020&filter[season]=Spring"
This returns anime from Spring 2020.

Filter Operators

The API supports several filter patterns:

Exact Match (Where)

filter[field]=value
Example:
curl "https://api.animethemes.moe/api/anime?filter[slug]=cowboy_bebop"

Multiple Values (WhereIn)

Separate multiple values with commas:
filter[field]=value1,value2,value3
Example:
curl "https://api.animethemes.moe/api/anime?filter[year]=2019,2020,2021"
This returns anime from 2019, 2020, or 2021.

Relationship Existence (Has)

Check if a relationship exists:
filter[has]=relationship
Example:
curl "https://api.animethemes.moe/api/anime?filter[has]=animethemes"
This returns only anime that have at least one theme.

Soft Deleted Records (Trashed)

Include or filter trashed (soft-deleted) records:
filter[trashed]=with      # Include trashed records
filter[trashed]=only      # Only trashed records
filter[trashed]=without   # Exclude trashed records (default)
Example:
curl "https://api.animethemes.moe/api/anime?filter[trashed]=with"

Scoped Filters

Apply filters to included relationships:
filter[relationship][field]=value
Example:
curl "https://api.animethemes.moe/api/anime?include=animethemes&filter[animethemes][type]=OP"
This includes only opening themes in the animethemes relationship.

Sorting

Sort results by one or more fields using the sort parameter.

Ascending Sort

sort=field
Example:
curl "https://api.animethemes.moe/api/anime?sort=name"
Sorts anime by name in ascending order (A-Z).

Descending Sort

Prefix the field name with - for descending order:
sort=-field
Example:
curl "https://api.animethemes.moe/api/anime?sort=-year"
Sorts anime by year in descending order (newest first).

Multiple Sort Fields

Separate multiple sort fields with commas:
sort=field1,-field2
Example:
curl "https://api.animethemes.moe/api/anime?sort=-year,name"
Sorts by year descending, then by name ascending.

Random Sort

Get results in random order:
curl "https://api.animethemes.moe/api/anime?sort=random"

Relationship Sorting

Sort by related model fields using dot notation:
sort=relationship.field
Example:
curl "https://api.animethemes.moe/api/animetheme?sort=anime.year"

Field Selection (Sparse Fieldsets)

Request only specific fields to reduce response size and improve performance.

Basic Field Selection

Use the fields parameter to specify which fields to include:
fields[resource]=field1,field2,field3
Example:
curl "https://api.animethemes.moe/api/anime?fields[anime]=id,name,year"
Response:
{
  "anime": [
    {
      "id": 1,
      "name": "Cowboy Bebop",
      "year": 1998
    }
  ]
}

Field Selection for Multiple Resources

When including relationships, you can specify fields for each resource type:
curl "https://api.animethemes.moe/api/anime?include=animethemes&fields[anime]=id,name&fields[animetheme]=id,type,sequence"
Use the include parameter to load related resources.

Basic Include

include=relationship
Example:
curl "https://api.animethemes.moe/api/anime?include=animethemes"

Multiple Includes

Separate multiple relationships with commas:
include=relationship1,relationship2
Example:
curl "https://api.animethemes.moe/api/anime?include=animethemes,images,studios"

Nested Includes

Use dot notation to include nested relationships:
include=relationship.nested
Example:
curl "https://api.animethemes.moe/api/anime?include=animethemes.animethemeentries.videos"
This includes:
  • Anime themes
  • Theme entries within each theme
  • Videos within each entry

Scoped Includes

Load different relationships for different resource types:
include[resource]=relationship1,relationship2
Example:
curl "https://api.animethemes.moe/api/anime?include[anime]=animethemes&include[animetheme]=song"
Perform full-text search across resources:
filter[search]=query
Example:
curl "https://api.animethemes.moe/api/anime?filter[search]=cowboy"
The search implementation uses either Elasticsearch or a collection-based driver depending on the server configuration.

Combining Parameters

All query parameters can be combined for powerful queries:
curl "https://api.animethemes.moe/api/anime?filter[year]=2020&filter[season]=Spring&sort=-name&include=animethemes,images&fields[anime]=id,name,slug&page[size]=25"
This request:
  • Filters anime from Spring 2020
  • Sorts by name descending
  • Includes themes and images
  • Selects only id, name, and slug fields
  • Returns 25 results per page

Best Practices

Use Field Selection

When you don’t need all fields, use sparse fieldsets to improve performance:
# Instead of:
curl "https://api.animethemes.moe/api/anime"

# Use:
curl "https://api.animethemes.moe/api/anime?fields[anime]=id,name,slug"

Filter Before Including

Apply filters to the main resource before including relationships:
curl "https://api.animethemes.moe/api/anime?filter[year]=2020&include=animethemes"

Limit Nested Includes

Avoid including too many nested relationships in a single request, as this can impact performance.

Use Appropriate Page Sizes

Combine filtering with pagination:
curl "https://api.animethemes.moe/api/anime?filter[year]=2020&page[size]=50"

Examples

Get Anime from 2020 with Themes

curl "https://api.animethemes.moe/api/anime?filter[year]=2020&include=animethemes&sort=name"

Find Specific Song

curl "https://api.animethemes.moe/api/song?filter[title]=Tank!&include=artists"

Get Opening Themes Only

curl "https://api.animethemes.moe/api/animetheme?filter[type]=OP&include=anime,song"

Search for Artist

curl "https://api.animethemes.moe/api/artist?filter[search]=yoko%20kanno&include=songs"

Get Recent Videos

curl "https://api.animethemes.moe/api/video?sort=-created_at&page[limit]=20&fields[video]=id,filename,link"

Build docs developers (and LLMs) love