Filter content to get what you need
Is this page helpful?
system.id
) against the ID value you have.
equals
filter.
To ensure you get content in a specific language, use the language
parameter in your requests.
in
filter.system.type
) using the equals
filter.in
filter.contains
, any
, or all
filters.range
filter.
To get items based on a number range, you need to specify two numbers. The numbers can be either integers like 3
or floats like 3.14
.
system
properties of the content item object. For example, system.workflow_step
, system.collection
, system.last_modified
.// Gets an item by its internal ID
const response = await deliveryClient.items()
.equalsFilter('system.id', '2f7288a1-cfc8-47be-9bf1-b1d312f7da18')
.toPromise();
// Gets three items by their codenames. The codenames are unique per project.
const response = await deliveryClient.items()
.inFilter('system.codename', ['delivery_api', 'get_content', 'hello_world'])
.toPromise();
// Gets items based on the type Product
const response = await deliveryClient.items()
.equalsFilter('system.type', 'product') // Same as using .type('product')
.toPromise();
// Gets items based on the types Product, Article, and News
const response = await deliveryClient.items()
.inFilter('system.type', ['product', 'article', 'news'])
.toPromise();
// 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+0
const response = await deliveryClient.items()
.greaterThanFilter('system.last_modified', '2020-05-09T09:00:00.000000Z')
.toPromise();
// Gets items released at or after April 9 2020, 7 am UTC+0
const response = await deliveryClient.items()
.greaterThanOrEqualFilter('elements.release_date', '2020-05-09T07:00:00Z')
.toPromise();
// Gets items modified before April 5 2020 UTC+0. Last match would be at 2020-05-04T23:59:59.
const response = await deliveryClient.items()
.lessThanFilter('system.last_modified', '2020-05-05')
.toPromise();
// Gets items released at or before April 5 2020 10:30 am UTC+0
const response = await deliveryClient.items()
.lessThanOrEqualFilter('elements.release_date', '2020-05-05T10:30:00Z')
.toPromise();
// Gets items whose Title element value equals to 'Hello World'
const response = await deliveryClient.items()
.equalsFilter('elements.title', 'Hello World')
.toPromise();
// Note: Filters work with codenames of the tags.
// Gets items tagged with one specific tag
const response = await deliveryClient.items()
.containsFilter('elements.tags', ['kontent_ai'])
.toPromise();
// Gets items tagged with a list of specific tags
const response = await deliveryClient.items()
.allFilter('elements.tags', ['kontent_ai', 'cms'])
.toPromise();
// Gets items tagged with at least one tag from the list
const response = await deliveryClient.items()
.anyFilter('elements.tags', ['headless', 'cms'])
.toPromise();
// Gets items whose URL slug equals to sample-url-slug
const response = await deliveryClient.items()
.equalsFilter('elements.url_slug', 'sample-url-slug')
.toPromise();
// Gets items attributed to Jane.
const response = await deliveryClient.items()
.containsFilter('elements.author', ['jane_doe'])
.toPromise();
// Gets items attributed to at least Jane, John, or both.
const response = await deliveryClient.items()
.anyFilter('elements.author', ['jane_doe', 'john_wick'])
.toPromise();
// Gets pages linking travel insurance as their subpage.
const response = await deliveryClient.items()
.containsFilter('elements.subpages', ['travel_insurance'])
.toPromise();
// Gets pages linking at least travel insurance, car insurance, or both as their subpage.
const response = await deliveryClient.items()
.anyFilter('elements.subpages', ['travel_insurance', 'car_insurance'])
.toPromise();
contains
, any
, and all
filters work only if the element’s value is a stringified array of strings. For example, "[\"DE\",\"US\",\"UK\"]"
.// 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 UTC
const response = await deliveryClient.items()
.rangeFilter('system.last_modified', '2020-05-05T10:30:00', '2020-05-07T07:00:00')
.toPromise();
// Gets items whose rating is at least 6.5 and at most 9
const response = await deliveryClient.items()
.rangeFilter('elements.product_rating', '6.5', '9')
.toPromise();