Skip navigation

Getting titles and images of 5 latest articles

In this tutorial, you will learn how to use the Delivery API to:

  • Filter content items by content type
  • Order the content items
  • Get only the top five content items
  • Get only specific content elements

Table of contents

    1. Get all items

    All content items are part of a project. You must include the project ID in every API request.

    After getting the project ID, include it in the request URI. The following URI gets all content items:

    • Java
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 articles using a simple request List<ContentItem> items = deliveryService.<ContentItem>items() .get() .getItems(); // Gets all articles 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 items List<ContentItem> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 articles using a simple request List<ContentItem> items = deliveryService.<ContentItem>items() .get() .getItems(); // Gets all articles 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 items List<ContentItem> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") // Note: Using "items" as custom query returns all 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) } } }
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") // Note: Using "items" as custom query returns all 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
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .build(); ContentItemsListingResponse listingResponse = client.getItems(params);
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .build(); ContentItemsListingResponse listingResponse = client.getItems(params);
    • JavaScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript const KontentDelivery = require("@kentico/kontent-delivery"); const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3" }); deliveryClient.items<ContentItem>() .toObservable() .subscribe(response => console.log(response));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript const KontentDelivery = require("@kentico/kontent-delivery"); const deliveryClient = new DeliveryClient({ projectId: "975bf280-fd91-488c-994c-2f04416e5ee3" }); deliveryClient.items<ContentItem>() .toObservable() .subscribe(response => console.log(response));
    • C#
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net 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>(); IReadOnlyList<ContentItem> items = response.Items;
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net 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>(); IReadOnlyList<ContentItem> items = response.Items;
    • PHP
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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 // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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
    • TypeScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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));

    2. Get only articles

    You can filter content items by content type by including the system.type query parameter and the content type's codename.

    After getting the content type's codename, include it in the request URI. The following URI gets all articles:

    • Java
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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<Article> items = deliveryService.<Article>items() .equalsFilter("system.type", "article") .get() .getItems(); // Gets all articles using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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<Article> items = deliveryService.<Article>items() .equalsFilter("system.type", "article") .get() .getItems(); // Gets all articles using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios 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) } } }
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios 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
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.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, params);
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.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, params);
    • JavaScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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));
    • C#
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net 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") ); IReadOnlyList<ContentItem> items = response.Items;
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net 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") ); IReadOnlyList<ContentItem> items = response.Items;
    • PHP
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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 // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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
    • TypeScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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 that the content type is a part of the system properties. Therefore, the query parameters begin with system..

    You can see the full list of system properties in the API reference.

    3. Order articles by post date

    You can order articles by their post date by including the order query parameter and a content element's codename.

    After getting the content element's codename, include it in the request URI. The following URI gets all articles ordered from the most recent to the least recent:

    • Java
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 ordered by the "Post date" element using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .elementsParameter(Arrays.asList("title", "summary", "post_date", "teaser_image")) .orderParameter("elements.post_date", OrderType.Desc) .get() .getItems(); // Gets all articles ordered by the "Post date" element using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("elements.post_date", OrderType.Desc) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 ordered by the "Post date" element using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .elementsParameter(Arrays.asList("title", "summary", "post_date", "teaser_image")) .orderParameter("elements.post_date", OrderType.Desc) .get() .getItems(); // Gets all articles ordered by the "Post date" element using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("elements.post_date", OrderType.Desc) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&order=elements.post_date[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) } } }
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&order=elements.post_date[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
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .orderByDesc("elements.post_date") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .orderByDesc("elements.post_date") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    • JavaScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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") .orderParameter("elements.post_date", KontentDelivery.SortOrder.desc) .toObservable() .subscribe(response => console.log(response));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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") .orderParameter("elements.post_date", KontentDelivery.SortOrder.desc) .toObservable() .subscribe(response => console.log(response));
    • C#
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets all articles sorted by post date // 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 OrderParameter("elements.post_date", SortOrder.Descending) ); IReadOnlyList<ContentItem> items = response.Items;
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets all articles sorted by post date // 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 OrderParameter("elements.post_date", SortOrder.Descending) ); IReadOnlyList<ContentItem> items = response.Items;
    • PHP
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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") ->orderDesc("elements.post_date"));
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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") ->orderDesc("elements.post_date"));
    • cURL
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&order=elements.post_date[desc]" --header "content-type: application/json"
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&order=elements.post_date[desc]" --header "content-type: application/json"
    • Ruby
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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") .order_by("elements.post_date", "[desc]") .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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") .order_by("elements.post_date", "[desc]") .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    • TypeScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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") .orderParameter("elements.post_date", SortOrder.desc) .toObservable() .subscribe(response => console.log(response));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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") .orderParameter("elements.post_date", SortOrder.desc) .toObservable() .subscribe(response => console.log(response));

    Note that you can order content items in ascending or descending order.

    4. Get only the five latest articles

    When getting a large collection of content items, you can get only a small subset by using the skip and limit query parameters.

    To get only the five latest articles, you can add the following query parameter:

    • Java
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 5 articles ordered by the "Post date" element using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .get() .getItems(); // Gets 5 articles ordered by the "Post date" element using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 5 articles ordered by the "Post date" element using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .get() .getItems(); // Gets 5 articles ordered by the "Post date" element using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&order=elements.post_date[desc]&limit=5" // 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) } } }
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&order=elements.post_date[desc]&limit=5" // 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
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .orderByDesc("elements.post_date") .page(null, 5) .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .orderByDesc("elements.post_date") .page(null, 5) .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    • JavaScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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") .orderParameter("elements.post_date", KontentDelivery.SortOrder.desc) .limitParameter(5) .toObservable() .subscribe(response => console.log(response));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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") .orderParameter("elements.post_date", KontentDelivery.SortOrder.desc) .limitParameter(5) .toObservable() .subscribe(response => console.log(response));
    • C#
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets 5 articles sorted by post date // 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 OrderParameter("elements.post_date", SortOrder.Descending), new LimitParameter(5) ); IReadOnlyList<ContentItem> items = response.Items;
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets 5 articles sorted by post date // 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 OrderParameter("elements.post_date", SortOrder.Descending), new LimitParameter(5) ); IReadOnlyList<ContentItem> items = response.Items;
    • PHP
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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") ->orderDesc("elements.post_date") ->limit(5));
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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") ->orderDesc("elements.post_date") ->limit(5));
    • cURL
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&order=elements.post_date[desc]&limit=5" --header "content-type: application/json"
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&order=elements.post_date[desc]&limit=5" --header "content-type: application/json"
    • Ruby
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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(5) .order_by("elements.post_date", "[desc]") .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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(5) .order_by("elements.post_date", "[desc]") .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    • TypeScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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") .orderParameter("elements.post_date", SortOrder.desc) .limitParameter(5) .toObservable() .subscribe(response => console.log(response));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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") .orderParameter("elements.post_date", SortOrder.desc) .limitParameter(5) .toObservable() .subscribe(response => console.log(response));

    5. Get only titles and images

    You can retrieve only certain content elements of a content item, for example when displaying a preview of an article.

    You can add the elements query parameter and a comma-separated list of content elements' codenames to get only the specified content elements.

    The following URI gets all titles and teaser images of articles ordered from the most recent to the least recent:

    • Java
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 specific elements of 5 articles ordered by the "Post date" element using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .elementsParameter(Arrays.asList("title", "teaser_image")) .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .get() .getItems(); // Gets specific elements of 5 articles ordered by the "Post date" element using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .elementsParameter(Arrays.asList("title", "teaser_image")) .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/javaandroid 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 specific elements of 5 articles ordered by the "Post date" element using a simple request List<Article> articles = deliveryService.<Article>items() .equalsFilter("system.type", "article") .elementsParameter(Arrays.asList("title", "teaser_image")) .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .get() .getItems(); // Gets specific elements of 5 articles ordered by the "Post date" element using RxJava2 deliveryService.<Article>items() .equalsFilter("system.type", "article") .elementsParameter(Arrays.asList("title", "teaser_image")) .orderParameter("elements.post_date", OrderType.Desc) .limitParameter(5) .getObservable() .subscribe(new Observer<DeliveryItemListingResponse<Article>>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(DeliveryItemListingResponse<Article> response) { // Gets the articles List<Article> items = response.getItems(); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
    • Swift
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&order=elements.post_date[desc]&limit=5&elements=title,teaser_image" // 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) } } }
    // Tip: Find more about Swift SDK at https://docs.kontent.ai/ios import KenticoCloud let client = DeliveryClient.init(projectId: "975bf280-fd91-488c-994c-2f04416e5ee3") let customQuery = "items?system.type=article&order=elements.post_date[desc]&limit=5&elements=title,teaser_image" // 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
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .orderByDesc("elements.post_date") .page(null, 5) .projection("title", "teaser_image") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    // Tip: Find more about Java/JavaRx SDKs at https://docs.kontent.ai/java import com.github.kentico.kontent.delivery; DeliveryClient client = new DeliveryClient("975bf280-fd91-488c-994c-2f04416e5ee3"); List<NameValuePair> params = DeliveryParameterBuilder.params() .filterEquals("system.type", "article") .orderByDesc("elements.post_date") .page(null, 5) .projection("title", "teaser_image") .build(); // Create strongly typed models according to https://docs.kontent.ai/strongly-typed-models List<ArticleItem> items = client.getItems(ArticleItem.class, params);
    • JavaScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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") .orderParameter("elements.post_date", KontentDelivery.SortOrder.desc) .limitParameter(5) .elementsParameter(["title", "teaser_image"]) .toObservable() .subscribe(response => console.log(response));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/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") .orderParameter("elements.post_date", KontentDelivery.SortOrder.desc) .limitParameter(5) .elementsParameter(["title", "teaser_image"]) .toObservable() .subscribe(response => console.log(response));
    • C#
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets specific elements of 5 articles sorted by post date // 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 OrderParameter("elements.post_date", SortOrder.Descending), new LimitParameter(5), new ElementsParameter("title", "teaser_image") ); IReadOnlyList<ContentItem> items = response.Items;
    // Tip: Find more about .NET SDKs at https://docs.kontent.ai/net using Kentico.Kontent.Delivery; // Initializes a content delivery client IDeliveryClient client = DeliveryClientBuilder .WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3") .Build(); // Gets specific elements of 5 articles sorted by post date // 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 OrderParameter("elements.post_date", SortOrder.Descending), new LimitParameter(5), new ElementsParameter("title", "teaser_image") ); IReadOnlyList<ContentItem> items = response.Items;
    • PHP
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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") ->orderDesc("elements.post_date") ->limit(5) ->elements(array("title", "teaser_image")));
    <?php // Tip: Find more about PHP SDKs at https://docs.kontent.ai/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") ->orderDesc("elements.post_date") ->limit(5) ->elements(array("title", "teaser_image")));
    • cURL
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&order=elements.post_date[desc]&limit=5&elements=title,teaser_image" --header "content-type: application/json"
    curl --request GET \ --url "https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?system.type=article&order=elements.post_date[desc]&limit=5&elements=title,teaser_image" --header "content-type: application/json"
    • Ruby
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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(5) .order_by("elements.post_date", "[desc]") .elements(%w[title teaser_image]) .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    # Tip: Find more about Ruby SDKs at https://docs.kontent.ai/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(5) .order_by("elements.post_date", "[desc]") .elements(%w[title teaser_image]) .execute do |response| items = response.items items.each { |item| puts item.system.codename } end
    • TypeScript
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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") .orderParameter("elements.post_date", SortOrder.desc) .limitParameter(5) .elementsParameter(["title", "teaser_image"]) .toObservable() .subscribe(response => console.log(response));
    // Tip: Find more about JS/TS SDKs at https://docs.kontent.ai/javascript 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") .orderParameter("elements.post_date", SortOrder.desc) .limitParameter(5) .elementsParameter(["title", "teaser_image"]) .toObservable() .subscribe(response => console.log(response));

    Note that the system properties are always returned in the response.