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.
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 in system.id) against the ID value you have.
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
.
To get items based on the value of a text or rich text
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 the equals filter.
element, you need to specify the value using the equals filter.
Filter by where items are used – You can have a linked items element for navigation. Each linked item represents a navigation item in a hierarchy.
Filter by article's author – You can have several articles written by a single author, Jane. Each article has a linked items element named Author, containing a reference to the content item that represents the author Jane.
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!
If you have multiple identifiers of a single type (for example, only IDs or codenames) and want to retrieve them in a single request, use the in filter.
To get items based on a single content type, specify the content type's codename (system.type) using the equals filter.
To get items based on multiple content types, specify the content types' codenames using the in filter.
To get items tagged with specific taxonomy terms, you need to specify the terms using the contains, any, or all filters.
C#
// Gets an item by its internal IDIDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new EqualsFilter("system.id", "2f7288a1-cfc8-47be-9bf1-b1d312f7da18"));
C#
// Gets three items by their codenames. The codenames are unique per project.IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new InFilter("system.codename", "delivery_api", "get_content", "hello_world"));
C#
// Gets items based on the type ProductIDeliveryItemListingResponse<Product> response = await deliveryClient.GetItemsAsync<Product>( new EqualsFilter("system.type", "product"));
C#
// Gets items based on the types Product, Article, and NewsIDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new InFilter("system.type", "product", "article", "news"));
C#
// Note: Date & time element values are provided by users and stored with minute precision. The system.last_modified value reflects Last content change to an item and is stored with ms precision.// Gets items modified after April 9 2020, 9 am UTC+0IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new GreaterThanFilter("system.last_modified", "2020-05-09T09:00:00.000000Z"));// Gets items released at or after April 9 2020, 7 am UTC+0IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new GreaterThanOrEqualFilter("elements.release_date", "2020-05-09T07:00:00Z"));// Gets items modified before April 5 2020 UTC+0. Last match would be at 2020-05-04T23:59:59.IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new LessThanFilter("system.last_modified", "2020-05-05"));// Gets items released at or before April 5 2020 10:30 am UTC+0IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new LessThanOrEqualFilter("elements.release_date", "2020-05-05T10:30:00Z"));
C#
// Gets items whose Title element value equals to "Hello World" IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new EqualsFilter("elements.title", "Hello World"));
C#
// Note: Filters work with codenames of the tags.// Gets items tagged with one specific tagIDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new ContainsFilter("elements.tags", "kontent_ai"));// Gets items tagged with a list of specific tagsIDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new AllFilter("elements.tags", "kontent_ai", "cms"));// Gets items tagged with at least one tag from the listIDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new AnyFilter("elements.tags", "headless", "cms"));
C#
// Gets items in default language with the URL slug element equal to 'sample-url-slug'IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new EqualsFilter("elements.url_slug", "sample-url-slug"));
Tip: This approach works equally well for other system properties of the content item object. For example, system.workflow_step, system.collection, system.last_modified.
Filter content to get what you need | Kontent.ai Learn
// Note: Date & time element values are provided by users and stored with minute precision. The system.last_modified value reflects Last content change to an item and is stored with ms precision.// Gets items modified between April 5, 2020 10:30 UTC and April 7, 2020, 7:00 UTCIDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new RangeFilter("system.last_modified", "2020-05-05T10:30:00", "2020-05-07T07:00:00"));
C#
// Gets items whose rating is at least 6.5 and at most 9IDeliveryItemListingResponse<object> response = await deliveryClient.GetItemsAsync<object>( new RangeFilter("elements.product_rating", "6.5", "9"));
Also works for the multiple choice and custom elementsUse the same approach to get items based on a specific value or values of the multiple choice elements.For custom elements, the contains
,
any
, and
all
filters work only if the element’s value is a stringified array of strings. For example,