Filter content to get what you need
The Delivery API provides several filters to help you refine your requests based on your requirements. To choose the right one, think about what you know about the content you want to get. There’s a filter for every use case.Find a scenario relevant to you and adjust the code samples to get the content you need.
Filter by item ID or a codename
To get an item based on its identifier (like ID or codename), use the equals filter. For example, if you need to get an item by its internal ID, you match the item's ID (found insystem.id
) against the ID value you have.
If you have multiple codenames of a single type and want to retrieve the items in a single request, use GraphQL aliases.
Filter by content types
To get items based on a single content type, use the root collection query for a specific type, for example,
product_All
.To get items based on multiple content types, specify multiple root collection queries.
Filter by date & time and numbers
To get items by a datetime value, you can use one of the comparison filters. This lets you retrieve content modified or released before or after a certain date. The following code shows the filters used on the last content modification date and a date & time element.Filter by a range of dates and numbers
The Delivery GraphQL API doesn't support filtering content items based on a range of values. See the list of supported filters.
Filter by text and rich text
To get items based on the value of a text or rich text element, you need to specify the value using the equals filter.Filter by taxonomy and multiple choice
To get items tagged with specific taxonomy terms, you need to specify the terms using either the
containsAny
or containsAll
filters.Filter by URL slug
The URL slug element value is stored in the same way as the values of text elements. This means the approach to getting items by a specific URL slug is the same, using theequals
filter.
language
parameter in your requests.
Filter by parent items
Sign in with your Kontent.ai credentials or sign up for free to unlock the full lesson, track your progress, and access exclusive expert insights and tips!