Getting content

While your copywriters write articles and add finishing touches to the content in your project, you can deliver that content to web and mobile applications via an API. In this tutorial, you'll learn how to retrieve your content from Kentico Kontent using the Delivery API.

Table of contents

    The Delivery API is a read-only REST API that can serve your content in two modes: public and preview. In public mode, you can only retrieve content that is published and publicly available. In preview mode, you can retrieve published as well as any unpublished content. This tutorial covers using the Delivery API in public mode, in which you don't need to authenticate your requests.

    Let's dive in and see what you need to retrieve a list of specific content items, such as articles.

    Getting content items

    In order to retrieve content items from a project, you will need the project ID. Your project is the primary organizational unit in Kentico Kontent. Every project is uniquely identified by an ID you can use to tell the Delivery API where to look for content. For example, a project ID might look like this: 975bf280-fd91-488c-994c-2f04416e5ee3.

    To get the ID of your project:

    1. In Kentico Kontent, choose a project.
    2. From the app menu, choose Project settings .
    3. Under Development, choose API keys.
    4. In the Project ID box, click Copy to clipboard.

    With the project ID, you can now make queries to the Delivery API using a URL such as https://deliver.kontent.ai/<YOUR_PROJECT_ID>/items.

    • Java
    import com.kenticocloud.delivery_core.*; import com.kenticocloud.delivery_rx.*; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function; // Prepares the DeliveryService configuration object String projectId = "975bf280-fd91-488c-994c-2f04416e5ee3"; IDeliveryConfig config = DeliveryConfig.newConfig(projectId); // Initializes a DeliveryService for Java projects IDeliveryService deliveryService = new DeliveryService(config); // Gets all content items using a simple request List<ContentItem> items = deliveryService.<ContentItem>items() .get() .getItems(); // Gets all content items using RxJava2 deliveryService.<ContentItem>items() .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<ContentItem>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<ContentItem> response) { // Gets the content items List<ContentItem> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    import com.kenticocloud.delivery_core.*; import com.kenticocloud.delivery_rx.*; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function; // Prepares the DeliveryService configuration object String projectId = "975bf280-fd91-488c-994c-2f04416e5ee3"; IDeliveryConfig config = DeliveryConfig.newConfig(projectId); // Initializes a DeliveryService for Java projects IDeliveryService deliveryService = new DeliveryService(config); // Gets all content items using a simple request List<ContentItem> items = deliveryService.<ContentItem>items() .get() .getItems(); // Gets all content items using RxJava2 deliveryService.<ContentItem>items() .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<ContentItem>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<ContentItem> response) { // Gets the content items List<ContentItem> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") // Note: Using "items" as custom query returns all content items, // but to map them to a single model, a filter is needed. let customQuery = "items?system.type=article" // More about strongly-typed models https://github.com/Kentico/cloud-sdk-swift#using-strongly-typed-models client.getItems(modelType: Article.self, customQuery: customQuery) { (isSuccess, itemsResponse, error) in if isSuccess { if let articles = itemsResponse?.items { // Use your items here } } else { if let error = error { print(error) } } }
    import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") // Note: Using "items" as custom query returns all content items, // but to map them to a single model, a filter is needed. let customQuery = "items?system.type=article" // More about strongly-typed models https://github.com/Kentico/cloud-sdk-swift#using-strongly-typed-models client.getItems(modelType: Article.self, customQuery: customQuery) { (isSuccess, itemsResponse, error) in if isSuccess { if let articles = itemsResponse?.items { // Use your items here } } else { if let error = error { print(error) } } }
    • Java
    import com.kenticocloud.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .build(); ContentItemsListingResponse listingResponse = client.getItems();
    import com.kenticocloud.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .build(); ContentItemsListingResponse listingResponse = client.getItems();
    • JavaScript
    const KontentDelivery = require("@kentico/kontent-delivery"); const deliveryClient = new KontentDelivery.DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3" }); deliveryClient.items() .toObservable() .subscribe(response => console.log(response));
    const KontentDelivery = require("@kentico/kontent-delivery"); const deliveryClient = new KontentDelivery.DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3" }); deliveryClient.items() .toObservable() .subscribe(response => console.log(response));
    • C#
    using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets all content items // Note: Using the <object> generic parameter produces strongly typed objects, based on "system.type" DeliveryItemListingResponse<object> response = await client.GetItemsAsync<object>(); var items = response.Items;
    using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets all content items // Note: Using the <object> generic parameter produces strongly typed objects, based on "system.type" DeliveryItemListingResponse<object> response = await client.GetItemsAsync<object>(); var items = response.Items;
    • PHP
    <?php // Defined by Composer to include required libraries require __DIR__ . "/vendor/autoload.php"; use Kentico\Kontent\Delivery\DeliveryClient; $client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); $items = $client->getItems();
    <?php // Defined by Composer to include required libraries require __DIR__ . "/vendor/autoload.php"; use Kentico\Kontent\Delivery\DeliveryClient; $client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); $items = $client->getItems();
    • cURL
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items" --header "content-type: application/json"
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items" --header "content-type: application/json"
    • Ruby
    require "delivery-sdk-ruby" delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: "975bf280-fd91-488c-994c-2f04416e5ee3" delivery_client.items.execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    require "delivery-sdk-ruby" delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: "975bf280-fd91-488c-994c-2f04416e5ee3" delivery_client.items.execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    • TypeScript
    import { ContentItem, DeliveryClient } from "@kentico/kontent-delivery"; const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3" }); deliveryClient.items<ContentItem>() .toObservable() .subscribe(response => console.log(response));
    import { ContentItem, DeliveryClient } from "@kentico/kontent-delivery"; const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3" }); deliveryClient.items<ContentItem>() .toObservable() .subscribe(response => console.log(response));

    Calling the /items endpoint gives you all content items from the specified project in the form of a paged listing response, returned as JSON. Note that recently published items may appear in the Delivery API after a slight delay.

    Paging the results

    If you don't need all content items at once, you can tinker with the paging by specifying the limit and skip query parameters.

    For example, calling the /items endpoint with the limit=3&skip=6 query parameters sets the page size to 3 and gives you the third page.

    Filtering content items

    Now that you can get all content items from your project, you need to filter them to get only a specific few. In this example, you'll retrieve articles. These are the content items based on the Article content type.

    To move any further, you need to find the codename of the Article content type.

    Quick facts about codenames

    Codenames are identifiers of objects in Kentico Kontent. A codename is initially generated by the system from the object's name when it's saved for the first time.

    You can copy codenames by clicking the codename button  near the name of a content item, content type, content element, or other objects in your project.

    Example: Displaying the codename of the Article content type.

    Once you have the codename (in this case, article) you can use it to filter the retrieved content items by content type.

    The information about a content item's type is stored in the System object within the type attribute. The System object contains metadata about the content item such as last modification date, the item's location in sitemap, content type the item is based on, language, etc.

    • JSON
    "system": { "id": "cf106f4e-30a4-42ef-b313-b8ea3fd3e5c5", "name": "Coffee Beverages Explained", "codename": "coffee_beverages_explained", "language": "en-US", "type": "article", "sitemap_locations": [ "articles" ], "last_modified": "2016-10-27T11:14:58.9229067Z" }
    "system": { "id": "cf106f4e-30a4-42ef-b313-b8ea3fd3e5c5", "name": "Coffee Beverages Explained", "codename": "coffee_beverages_explained", "language": "en-US", "type": "article", "sitemap_locations": [ "articles" ], "last_modified": "2016-10-27T11:14:58.9229067Z" }

    To filter the content items by type, you need to compare the value in the type system attribute to article using the following notation: system.type=article. Any content items that are not based on the Article content type will be omitted from the response.

    • Java
    import com.kenticocloud.delivery_core.*; import com.kenticocloud.delivery_rx.*; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function; // Prepares an array to hold strongly-typed models List<TypeResolver<?>> typeResolvers = new ArrayList<>(); // Registers the type resolver for articles typeResolvers.add(new TypeResolver<>(Article.TYPE, new Function<Void, Article>() { @Override public Article apply(Void input) { return new Article(); } })); // Prepares the DeliveryService configuration object String projectId = "975bf280-fd91-488c-994c-2f04416e5ee3"; IDeliveryConfig config = DeliveryConfig.newConfig(projectId) .withTypeResolvers(typeResolvers); // Initializes a DeliveryService for Java projects IDeliveryService deliveryService = new DeliveryService(config); // Gets all articles using a simple request List<ContentItem> items = deliveryService.<ContentItem>items() .equalsFilter("system.type", "article") .get() .getItems(); // Gets all articles using RxJava2 deliveryService.<ContentItem>items() .equalsFilter("system.type", "article") .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<ContentItem>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<ContentItem> response) { // Gets the articles List<ContentItem> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    import com.kenticocloud.delivery_core.*; import com.kenticocloud.delivery_rx.*; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function; // Prepares an array to hold strongly-typed models List<TypeResolver<?>> typeResolvers = new ArrayList<>(); // Registers the type resolver for articles typeResolvers.add(new TypeResolver<>(Article.TYPE, new Function<Void, Article>() { @Override public Article apply(Void input) { return new Article(); } })); // Prepares the DeliveryService configuration object String projectId = "975bf280-fd91-488c-994c-2f04416e5ee3"; IDeliveryConfig config = DeliveryConfig.newConfig(projectId) .withTypeResolvers(typeResolvers); // Initializes a DeliveryService for Java projects IDeliveryService deliveryService = new DeliveryService(config); // Gets all articles using a simple request List<ContentItem> items = deliveryService.<ContentItem>items() .equalsFilter("system.type", "article") .get() .getItems(); // Gets all articles using RxJava2 deliveryService.<ContentItem>items() .equalsFilter("system.type", "article") .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<ContentItem>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<ContentItem> response) { // Gets the articles List<ContentItem> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article" // More about strongly-typed models https://github.com/Kentico/cloud-sdk-swift#using-strongly-typed-models client.getItems(modelType: Article.self, customQuery: customQuery) { (isSuccess, itemsResponse, error) in if isSuccess { if let articles = itemsResponse?.items { // Use your items here } } else { if let error = error { print(error) } } }
    import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article" // More about strongly-typed models https://github.com/Kentico/cloud-sdk-swift#using-strongly-typed-models client.getItems(modelType: Article.self, customQuery: customQuery) { (isSuccess, itemsResponse, error) in if isSuccess { if let articles = itemsResponse?.items { // Use your items here } } else { if let error = error { print(error) } } }
    • Java
    import com.kenticocloud.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class);
    import com.kenticocloud.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class);
    • JavaScript
    const KontentDelivery = require("@kentico/kontent-delivery"); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models class Article extends KontentDelivery.ContentItem { constructor() { super(); } } const deliveryClient = new KontentDelivery.DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new KontentDelivery.TypeResolver("article", (rawData) => new Article()) ] }); deliveryClient.items() .type("article") .toObservable() .subscribe(response => console.log(response));
    const KontentDelivery = require("@kentico/kontent-delivery"); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models class Article extends KontentDelivery.ContentItem { constructor() { super(); } } const deliveryClient = new KontentDelivery.DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new KontentDelivery.TypeResolver("article", (rawData) => new Article()) ] }); deliveryClient.items() .type("article") .toObservable() .subscribe(response => console.log(response));
    • C#
    using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets all articles // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models DeliveryItemListingResponse<Article> response = await client.GetItemsAsync<Article>( new EqualsFilter("system.type", "article") ); var items = response.Items;
    using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets all articles // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models DeliveryItemListingResponse<Article> response = await client.GetItemsAsync<Article>( new EqualsFilter("system.type", "article") ); var items = response.Items;
    • PHP
    <?php // Defined by Composer to include required libraries require __DIR__ . "/vendor/autoload.php"; use Kentico\Kontent\Delivery\DeliveryClient; use Kentico\Kontent\Delivery\QueryParams; $client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); $items = $client->getItems((new QueryParams()) ->equals("system.type", "article"));
    <?php // Defined by Composer to include required libraries require __DIR__ . "/vendor/autoload.php"; use Kentico\Kontent\Delivery\DeliveryClient; use Kentico\Kontent\Delivery\QueryParams; $client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); $items = $client->getItems((new QueryParams()) ->equals("system.type", "article"));
    • cURL
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article" --header "content-type: application/json"
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article" --header "content-type: application/json"
    • Ruby
    require "delivery-sdk-ruby" delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: "975bf280-fd91-488c-994c-2f04416e5ee3" delivery_client.items("system.type".eq "article").execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    require "delivery-sdk-ruby" delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: "975bf280-fd91-488c-994c-2f04416e5ee3" delivery_client.items("system.type".eq "article").execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    • TypeScript
    import { ContentItem, DeliveryClient, Elements, TypeResolver } from "@kentico/kontent-delivery"; // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models export class Article extends ContentItem { public title: Elements.TextElement; public summary: Elements.TextElement; public post_date: Elements.DateTimeElement; public teaser_image: Elements.AssetsElement; public related_articles: Article[]; } const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new TypeResolver("article", (rawData) => new Article) ] }); deliveryClient.items<Article>() .type("article") .toObservable() .subscribe(response => console.log(response));
    import { ContentItem, DeliveryClient, Elements, TypeResolver } from "@kentico/kontent-delivery"; // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models export class Article extends ContentItem { public title: Elements.TextElement; public summary: Elements.TextElement; public post_date: Elements.DateTimeElement; public teaser_image: Elements.AssetsElement; public related_articles: Article[]; } const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new TypeResolver("article", (rawData) => new Article) ] }); deliveryClient.items<Article>() .type("article") .toObservable() .subscribe(response => console.log(response));

    Note: The value comparison is done using the equals operator (=). To learn more about other filtering operators, such as less than ([lt]), greater than ([gt]), range ([range]) and more, see content filtering in our API reference.

    Ordering content items

    The Delivery API sorts content items alphabetically by their codenames by default. But with content like articles, you usually want to retrieve and display them in a certain order and get, for example, only the 3 latest articles from your project.

    When getting lists of content items, you can specify their order by using the order query parameter. The value of the order query parameter must be in the following format: <AttributeToOrderBy>[<asc|desc>]. Where the AttributeToOrderBy value specifies either a System attribute (such as system.type) or a content element within a content item (such as elements.title). For instance, if you don't specify the order when retrieving content, it is the equivalent of adding order=system.codename[asc] to your query.

    To get the 3 latest articles from your project, you need to provide the following query parameters:

    • system.type=article – specifies the content type of the content items.
    • limit=3 – sets the page size (that is the number of content items to return).
    • order=system.last_modified[desc] – sorts the content items by last modification date in descending order.
    • Java
    import com.kenticocloud.delivery_core.*; import com.kenticocloud.delivery_rx.*; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function; // Prepares an array to hold strongly-typed models List<TypeResolver<?>> typeResolvers = new ArrayList<>(); // Registers the type resolver for articles typeResolvers.add(new TypeResolver<>(Article.TYPE, new Function<Void, Article>() { @Override public Article apply(Void input) { return new Article(); } })); // Prepares the DeliveryService configuration object String projectId = "975bf280-fd91-488c-994c-2f04416e5ee3"; IDeliveryConfig config = DeliveryConfig.newConfig(projectId) .withTypeResolvers(typeResolvers); // Initializes a DeliveryService for Java projects IDeliveryService deliveryService = new DeliveryService(config); // Gets the 3 latest articles ordered by their last modified time using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("system.last_modified", OrderType.Desc) .limitParameter(3) .get() .getItems(); // Gets the 3 latest articles ordered by their last modified time using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("system.last_modified", OrderType.Desc) .limitParameter(3) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the mapped articles List<Article> articles = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    import com.kenticocloud.delivery_core.*; import com.kenticocloud.delivery_rx.*; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function; // Prepares an array to hold strongly-typed models List<TypeResolver<?>> typeResolvers = new ArrayList<>(); // Registers the type resolver for articles typeResolvers.add(new TypeResolver<>(Article.TYPE, new Function<Void, Article>() { @Override public Article apply(Void input) { return new Article(); } })); // Prepares the DeliveryService configuration object String projectId = "975bf280-fd91-488c-994c-2f04416e5ee3"; IDeliveryConfig config = DeliveryConfig.newConfig(projectId) .withTypeResolvers(typeResolvers); // Initializes a DeliveryService for Java projects IDeliveryService deliveryService = new DeliveryService(config); // Gets the 3 latest articles ordered by their last modified time using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("system.last_modified", OrderType.Desc) .limitParameter(3) .get() .getItems(); // Gets the 3 latest articles ordered by their last modified time using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("system.last_modified", OrderType.Desc) .limitParameter(3) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the mapped articles List<Article> articles = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&limit=3&order=system.last_modified[desc]" // More about strongly-typed models https://github.com/Kentico/cloud-sdk-swift#using-strongly-typed-models client.getItems(modelType: Article.self, customQuery: customQuery) { (isSuccess, itemsResponse, error) in if isSuccess { if let articles = itemsResponse?.items { // Use your items here } } else { if let error = error { print(error) } } }
    import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&limit=3&order=system.last_modified[desc]" // More about strongly-typed models https://github.com/Kentico/cloud-sdk-swift#using-strongly-typed-models client.getItems(modelType: Article.self, customQuery: customQuery) { (isSuccess, itemsResponse, error) in if isSuccess { if let articles = itemsResponse?.items { // Use your items here } } else { if let error = error { print(error) } } }
    • Java
    import com.kenticocloud.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .page(null, 3) .orderByDesc("system.last_modified") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    import com.kenticocloud.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .page(null, 3) .orderByDesc("system.last_modified") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    • JavaScript
    const KontentDelivery = require("@kentico/kontent-delivery"); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models class Article extends KontentDelivery.ContentItem { constructor() { super(); } } const deliveryClient = new KontentDelivery.DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new KontentDelivery.TypeResolver("article", (rawData) => new Article()) ] }); deliveryClient.items() .type("article") .limitParameter(3) .orderParameter("system.last_modified", KontentDelivery.SortOrder.desc) .toObservable() .subscribe(response => console.log(response));
    const KontentDelivery = require("@kentico/kontent-delivery"); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models class Article extends KontentDelivery.ContentItem { constructor() { super(); } } const deliveryClient = new KontentDelivery.DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new KontentDelivery.TypeResolver("article", (rawData) => new Article()) ] }); deliveryClient.items() .type("article") .limitParameter(3) .orderParameter("system.last_modified", KontentDelivery.SortOrder.desc) .toObservable() .subscribe(response => console.log(response));
    • C#
    using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets the 3 latest articles ordered by their last modified time // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models DeliveryItemListingResponse<Article> response = await client.GetItemsAsync<Article>( new EqualsFilter("system.type", "article"), new LimitParameter(3), new OrderParameter("system.last_modified", SortOrder.Descending) ); var items = response.Items;
    using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets the 3 latest articles ordered by their last modified time // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models DeliveryItemListingResponse<Article> response = await client.GetItemsAsync<Article>( new EqualsFilter("system.type", "article"), new LimitParameter(3), new OrderParameter("system.last_modified", SortOrder.Descending) ); var items = response.Items;
    • PHP
    <?php // Defined by Composer to include required libraries require __DIR__ . "/vendor/autoload.php"; use Kentico\Kontent\Delivery\DeliveryClient; use Kentico\Kontent\Delivery\QueryParams; $client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); $items = $client->getItems((new QueryParams()) ->equals("system.type", "article") ->limit(3) ->orderDesc("system.last_modified"));
    <?php // Defined by Composer to include required libraries require __DIR__ . "/vendor/autoload.php"; use Kentico\Kontent\Delivery\DeliveryClient; use Kentico\Kontent\Delivery\QueryParams; $client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); $items = $client->getItems((new QueryParams()) ->equals("system.type", "article") ->limit(3) ->orderDesc("system.last_modified"));
    • cURL
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&limit=3&order=system.last_modified[desc]" --header "content-type: application/json"
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&limit=3&order=system.last_modified[desc]" --header "content-type: application/json"
    • Ruby
    require "delivery-sdk-ruby" delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: "975bf280-fd91-488c-994c-2f04416e5ee3" delivery_client.items("system.type".eq "article") .limit(3) .order_by("system.last_modified", "[desc]") .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    require "delivery-sdk-ruby" delivery_client = Kentico::Kontent::Delivery::DeliveryClient.new project_id: "975bf280-fd91-488c-994c-2f04416e5ee3" delivery_client.items("system.type".eq "article") .limit(3) .order_by("system.last_modified", "[desc]") .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    • TypeScript
    import { ContentItem, DeliveryClient, Elements, SortOrder, TypeResolver } from "@kentico/kontent-delivery"; // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models export class Article extends ContentItem { public title: Elements.TextElement; public summary: Elements.TextElement; public post_date: Elements.DateTimeElement; public teaser_image: Elements.AssetsElement; public related_articles: Article[]; } const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new TypeResolver("article", (rawData) => new Article) ] }); deliveryClient.items<Article>() .type("article") .limitParameter(3) .orderParameter("system.last_modified", SortOrder.desc) .toObservable() .subscribe(response => console.log(response));
    import { ContentItem, DeliveryClient, Elements, SortOrder, TypeResolver } from "@kentico/kontent-delivery"; // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models export class Article extends ContentItem { public title: Elements.TextElement; public summary: Elements.TextElement; public post_date: Elements.DateTimeElement; public teaser_image: Elements.AssetsElement; public related_articles: Article[]; } const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3", typeResolvers: [ new TypeResolver("article", (rawData) => new Article) ] }); deliveryClient.items<Article>() .type("article") .limitParameter(3) .orderParameter("system.last_modified", SortOrder.desc) .toObservable() .subscribe(response => console.log(response));

    What's next?

    This tutorial showed you how to get specific content from your Kentico Kontent project by filtering and sorting. Besides retrieving content items, you can also query the Delivery API to get content types, content elements, and taxonomy groups. Everything's described in our API reference.

    To learn more about using the Delivery API, check out the following articles: