cs-icon.svg

Contentstack - Java Delivery SDK

Java Delivery SDK for Contentstack

Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. Read More.

Contentstack provides Java Delivery SDK to build application on top of Java. Given below is the detailed guide and helpful resources to get started with our Java Delivery SDK.

Prerequisite

To get started with Java SDK, you will need the following:

  • An IDE. You can use an IDE of your choice, but make sure it supports Java.
  • Java SDK version 1.8 or later

SDK Installation and Setup

Add the following dependency code snippets into your project:

Maven

<dependency>
  <groupid>com.contentstack.sdk</groupid>
  <artifactid>java</artifactid>
  <version>{version}</version>
</dependency>

Maven users need to add the above code in your pom.xml file under the <dependencies> section.

Gradle

implementation'com.contentstack.sdk:java:{version}

Gradle users need to add the above dependency code into your build.gradle file.

You can download the latest dependency version here.

Quickstart in 5 mins

Initializing your SDK

To initialize the SDK, you will need to specify the stack’s APIKey, Delivery Token, and  Environment where you will publish your content

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("APIKey","deliveryToken","environmentName");

Note : By default, the SDK uses the North American region. Configuration changes are not required for North American region users

For setting the Region refer to the code below:

import com.contentstack.sdk.*;
Config config = Config();
Config.region = ContentstackRegion.EU;
Stack stack = Contentstack.stack("APIKey", "deliveryToken", "environmentName", config);

For setting the Branch refer to the code below:.

import com.contentstack.sdk.*;
Config config = Config();
config.setBranch("branch");
Stack stack = Contentstack.stack("APIkey", "deliveryToken", "environmentName", config);

Note:For Europe, set the region as EU, and for Azure North America and Azure Europe, set the region as AZURE_NA and AZURE_EU respectively.




Basic Queries

Contentstack SDKs let you interact with the Content Delivery APIs and retrieve content from Contentstack. They are read-only in nature. The SDKs fetch and deliver content from the nearest server via Fastly, our powerful and robust CDN.

Get a Single Entry

To retrieve a single Entry from a Content Type, use the code snippet given below:

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("APIKey", "deliveryToken", "environmentName");
ContentType contentType = stack.contentType("contentTypeUid");
Entry entry = contentType.entry("entryUid");
entry.fetch(new EntryResultCallBack() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
if (error == null) {
  System.out.println(entry);
}});

Get Multiple Entries

To retrieve multiple entries of a particular content type, use the code snippet given below:

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("APIKey", "deliveryToken", "environmentName");
Query query = stack.contentType("contentTypeUid").query();
query.find(new QueryResultsCallBack){
 @Override
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
if (error == null) {
}}
});
Note:
  • Currently, the Java SDK does not support multiple content types referencing in a single query. For more information on how to query entries and assets, refer the Queriessection of our Content Delivery API documentation
  • By default, the limit for response details per request is 100, with the maximum limit set at 250.

Pagination

In a single instance, the Get Multiple Entries query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the skip and limit parameters in subsequent requests.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("APIKey","deliveryToken","environmentName"); 
Query query = stack.contentType("contentTypeUid").query(); 
query.skip(20).limit(20).find(newQueryResultsCallBack(){ 
@Override 
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error){
}});

Contentstack

Contentstack class that exposes Stack instance

stack

A stack method provides access to the stack of your site. It allows users to get the content within a single space.

Returns:
Type
Stack
NameTypeDescription

apiKey (required)

String

API Key of your application on Contentstack

deliveryToken (required)

String

Delivery Tokens retrieves only the published entries of the environment with which it is associated

environment (required)

String

A publishing environment refers to one or more deployment servers or a content delivery destination (Webpage’s address) where you will publish your content (entries or assets).

config

Config

Config instance to set environment and other configuration details.

import com.contentstack.sdk.*;
 
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");

Example with Config:

import com.contentstack.sdk.*; 
Config config = new Config().setHost("api.contentstack.io");
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");

Config

Config class that exposes config instance, Where the user can provide other configurations on the stack

earlyAccess

With the earlyAccess header support, you can access features that are part of the early access program.

Config config = new Config();
String[] earlyAccess = {"Taxonomy", "Teams", "Terms", "LivePreview"};
config.setEarlyAccess(earlyAccess);
Stack stack = Contentstack.stack(API_KEY, DELIVERY_TOKEN, ENV, config);

getBranch

Get branch of the stack

Returns:
Type
String

import com.contentstack.sdk.*;
Config config = new Config();
config.getBranch();
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment, config);

setBranch

Set branch for on the stack

Returns:
Type
void
NameTypeDescription

branch (required)

String

branch you want to set

import com.contentstack.sdk.*;
Config config = new Config();
config.setBranch("branchName");
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment, config);

setProxy

Sets custom proxy

Returns:
Type
void
NameTypeDescription

proxy (required)

Proxy

Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object

import com.contentstack.sdk.*;
java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort"));
java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80));
Config config = new Config();
config.setProxy(proxy);

getProxy

Returns the Proxy instance

Returns:
Type
ConnectionPool
import com.contentstack.sdk.*;
Config config = new Config()
config.getProxy()
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

connectionPool

Manages reuse of HTTP and HTTP/2 connections for reduced network latency. HTTP requests that * share the same {@link okhttp3.Address} may share a {@link okhttp3.Connection}. This class implements the policy of which connections to keep open for future use.

Returns:
Type
ConnectionPool
NameTypeDescription

maxIdleConnections (required)

Int

the maxIdleConnections default value is 5

Default: 5

keepAliveDuration (required)

long

the keepAliveDuration default value is 5

Default: 5

timeUnit (required)

TimeUnit

the timeUnit default value is TimeUnit.MINUTES

Default: TimeUnit.MINUTES
import com.contentstack.sdk.*;
Config config = new Config()
config.connectionPool(maxIdleConnections, keepAliveDuration, timeUnit)
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

getRegion

Get Region of the request url

Returns:
Type
ContentstackRegion
import com.contentstack.sdk.*;
Config config = new Config()
config.getRegion()
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setRegion()

Sets Region of the database

Returns:
Type
ContentstackRegion
NameTypeDescription

region (required)

ContentstackRegion

DB region for your stack. You can choose from four regions namely, NA, EU, Azure NA, and Azure EU.

Default: ContentstackRegion. US
import com.contentstack.sdk.*;
Config config = new Config()
config.setRegion(ContentstackRegion.EU)
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

getHost()

Gets host of the request

Returns:
Type
String
import com.contentstack.sdk.*;
Config config = new Config()
config.getHost()
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setHost()

Set custom host of the request url

Returns:
Type
String
NameTypeDescription

hostname (required)

String

The host

import com.contentstack.sdk.*;
Config config = new Config()
config.sethost(hostname)
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

getVersion()

Gets version of the request path

Returns:
Type
String
import com.contentstack.sdk.*;
Config config = new Config()
config.getVersion()
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

enableLivePreview()

Enables Live Preview

Returns:
Type
Config
NameTypeDescription

enable (required)

Boolean

Provide true to enable the Live Preview

Default: False
import com.contentstack.sdk.*;
Config config = new Config()
config.enableLivePreview(true)
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setLivePreviewHost()

Sets Host to the Live Preview request url

Returns:
Type
Config
NameTypeDescription

livePreviewHost (required)

String

Host for Live Preview

import com.contentstack.sdk.*;
Config config = new Config()
config.setLivePreviewHost(host)
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setManagementToken()

Adds Management Token to the stack header

Returns:
Type
Config
NameTypeDescription

managementToken (required)

String

The Management Token

import com.contentstack.sdk.*;
Config config = new Config()
config.setManagementToken(managementToken)
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

Asset

In Contentstack, any files (images, videos, PDFs, audio files, and so on) that you upload get stored in your repository for future use. This repository of uploaded files is called Assets.

getUpdatedBy

Gets UpdatedBy object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getUpdatedBy();

setHeader

Add header using key and value

Returns:
Type
AssetLibrary
NameTypeDescription

key (required)

String

The key you want to remove from the header

value (required)

String

Value of the header against the key

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.setHeader(key, value);

removeHeader

Removes header key

Returns:
Type
AssetLibrary
NameTypeDescription

key (required)

String

The key you want to remove from the header

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.removeHeader(key);

sort

Sort asset library.

Returns:
Type
AssetLibrary
NameTypeDescription

keyOrderBy (required)

String

the key order by

orderby (required)

ORDERBY

the orderby can be applied using ORDERBY enums

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.sort(keyOrderBy, ORDERBY.ASCENDING);

includeCount

Include count asset library.

Returns:
Type
AssetLibrary

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeCount();

includeRelativeUrl

Include relative url asset library.

Returns:
Type
AssetLibrary

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeRelativeUrl();

includeFallback

Includes the fallback language

Returns:
Type
AssetLibrary

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeFallback()

getCount

Returns list of all assets available in the stack

Returns:
Type
int

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.getCount()

setHeader

Fetch all the assets

Returns:
Type
Query
NameTypeDescription

callback (required)

FetchAssetsCallback

The callback of type FetchAssetsCallback

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.fetchAll(new FetchAssetsCallback({
});

removeHeader

Removes header using key

Returns:
Type
void
NameTypeDescription

headerKey (required)

String

Key of the header you want to remove

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.removeHeader(headerKey);





getAssetUid

Gets AssetUid object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getAssetUid();
}
});





getFileType

Gets FileType object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getFileType();
}
});





getFileSize

Gets FileSize object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getFileSize();
}
});





getFileName

Gets FileName object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 String filename = asset.getFileName();
}
});





getUrl

Gets getUrl object from the asset response

Returns:
Type
JSONObject

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 String url = asset.getUrl();
 System.out.println(url);
}
});





toJSON

Gets JSON object from the asset response

Returns:
Type
JSONObject

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.toJSON();
}
});





getCreateAt

Gets CreateAt object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getCreateAt();
}
});





getCreatedBy

Gets CreatedBy object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getCreatedBy();
}
});





getUpdateAt

Gets UpdateAt object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
 asset.getUpdateAt();
}
});





getDeleteAt

Gets Deleted At object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getDeleteAt()

getDeletedBy

Gets Deleted by object from the asset response

Returns:
Type
String

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getDeletedBy()

getTags

Includes Array of tags in the asset response

Returns:
Type
String[]

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.getTags()

setTags

Includes Tags in the asset response

Returns:
Type
Asset

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.setTags()

includeDimension

Inludes Dimension in the asset response

Returns:
Type
Asset

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.includeDimension();

addParam

Add query parameter to the asset request

Returns:
Type
Asset
NameTypeDescription

key (required)

String

Key of the header you want to add

value (required)

String

Add value to the header against the header key

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Asset asset = stack.asset(assetUid).addParam();

includeFallback

Includes Fallback language in the asset response

Returns:
Type
Asset

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.includeFallback();

includeBranch

Includes Branch in the asset response

Returns:
Type
Asset

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Asset asset = stack.asset(assetUid);
asset.includeBranch();

fetch

Fetch all the assets available in the stack

Returns:
Type
void
NameTypeDescription

callback (required)

FetchResultCallback

callback of the asset response

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
  System.out.print(asset);
 }
}

AssetLibrary

In Contentstack, any files (images, videos, PDFs, audio files, and so on) that you upload get stored in your repository for future use. This repository of uploaded files is called Assets.

sort

Sort asset library.

Returns:
Type
AssetLibrary
NameTypeDescription

keyOrderBy (required)

String

the key order by

orderby (required)

ORDERBY

the orderby can be applied using ORDERBY enums

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(
apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.sort(keyOrderBy, ORDERBY.ASCENDING);

includeCount

Include count asset library.

Returns:
Type
AssetLibrary

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(
apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeCount();

includeRelativeUrl

Include relative url asset library.

Returns:
Type
AssetLibrary

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(
apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeRelativeUrl();

sort

Sort asset library.

Returns:
Type
AssetLibrary
NameTypeDescription

keyOrderBy (required)

String

the key order by

orderby (required)

ORDERBY

the orderby can be applied using ORDERBY enums

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.sort(keyOrderBy, ORDERBY.ASCENDING);

includeCount

Include count asset library.

Returns:
Type
AssetLibrary

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeCount();

includeRelativeUrl

Include relative url asset library.

Returns:
Type
AssetLibrary

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeRelativeUrl();

ContentType

Content type defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required to first create a content type, and then create entries using the content type.

removeHeader

Removes header from the stack using headerKey

Returns:
Type
void
NameTypeDescription

headerKey (required)

String

The key of the header

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
ContentType contentType = stack.contentType("contentTypeUid");
contentType.removeHeader(headerKey)

entry

An Entry is the actual piece of content created using one of the defined content types.

Returns:
Type
Entry
NameTypeDescription

entryUid (required)

String

The entry unique ID of the entry that you want to fetch

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
ContentType contentType = stack.contentType("contentTypeUid");
contentType.entry("entryUid")

query

Provides query instance

Returns:
Type
void

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
ContentType contentType = stack.contentType("contentTypeUid");
contentType.query()

fetch

fetch all the content types available for the stack

Returns:
Type
void
NameTypeDescription

params (required)

JSONObject

key value parameters of type JSONObject

callback (required)

ContentTypesCallback

The callback of type ContentTypesCallback

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
ContentType contentType = stack.contentType("contentTypeUid");
contentType.fetch(new JSONObject(), new ContentTypesCallback() {
 @Override
public void onCompletion(ContentTypesModel model, Error error) {
   JSONArray resp = model.getResultArray();
}
});

Entry

An entry is the actual piece of content created using one of the defined content types.

removeHeader

Removes header using key

Returns:
Type
void
NameTypeDescription

key

String

key of the header you want to remove

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.removeHeader(key)

getTags

Gets entry tags

Returns:
Type
String[]

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.
()

getContentType

Gets entry content type

Returns:
Type
Entry

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getContentType()

getUid

Gets entry uid

Returns:
Type
Entry

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getUid()

getLocale

Gets Language of the entry

Returns:
Type
Entry

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getLocale();

setLocale

Sets locale of entry

Returns:
Type
Entry
NameTypeDescription

locale (required)

String

language code

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.setLocale();

except

Specifies list of field uids that would be excluded from the response

Returns:
Type
Entry
NameTypeDescription

referenceField (required)

String

field uid which get excluded from the response.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.except(new String[]{"name", "description"});

includeReference

Add a constraint that requires a particular reference key details.

Returns:
Type
Entry
NameTypeDescription

referenceFields (required)

String[]

referenceFields array key that to be constrained

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeReference(new String[]{"referenceUid_A", "referenceUid_B"});

only

Specifies an array of only keys in BASE object that would be included in the response

Returns:
Type
Entry
NameTypeDescription

fieldUid (required)

ArrayList<String>

Array of the only reference keys to be included in response

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.only(new String[]{"name", "description"});

onlyWithReferenceUid

Specifies an array of only keys that would be included in the response.

Returns:
Type
Entry
NameTypeDescription

fieldUid (required)

ArrayList<String>

Array of the only reference keys to be included in response.

referenceFieldUid (required)

String

Key who has reference to some other class object

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
ArrayList<String> array = new ArrayList<String>();
array.add("description");
array.add("name");
entry.onlyWithReferenceUid(array, "referenceUid");

exceptWithReferenceUid()

Specifies an array of except keys that would be exclude in the response

Returns:
Type
Entry
NameTypeDescription

fieldUid (required)

ArrayList<String>

Array of the except reference keys to be excluded in response

referenceFieldUid (required)

String

Key who has reference to some other class object

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.
()
ArrayList<String> array = new ArrayList<String>();

fetch

fetch is used to get the entry response

Returns:
Type
void
NameTypeDescription

callback (required)

EntryResultCallBack

EntryResultCallBack object to notify the application when the request has completed

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.fetch(new EntryResultCallBack() {
@Override public void onCompletion(ResponseType responseType, Error error) {
}
});}

addParam

Adds query parameters in the entry request

Returns:
Type
Entry
NameTypeDescription

key (required)

String

key of the header

value (required)

String

value of the header

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.addParam(key, value)

includeReferenceContentTypeUID

Include Reference ContentType UID in the entry response

Returns:
Type
Entry
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeReferenceContentTypeUID()

includeContentType

Include ContentType in the entry response

Returns:
Type
Entry
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeContentType()

includeFallback

Include Fallback Language in the entry response

Returns:
Type
Entry
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeFallback()

includeEmbeddedItems

Include Embedded Items in the entry response

Returns:
Type
Entry
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeEmbeddedItems()

includeBranch

include branch in the entry response

Returns:
Type
void
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("user").entry("entryUid");
entry.includeBranch();

Taxonomy

Taxonomy helps you categorize pieces of content within your stack to facilitate easy navigation and retrieval of information.

To access the taxonomy instance, use the code snippet provided below within the stack class:

Stack stack = Contentstack.stack("API_KEY", "DELIVERY_TOKEN", "ENVIRONMENT");
Taxonomy taxonomy = stack.taxonomy();

in

The in method retrieves all entries for a specific taxonomy that satisfy the given conditions provided in the $in query.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

taxonomy (required)

string

Enter the UID of the taxonomy

listOfItems

list<string>

Enter the list of taxonomy fields

Example: If you want to retrieve entries with the color taxonomy applied and linked to the terms red and/or yellow.

Taxonomy taxonomy = stack.taxonomy();List listOfItems = new ArrayList<>();
listOfItems.add("red");
listOfItems.add("yellow");
taxonomy.in("taxonomies.color", listOfItems).find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

or

The or method retrieves all entries for a specific taxonomy that satisfy at least one of the given conditions provided in the $or query.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

listOfItems

list<JSONObject>

Enter the list of taxonomy fields

Example: If you want to retrieve entries with either the color or size taxonomy applied and linked to the terms yellow and small, respectively.

Taxonomy taxonomy = stack.taxonomy();
     List<jsonobject>listOfItems = new ArrayList<>();
     JSONObject item1 = new JSONObject();
     item1.put("taxonomies.color", "yellow");
     JSONObject item2 = new JSONObject();
     item2.put("taxonomies.size", "small");
     listOfItems.add(item1);
     listOfItems.add(item2);
     taxonomy.or(listOfItems);
     taxonomy.find((response, error) -> {
        if (error!=null){
            System.out.println("response :"+response);
            }
        });

and

The and method retrieves all entries for a specific taxonomy that satisfy all the conditions provided in the $and query.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

listOfItems

list<JSONObject>

Enter the list of taxonomy fields

Example: If you want to retrieve entries with the color and computers taxonomies applied and linked to the terms red and laptop, respectively.

Taxonomy taxonomy = stack.taxonomy();
List<jsonobject>listOfItems = new ArrayList<>();
JSONObject items1 = new JSONObject();
items1.put("taxonomies.color", "green");
JSONObject items2 = new JSONObject();
items2.put("taxonomies.computers", "laptop");
listOfItems.add(items1);
listOfItems.add(items2);
taxonomy.and(listOfItems);
taxonomy.find((response, error) -> {
  if (error!=null){
      System.out.println("response :"+response);
    }
  });

exists

The exists method retrieves all entries for a specific taxonomy if the value of the field, mentioned in the condition, exists.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

taxonomy (required)

string

Enter the UID of the taxonomy

value (required)

boolean

Enter true/false

Example: If you want to retrieve entries with the color taxonomy applied.


Taxonomy taxonomy = stack.taxonomy().exists("taxonomies.color", true);
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

equalAndBelow

The equalAndBelow method retrieves all entries for a specific taxonomy that match a specific term and all its descendant terms, requiring only the target term.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

taxonomy (required)

string

Enter the UID of the taxonomy

termsUid (required)

string

Enter the UID of the term

Example: If you want to retrieve all entries with terms nested under blue, such as navy blue and sky blue, while also matching entries with the target term blue.


Taxonomy taxonomy = stack.taxonomy().equalAndBelow("taxonomies.color", "blue");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

equalAndBelowWithLevel

The equalAndBelowWithLevel method retrieves all entries for a specific taxonomy that match a specific term and all its descendant terms, requiring only the target term and a specified level.

Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

taxonomy (required)

string

Enter the UID of the taxonomy

termsUid (required)

string

Enter the UID of the term

level

int

Enter the level

Example: If you want to retrieve all entries until level 2 with terms nested under blue, such as navy blue and sky blue, while also matching entries with the target term blue.


Taxonomy taxonomy = stack.taxonomy().equalAndBelowWithLevel("taxonomies.color", "blue", 3);
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

below

The below method retrieves all entries for a specific taxonomy that match all of their descendant terms by specifying only the target term and a specific level.

Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

taxonomy (required)

string

Enter the UID of the taxonomy

termsUid (required)

string

Enter the UID of the term

Example: If you want to retrieve all entries containing terms nested under blue, such as navy blue and sky blue, but exclude entries that solely have the target term blue.


Taxonomy taxonomy = stack.taxonomy().below("taxonomies.appliances", "led");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

equalAbove

The equalAbove method retrieves all entries for a specific taxonomy that match a specific term and all its ancestor terms, requiring only the target term and a specified level.

Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

taxonomy (required)

string

Enter the UID of the taxonomy

termsUid (required)

string

Enter the UID of the term

Example: If you want to obtain all entries that include the term LED and its parent term TV.

Taxonomy taxonomy = stack.taxonomy().equalAbove("taxonomies.appliances", "led");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

above

The above method retrieves all entries for a specific taxonomy that match only the parent term(s) of a specified target term, excluding the target term itself and a specified level.

Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

Returns:
Type
Instance of Taxonomy Object
NameTypeDescription

taxonomy (required)

string

Enter the UID of the taxonomy

termsUid (required)

string

Enter the UID of the term

Example: If you wish to match entries with the term tv but exclude the target term led.

Taxonomy taxonomy = stack.taxonomy().above("taxonomies.appliances", "led");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

find

The find method is used to get the API response.

NameTypeDescription

callback (required)

TaxonomyCallback

The callback class that contains the API response

Example:

taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });

Query

The Get all entries request fetches the list of all the entries of a particular content type. It returns the content of each entry in JSON format. You need to specify the environment and locale of which you want to get the entries. We can apply filters on query also.

removeHeader

Remove header key

Returns:
Type
Query
NameTypeDescription

key (required)

String

key of the header you want to remove

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.removeHeader(key)

getContentType

Gets the content type

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.getContentType()

where

Add a constraint to fetch all entries that contains given value against specified key

Returns:
Type
Query
NameTypeDescription

key (required)

String

key of query parameter

value (required)

Object

value of query param

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.where("uid", "entry_uid");

addQuery

Add a custom query against specified key.

Returns:
Type
Query
NameTypeDescription

key (required)

String

key of query parameter

value (required)

String

value of query param

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.addQuery("key", "value");

removeQuery

Remove provided query key from custom query if exist.

Returns:
Type
Query
NameTypeDescription

key (required)

String

Query name to remove.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.removeQuery(key);

or

Combines all the queries together using AND operator

Returns:
Type
Query
NameTypeDescription

queryObjects (required)

ArrayList<Query>

List of Query instances on which AND query executes.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThan("due_date", "2013-06-25T00:00:00+05:30");
Query query = projectClass.query();
query.where('username','something');
Query subQuery = projectClass.query();
subQuery.where('email_address','something@email.com');
ArrayList<Query> array = new ArrayList<Query>();
array.add(query);
array.add(subQuery);
query.and(array);

or

Add a constraint to fetch all entries which satisfy any queries.

Returns:
Type
Query
NameTypeDescription

queryObjects (required)

ArrayList<Query>

the value that provides an upper bound

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThan("due_date", "2013-06-25T00:00:00+05:30");
Query query = projectClass.query();
query.where('username','something');
Query subQuery = projectClass.query();
subQuery.where('email_address','something@email.com');
ArrayList<Query> array = new ArrayList<Query>();
array.add(query);
array.add(subQuery);
query.or(array);

lessThan

Add a constraint to the query that requires a particular key entry to be less than the provided value.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

values (required)

Object

the value that provides an upper bound

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThan("due_date", "2013-06-25T00:00:00+05:30");

lessThanOrEqualTo

Add a constraint to the query that requires a particular key entry to be less than or equal to the provided value

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

values (required)

Object

The value that must be equalled.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.lessThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");

greaterThan

Add a constraint to the query that requires a particular key entry to be greater than the provided value.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

values (required)

Object

The value that provides an lower bound.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.greaterThan("due_date", "2013-06-25T00:00:00+05:30");

greaterThanOrEqualTo

Add a constraint to the query that requires a particular key entry to be greater than or equal to the provided value.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

values (required)

Object

The list of values the key object should not be.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.greaterThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30");

notEqualTo

Add a constraint to the query that requires a particular key's entry to be contained in the provided array

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

values (required)

Object

The list of values the key object should not be.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.notEqualTo("due_date", "2013-06-25T00:00:00+05:30");

notContainedIn

Add a constraint to the query that requires a particular key's entry to be contained in the provided array

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

values (required)

Object[]

The list of values the key object should not be.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.containedIn("severity", new Object[] { "Show Stopper", "Critical" });

notContainedIn

Add a constraint to the query that requires a particular key entry's value not be contained in the provided array.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

values (required)

Object[]

The list of values the key object should not be.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.notContainedIn("severity", new Object[] { "Show Stopper", "Critical" });

exists

Add a constraint that requires, a specified key exists in response

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.exists("status");

notExists

Add a constraint that requires, a specified key does not exists in response.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.notExists("status");

includeReference

Add a constraint that requires a particular reference key details

Returns:
Type
Query
NameTypeDescription

key (required)

String

key that to be constraineda

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeReference(key);

tags

Include tags with which to search entries

Returns:
Type
Query
NameTypeDescription

key (required)

String[]

Comma separated array of tags with which to search entries.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.tags(new String[] { "tag1", "tag2" });

ascending

Sort the results in ascending order with the given key. <br> Sort the returned entries in ascending order of the provided key.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to order by.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.ascending(key);

descending

Sort the results in descending order with the given key. <br> Sort the returned entries in descending order of the provided key.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to order by.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.descending(key);

only

Specifies an array of only keys in BASE object that would be included in the response.

Returns:
Type
Query
NameTypeDescription

fieldUid (required)

String[]

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();

exceptWithReferenceUid

Specifies an array of only keys that would be included in the response

Returns:
Type
Query
NameTypeDescription

fieldUid (required)

ArrayList<String>

Array of the only reference keys to be included in response

referenceFieldUid (required)

String

Key who has reference to some other class object

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
ArrayList<String> array = new ArrayList<String>();
array.add("description");
query.onlyWithReferenceUid(array, "for_bug");

exceptWithReferenceUid

Specifies an array of except keys that would be excluded in the response.

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
ArrayList<String> array = new ArrayList<String>();
array.add("description");
query.exceptWithReferenceUid(array, "for_bug");

count

Retrieve count and data of objects in result

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.count();

includeCount

Retrieve count and data of objects in result

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeCount();

includeContentType

Include Content Type of all returned objects along with objects themselves

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeContentType();

includeOwner

Include object owner's profile in the objects data.

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.
()

skip

The number of objects to skip before returning any.

Returns:
Type
Query
NameTypeDescription

number (required)

int

Number of objects to skip from returned objects

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.skip(3)

limit

A limit on the number of objects to return.

Returns:
Type
Query
NameTypeDescription

number (required)

int

Number of objects to limit.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
csQuery.limit(3)

regex

Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large data sets.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained.

regex (required)

String

The regular expression pattern to match

modifiers

Any of the following supported Regular expression modifiers.

- use i for case-insensitive matching.

- use m for making dot match newlines.

- use x for ignoring whitespace in regex

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
csQuery.regex("name", "^browser", "i");

locale

Set Language using locale code.

Returns:
Type
Query
NameTypeDescription

locale (required)

String

language code

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.locale("locale-code");

search

This method provides only the entries matching the specified value.

Returns:
Type
Query
NameTypeDescription

value (required)

String

value used to match or compare

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.search("header");

find

Execute a Query and Caches its result (Optional)

Returns:
Type
Query
NameTypeDescription

callBack (required)

QueryResultsCallBack

QueryResultsCallBack object to notify the application when the request has completed.

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.find(new QueryResultsCallBack() {
@Override 
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
 }
});

findOne

This Execute a Query and Caches its result (Optional)

Returns:
Type
Query
NameTypeDescription

callBack (required)

SingleQueryResultCallback

The key as string which needs to be added to the Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
@
}
});

addParam

This method adds key and value to an Entry. Parameters

Returns:
Type
Query
NameTypeDescription

paramKey (required)

String

The key as string which needs to be added to the Query

paramValue (required)

String

The value as string which needs to be added to the Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.addParam(key, value);

includeReferenceContentTypUid

This method also includes the content type UIDs of the referenced entries returned in the response

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
csQuery.includeReferenceContentTypUid()

whereNotIn

Get entries having values based on referenced fields. This query retrieves all entries that satisfy the query conditions made on referenced fields.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

queryObject (required)

Query

queryObject is Query object, so you can chain this call

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.whereIn("due_date", <span>query</span>);

whereNotIn

Get entries having values based on referenced fields. This query works the opposite of $in_query and retrieves all entries that does not satisfy query conditions made on referenced fields.

Returns:
Type
Query
NameTypeDescription

key (required)

String

The key to be constrained

queryObject (required)

Query

Query object, so you can chain this call

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.whereNotIn("due_date", 
);

includeFallback

Includes language fallback in the query response

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeFallback();

includeEmbeddedItems

Includes Embedded Items in the query response

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();
query.includeEmbeddedItems();

includeBranch

Includes Branch in the entry response

Returns:
Type
Query

import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
Query query = stack.contentType("contentTypeUid").query();