Getting content from your project is one of the core responsibilities of your app.Discover how to use basic filtering to retrieve some of your project’s published content items, such as articles.
While your content creators write articles and add finishing touches to the content in your project, you can display that content in web and mobile apps using Delivery API.Delivery API is a read-only API that’s available as both REST API and GraphQL API. Here you’ll learn the basics of using the Delivery REST API for getting published content.To retrieve content items from a project, you need to specify the project’s environment
Let’s see how to get all content items from the specified environment.
Recently published content items may appear in the API after a slight delay.
You know how to retrieve all items. Let’s expand by retrieving items based on a specific type. In this example, you’ll retrieve items based on the Article content type.
Before moving further, you need to find the codename of the content type.
You can copy codenames by clicking near the name of a content type, content element, or other objects in your project.
For example, to find the codename of the Article content type, go to Content model > Content types > Article > .
Once you have the codename, use it to filter the requested content items by their type.
The information about a content item’s type is stored in the content item’s System object property. The System object contains metadata about the content item, such as the last content modification date, language, content type, and more.
To retrieve content items by type, you need to filter them by the value of their type property. Any content items not based on the Article content type will be omitted from the API response.
By default, the Delivery API sorts content items alphabetically by their codenames. With content like articles, you might want to use chronological order. For example, have the articles ordered by their last modified date.To retrieve content items in a specific order, specify the following:
The content item property to order by. For example, the property can be a content element
(such as text or date & time element) or content item metadata (such as the item’s type or last modified date).
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!
This is how you edit a content type codename. Similarly, you can change the codenames of content items and elements.
Java
// Tip: Find more about Java SDK at https://kontent.ai/learn/javaimport kontent.ai.delivery.*;// Initializes a DeliveryClientDeliveryClient client = new DeliveryClient("KONTENT_AI_ENVIRONMENT_ID");// Gets all content itemsCompletionStage<ContentItemsListingResponse> listingResponse = client.getItems();
// Tip: Find more about Java SDK at https://kontent.ai/learn/javaimport kontent.ai.delivery.*;// Initializes a DeliveryClientDeliveryClient client = new DeliveryClient("KONTENT_AI_ENVIRONMENT_ID");// Tip: Create strongly typed models according to https://kontent.ai/learn/net-strong-types// Registers the model class for articlesclient.registerType(Article.class);// Gets all articlesCompletionStage<List<Article>> items = client.getItems( Article.class, DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .build(););
Get content from your project | Kontent.ai Learn
Paging the resultsIf you don’t need all content items at once, you can play with the paging by specifying the limit and skip parameters.For example, setting the limit to 3 and skip to 6 gives you the third page of results.
Quick facts about codenamesCodenames are alphanumeric identifiers of objects in Kontent.ai. Codenames are initially generated from the object’s name, such as the content item name.