Filtering
Filters allow you to narrow down results based on field values.Basic Filtering
Use thefilter parameter to filter resources by field values:
Multiple Filters
You can apply multiple filters simultaneously:Filter Operators
The API supports several filter patterns:Exact Match (Where)
Multiple Values (WhereIn)
Separate multiple values with commas:Relationship Existence (Has)
Check if a relationship exists:Soft Deleted Records (Trashed)
Include or filter trashed (soft-deleted) records:Scoped Filters
Apply filters to included relationships:Sorting
Sort results by one or more fields using thesort parameter.
Ascending Sort
Descending Sort
Prefix the field name with- for descending order:
Multiple Sort Fields
Separate multiple sort fields with commas:Random Sort
Get results in random order:Relationship Sorting
Sort by related model fields using dot notation:Field Selection (Sparse Fieldsets)
Request only specific fields to reduce response size and improve performance.Basic Field Selection
Use thefields parameter to specify which fields to include:
Field Selection for Multiple Resources
When including relationships, you can specify fields for each resource type:Including Related Resources
Use theinclude parameter to load related resources.
Basic Include
Multiple Includes
Separate multiple relationships with commas:Nested Includes
Use dot notation to include nested relationships:- Anime themes
- Theme entries within each theme
- Videos within each entry
Scoped Includes
Load different relationships for different resource types:Search
Perform full-text search across resources:Combining Parameters
All query parameters can be combined for powerful queries:- 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:Filter Before Including
Apply filters to the main resource before including relationships: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:Examples
Get Anime from 2020 with Themes
Find Specific Song
Get Opening Themes Only
Search for Artist
Get Recent Videos
Related Topics
- Pagination - Paginate filtered results
- Rate Limits - Understand request limits