Contentstack Delivery React Native SDK

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 React Native Delivery SDK to build application on top of React Native. Given below is the detailed guide and helpful resources to get started with our React Native Delivery SDK.

Prerequisite

You need Node.js version 4.4.7 or later installed to use the Contentstack JavaScript Delivery SDK.

Setup and Installation

React Native uses the Javascript SDK to create apps. To use the JavaScript Delivery SDK, install ist via npm:

npm i contentstack

To import the SDK in your project, use the following command:

import Contentstack from 'contentstack/react-native'

To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.

const Stack = Contentstack.Stack({ "api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment" });

To initialize the SDK for the Europe, Azure NA, Azure EU, or GCP NA region, refer to the code below:

For EU

const Stack = Contentstack.Stack({"api_key":"api_key","delivery_token":"delivery_token","environment":"environment","region":Contentstack.Region.EU});
For Azure EU
const Stack = Contentstack.Stack({"api_key":"api_key","delivery_token":"delivery_token","environment":"environment","region":Contentstack.Region.AZURE_EU});
FOR AZURE_NA
const Stack = Contentstack.Stack({"api_key":"api_key","delivery_token":"delivery_token","environment": "environment", "region": Contentstack.Region.AZURE_NA});
FOR GCP_NA
const Stack = Contentstack.Stack({"api_key":"api_key","delivery_token":"delivery_token","environment":"environment","region":Contentstack.Region.GCP_NA});

Quickstart in 5 mins

Initializing your SDK

You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK:

const Stack = Contentstack.Stack({ "api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment" });

Once you have initialized the SDK, you can start getting content in your app.

Querying content from your stack

To get a single entry, you need to specify the content type as well as the ID of the entry.

const Stack = Contentstack.Stack({ "api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment" });

const entry = Stack.ContentType('blog').Entry("entry_uid");

const result = await entry.fetch()

NoteWe have a method on query for a specific language. For example, consider the following query:

Stack.ContentType('content_type_uid').Query().language('fr-fr').toJSON().find()

It will provide all entries of a content type published on the French locale.

To retrieve multiple entries of a content type, you need to specify the content type UID. You can also specify search parameters to filter results.

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment" });

const Query = Stack.ContentType('blog').Query();

Query.where("title", "welcome")

.includeSchema()

.includeCount()

.toJSON()

.find()

.then((result) => {


})

.catch((error))=> {


});
Note
  • Currently, the JavaScript SDK does not support multiple content types referencing in a single query. For more information on how to query entries and assets, refer the Queries section of our Content Delivery API documentation.
  • By default, the limit for response details per request is 100, with the maximum limit set at 250.

Paginating Responses

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.

const Stack = Contentstack.Stack({ "api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment" });

let blogQuery = Stack.ContentType('example').Query();

blogQuery.skip(20).limit(20).find()

.then((result) => {


}).catch((error))=> {


});

Querying Assets from your stack

To get a single asset, you need to specify the UID of the asset.

const Stack = Contentstack.Stack({ "api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment" });

const Asset = Stack.Asset("asset_uid");

Asset.fetch()

.then((result) => {


}).catch((error))=> {


});

To retrieve multiple assets. You can also specify search parameters to filter results.

const Stack = Contentstack.Stack({ "api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment" });

const Query = Stack.Asset().Query();

Query

.limit(20)

.toJSON()

.find()

.then(function success(result) {


}, function error(err) {


});

Cache Policies

You can set a cache policy on a stack and/or query object.

Setting a cache policy on a stack

This option allows you to globalize a cache policy. This means the cache policy you set will be applied to all the query objects of the stack.

//Setting a cache policy on a stack

Stack.setCachePolicy(Contentstack.CachePolicy.NETWORK_ELSE_CACHE)
Setting a cache policy on a query object

This option allows you to set/override a cache policy on a specific query object.

// setting a cache policy on a queryobject

Query.setCachePolicy(Contentstack.CachePolicy.CACHE_THEN_NETWORK)

Contentstack

Creates an instance of `Contentstack`.

NameTypeDescription
CachePolicy Contentstack.CachePolicy

CachePolicy contains different cache policies constants.

Stack

NameTypeDescription
api_key (required)string

Stack API key

delivery_tokenstring

Stack Delivery token.

environmentstring

Stack Environment name.

regionContentstackRegion | string

DB region for Stack. You can choose from five regions namely, NA, EU, Azure NA, Azure EU, and GCP NA.

branchstring

Name of the branch you want to fetch data from

live_previewobject

Live preview configuration.

fetchOptions.debugboolean

Optional, to enable debug logs set to true.

Default: false
fetchOptions.logHandlerfunction

A log handler function to process given log messages & errors.

fetchOptions.agentHttpProxyAgent
fetchOptions.timeoutnumber

Set timeout for the request.

fetchOptions.retryLimitnumber

The number of retries before failure.

Default: 5
fetchOptions.retryDelaynumber

The number of ms to use for operation retries.

Default: 300ms
fetchOptions.retryConditionfunction

A function to determine if the error can be retried.

Default: Retry is on status codes 408, 429
fetchOptions.retryDelayOptions.basenumber

The base number of milliseconds to use in the exponential backoff for operation retries.

fetchOptions.retryDelayOptions.customBackoffnumber

A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds.

Initialize Stack:

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({ api_key: 'api_key', delivery_token: 'delivery_token', environment: 'environment' });

To set the European, Azure North American, Azure European, or GCP North America region, refer to the code below:

import Contentstack from 'contentstack';

const Stack = new Contentstack({ 'api_key': "api_key", 'delivery_token': "delivery_token", 'environment': "environment", "region": Contentstack.Region.<<add_your_region>>})

For Setting the Branch for a Region.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({ api_key: 'api_key', delivery_token: 'delivery_token', environment: 'environment', region: Contentstack.Region.<<add_your_region>>, host: '<<add_your_host_URL>>', branch: 'branch')

Proxy Configuration

const Stack = Contentstack.Stack({ 
    api_key: 'api_key', 
    delivery_token: 'delivery_token', 
    environment: 'environment',
    URL: URL,
    fetchOptions: {
       fetch: `proxy-url`
    }
});

Here are a few examples of how you can add a username and password to HttpProxyAgent.

  • You can pass it in the URI:
var proxyAgent = new HttpsProxyAgent('https://username:[email protected]');
  • You can set it in the auth option
var proxyOpts = url.parse('https://your-proxy.com');

proxyOpts.auth = 'username:password';

var proxyAgent = new HttpsProxyAgent(proxyOpts);
  • You can even set the HTTP header manually:
var proxyOpts = url.parse('https://your-proxy.com');

proxyOpts.headers = {

  'Proxy-Authentication': 'Basic ' + new Buffer('username:password').toString('base64')

};

var proxyAgent = new HttpsProxyAgent(proxyOpts);

Plugins

When creating custom plugins, through this request, you can pass the detailss of your custom plugins. This facilitates their utilization in subsequent requests when retrieving details.

// custom class for plugin

class CrossStackPlugin {

  onRequest (stack, request) {

    // request modifications

    return request

  }

  async onResponse (stack, request, response, data) {

    // response modifications here

    return response

  }

}


const Stack = Contentstack.Stack({

  api_key,

  delivery_token,

  environment,

  plugins: [

    new CrossStackPlugin(),

    new Livepreview()

  ]

});

Stack

Initialize an instance of ‘Stack’
NameTypeDescription
param.api_key (required)string
Stack API Key.
param.delivery_token (required)string
Stack Delivery token.
param.environment (required)string

Stack Environment name.

setProtocol

Sets the protocol for the host
NameTypeDescription
protocolstring
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

Stack.setProtocol('https');

setHost

Sets the host of the API server

NameTypeDescription
hoststring

Sets the host of the API server

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Stack.setHost('custom.contentstack.com');

setPort

Sets the port of the host
NameTypeDescription
portnumber
import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

SStack.setPort(443);

setCachePolicy

Allows you to set cache policies
NameTypeDescription
keyContentstack.CachePolicyDefault: Contentstack.CachePolicy.ONLY_NETWORK
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Stack.setCachePolicy(Contentstack.CachePolicy.IGNORE_CACHE);

setCacheProvider

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Stack.setCacheProvider({

  get: function (key, callback) {

    try {

        callback(null, <cache_provider>.get(key));

    } catch(e) {

        callback(e);

    }

  },

  set: function (key, value, callback) {

    try {

        if(key && value) <cache_provider>.set(key, value);

        callback();

    } catch(e) {

        callback(e);

    }

  }

});

getCacheProvider

Returns the currently set object of 'CacheProvider'


import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Stack.getCacheProvider();

Assets

Retrieves all assets of a stack by default. To retrieve a single asset, specify its UID.
NameTypeDescription
uidstring

UID of the asset

To get all Assets from the stack:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack;/Assets().Query().toJSON().find();

To specific Asset from the stack with uid:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.Assets('asset_uid').toJSON().find();

ContentType

Set the content type of which you want to retrieve the entries
NameTypeDescription
content_type_uidstring
UID of the existing content type

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.ContentType('content_type_uid').Query().toJSON().find()

getContentTypes

This method returns comprehensive information of all the content types of a particular stack in your account.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Const result = await Stack.getContentTypes({"include_global_field_schema": true});

getLastActivities

getLastActivities get all the ContentTypes whose last activity updated.
import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.getLastActivities().toJSON().fetch();

Taxonomies

Set the base URL to the taxonomies endpoint.

Example:

import Contentstack from 'contentstack';

const stack = Contentstack.stack('api_key', 'delivery_token', 'environment');


let data;

stack

.Taxonomies()

.where("taxonomies.taxonomy_uid", "term_uid")

.toJSON()

.find()

.then(response => {

  // the response

  data = response;

})

Query

An initializer is responsible for creating Query object.Provides support for all search queries

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.ContentType('content_type_uid').Query().toJSON().find();

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.Assets().Query().toJSON().find();

imageTransform

Performs transformations on images of mentioned url based on transformation parameters

NameTypeDescription
urlstring

Image url on which transformations need to be applied.

paramsobject

Object with transformation parameters

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Stack.imageTransform(imageURL, {height: 100, width: 200, disable: "upscale"});
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Stack.imageTransform(imageURL, {crop: "150,100"});
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

Stack.imageTransform(imageURL, {format: "png", crop: "150,100"});

sync

Syncs your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates
NameTypeDescription
param.initboolean
initializing sync
param.localestring
initializing sync with entries of a specific locale
param.start_datestringDefault: initializing sync with entries published after a specific date
param.content_type_uidstring

initializing sync with entries of a specific content type

param.typestring

Use the type parameter to get a specific type of content.Supports 'asset_published', 'entry_published', 'asset_unpublished', 'entry_unpublished', 'asset_deleted', 'entry_deleted', 'content_type_deleted'

param.pagination_tokenstring

Fetching the next batch of entries using pagination token

param.sync_tokenstring

Performing subsequent sync after initial sync

For initializing sync:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.sync({'init': true});

For initializing sync with entries of a specific locale:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.sync({'init': true, 'locale': 'en-us'});

For initializing sync with entries published after a specific date:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.sync({'init': true, 'start_date': '2018-10-22'});

For initializing sync with entries of a specific content type:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.sync({'init': true, 'content_type_uid': 'session'});

For initializing sync with specific type:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.sync({'init': true, 'type': 'entry_published'});

For fetching the next batch of entries using pagination token:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.sync({'pagination_token': '<page_token>'});

For performing subsequent sync after initial sync:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({"api_key": "api_key", "delivery_token": "delivery_token", "environment": "environment"});

const result = await Stack.sync({'sync_token': '<sync_token>'})

Assets

Creates an instance of `Assets`.

Retrieves all assets of a stack by default. To retrieve a single asset, specify its UID.

NameTypeDescription
uid string

UID of asset you want to retrieve

addParam

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.Assets('asset_uid').addParam('include_dimension', 'true').toJSON().fetch()

toJSON

Converts your response into plain JavasScript object

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().toJSON().find()
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.Assets().Query().toJSON().find()
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').toJSON().fetch()
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.Assets('asset_uid').toJSON().fetch()

fetch

Fetches a particular asset based on the provided asset UID.
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.Assets('asset_uid').addParam('include_dimension', 'true').toJSON().fetch()

where

The where() method retrieves the assets from the stack using any other field UID of the assets.

NameTypeDescription
field_name (required)String

Field UID of the Asset

value (required)String

Value of the Asset

Example:

import Contentstack from 'contentstack'

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.Assets().Query().where('field_name', "value").toJSON().find()

Entry

An initializer is responsible for creating Entry object.
NameTypeDescription
uid (required)string

Uid of the entry

language

Sets the language code of which you want to retrieve data.
NameTypeDescription
language_codestring

language code. e.g. 'en-us', 'ja-jp', etc.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').language('language_code').toJSON().fetch();

addParam

Includes query parameters in your queries.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').addParam('include_count', 'true').toJSON().fetch()

addQuery

Adds query to Entry object

NameTypeDescription
keystring

Key of the query

valueany

Value of the query

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').addQuery('include_content_type', true).toJSON().fetch();

only

Displays values of only the specified fields of entries or assets in the response
NameTypeDescription
valuesstring|array

The only function with field_uid will include the data of only the specified fields for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack'; 

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').only('title').toJSON().fetch();

The only function with an array of field_uids will include multiple fields for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').only(['title', 'description']).toJSON().fetch();

In only, we have the only with a reference parameter, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter to include the data of only the specified field_uid for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').only('reference_field_uid','title').toJSON().fetch();

In only, we have the only with a reference parameter with an array, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter with an array of fields to include the data of only the specified array of field_uids for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').only('reference_field_uid',['title', 'description']).toJSON().fetch();

except

Displays all data of an entries or assets excluding the data of the specified fields.
NameTypeDescription
valuesstring|array

The except function with field_uid will exclude the data of only the specified fields for each entry and includes the data of all other fields.

import Contentstack from 'contentstack'; 

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').except('title').toJSON().fetch();

The except function with an array of field_uids will except multiple fields for each entry and include the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').except(['title', 'description']).toJSON().fetch();

In except, we have the only with a reference parameter, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter to except the data of only the specified field_uid for each entry and include the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').except('reference_field_uid','title').toJSON().fetch();

In except, we have the only with a reference parameter with an array, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter with an array of fields to except the data of only the specified array of field_uids for each entry and include the data of all other fields.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').except('reference_field_uid',['title', 'description']).toJSON().fetch();

includeReference

Fetches the entire content of referenced entry.

NameTypeDescription
valuestring|array

Include Reference with reference_field_uids as array:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference(['reference_field_uid','other_reference_field_uid']).toJSON().fetch();

Include Reference with reference_field_uids and its children reference

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference(['reference_field_uid', 'reference_field_uid.child_reference_field_uid']).toJSON().fetch();

Include Reference with reference_field_uid:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').toJSON().fetch();

includeEmbeddedItems

Include Embedded Objects (Entries and Assets) along with entry/entries details.
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeEmbeddedItems().toJSON().fetch();

includeContentType

Include the details of the content type along with the entry/entries details.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeContentType().toJSON().fetch();

includeBranch

Include the Branch for publish content.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeBranch().toJSON().fetch();

includeFallback

Include the fallback locale publish content, if specified locale content is not publish.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

Stack.ContentType('content_type_uid;).Entry('entry_uid').includeFallback().fetch()

Taxonomy

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

NoteAll methods in the Query section are applicable for taxonomy-based filtering as well.

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.

NoteThis query is applicable for the stack.Taxonomies() and stack.ContentType('uid').Query() methods.

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as "taxonomies.<taxonomy_uid>"

value (required)string

UID of the term to match or compare

levelsint

Depth level till which terms will be matched

Example:

let data;

stack

.ContentType('ct_uid')

.Query()

.equalAndBelow("taxonomies.taxonomy_uid", "term_uid", 3)

.toJSON()

.find()

.then(response => {

  // the response

  data = 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.

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

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as "taxonomies.<taxonomy_uid>"

value (required)string

UID of the term to match or compare

levelsint

Depth level till which terms will be matched

Example:

let data;
stack
.ContentType('ct_uid')
.Query()
.below("taxonomies.taxonomy_uid", "term_uid", 3)
.toJSON()
.find()
.then(response => {
  // the response
  data = response;
})

equalAndAbove

The equalAndAbove 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.

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

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as "taxonomies.<taxonomy_uid>"

value (required)string

UID of the term to match or compare

levelsint

Depth level till which terms will be matched

Example:

let data;
stack
.Taxonomies()
.equalAndAbove("taxonomies.taxonomy_uid", "term_uid", 3)
.toJSON()
.find()
.then(response => {
  // the response
  data = 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.

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

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as "taxonomies.<taxonomy_uid>"

value (required)string

UID of the term to match or compare

levelsint

Depth level till which terms will be matched

Example:

let data;
stack
.ContentType('ct_uid')
.Query()
.above("taxonomies.taxonomy_uid", "term_uid", 3)
.toJSON()
.find()
.then(response => {
  // the response
  data = response;
})

Query

An initializer is responsible for creating Query object. Provides support for all search queries

addParam

Includes query parameters in your queries.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().addParam('include_count', 'true').toJSON().find()

notEqualTo

Retrieves entries in which the value for a field does not match the provided value.

NameTypeDescription
keystring

UID of the field

valueany

Value used to match or compare

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().notEqualTo('title', 'some random title').toJSON().find();

containedIn

Retrieve entries in which the value of a field matches with any of the provided array of values

NameTypeDescription
keystring

UID of the field

valuearray

Array of values that are to be used to match or compare

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().containedIn('title', ['Demo', 'Welcome']).toJSON().find();

notContainedIn

Retrieve entries in which the value of a field does not match with any of the provided array of values.

NameTypeDescription
keystring

UID of the field

valuearray

Array of values that are to be used to match or compare

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().notContainedIn('title', ['Demo', 'Welcome']).toJSON().find();

and

Retrieve entries that satisfy all the provided conditions.

NameTypeDescription
queriesarray

array of Query objects or raw queries

and with Query instances:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});


const Query1 = Stack.ContentType('content_type_1').Query().where('title', 'demo');

const Query2 = Stack.ContentType('content_type_1').Query().lessThan('age', 30);


const result = await Stack.ContentType('content_type_uid').Query().and(Query1, Query2).toJSON().find();

and with raw queries:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});


const Query1 = Stack.ContentType('content_type_1').Query().where('title', 'demo').getQuery();

const Query2 = Stack.ContentType('content_type_1').Query().lessThan('age', 30).getQuery();


const result = await Stack.ContentType('content_type_uid').Query().and(Query1, Query2).toJSON().find();

or

Retrieves entries that satisfy at least one of the given conditions

NameTypeDescription
queriesarray

array of Query objects or raw queries

or with Query instances:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});


const Query1 = Stack.ContentType('content_type_1').Query().where('title', 'demo');

const Query2 = Stack.ContentType('content_type_1').Query().lessThan('age', 30);


const result = await Stack.ContentType('content_type_uid').Query().or(Query1, Query2).toJSON().find();

or with raw queries:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});


const Query1 = Stack.ContentType('content_type_1').Query().where('title', 'demo').getQuery();

const Query2 = Stack.ContentType('content_type_1').Query().lessThan('age', 30).getQuery();


const result = await Stack.ContentType('content_type_uid').Query().or(Query1, Query2).toJSON().find();

lessThan

Retrieves entries in which the value of a field is lesser than the provided value

NameTypeDescription
keystring

UID of the field

valueany

Value used to match or compare

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().lessThan('age', 20).toJSON().find();

lessThanOrEqualTo

Retrieves entries in which the value of a field is lesser than or equal to the provided value.

NameTypeDescription
keystring

UID of the field

valueany

Value used to match or compare

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().lessThanOrEqualTo('age', 20).toJSON().find();

greaterThanOrEqualTo

Retrieves entries in which the value for a field is greater than or equal to the provided value.

NameTypeDescription
keystring

UID of the field

valueany

Value used to match or compare

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().greaterThanOrEqualTo('age', 20).toJSON().find();

limit

Returns a specific number of entries based on the set limit

NameTypeDescription
limitnumber

maximum number of entries to be returned

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().limit(20).toJSON().find();

ascending

Sort fetched entries in the ascending order with respect to a specific field.

NameTypeDescription
keystring

field uid based on which the ordering will be done

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().ascending('field_uid').toJSON().find();

descending

Sort fetched entries in the descending order with respect to a specific field

NameTypeDescription
keystring

field uid based on which the ordering will be done

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().descending('field_uid').toJSON().find();

exists

Retrieve entries if value of the field, mentioned in the condition, exists.

NameTypeDescription
keystring

UID of the field

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().exists('field_uid').toJSON().find();

notExists

Retrieve entries if value of the field, mentioned in the condition, does not exists.

NameTypeDescription
keystring

UID of the field

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().notExists('field_uid').toJSON().find();

only

Displays values of only the specified fields of entries or assets in the response
NameTypeDescription
valuesstring|array

The only function with field_uid will include the data of only the specified fields for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack'; 

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().only('title').toJSON().find();

The only function with an array of field_uids will include multiple fields for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().only(['title', 'description']).toJSON().find();

In only, we have the only with a reference parameter, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter to include the data of only the specified field_uid for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReference('reference_field_uid').only('reference_field_uid','title').toJSON().find();

In only, we have the only with a reference parameter with an array, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter with an array of fields to include the data of only the specified array of field_uids for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReference('reference_field_uid').only('reference_field_uid',['title', 'description']).toJSON().find();

except

Displays all data of an entries or assets excluding the data of the specified fields.
NameTypeDescription
valuesstring|array

The except function with field_uid will exclude the data of only the specified fields for each entry and includes the data of all other fields.

import Contentstack from 'contentstack'; 

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().except('title').toJSON().find();

The except function with an array of field_uids will except multiple fields for each entry and include the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().except(['title', 'description']).toJSON().find();

In except, we have the only with a reference parameter, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter to except the data of only the specified field_uid for each entry and include the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReference('reference_field_uid').except('reference_field_uid','title').toJSON().find();

In except, we have the only with a reference parameter with an array, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter with an array of fields to except the data of only the specified array of field_uids for each entry and include the data of all other fields.

import Contentstack from &'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReference('reference_field_uid').except('reference_field_uid',['title', 'description']).toJSON().find();

regex

Retrieve entries that match the provided regular expressions

NameTypeDescription
keystring

uid of the field

valueany
value used to match or compare
optionsany

match or compare value in entry

regex without options

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().regex('title', '^Demo').toJSON().find();

regex with options

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().regex('title', '^Demo', 'i').toJSON().find();

tags

Retrieves entries based on the provided tags

NameTypeDescription
valuesarray

array of tags

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().tags(['technology', 'business']).toJSON().find();

includeReference

Fetches the entire content of referenced entry.

NameTypeDescription
valuestring|array

Include Reference with reference_field_uids as array:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReference(['reference_field_uid','other_reference_field_uid']).toJSON().find();

Include Reference with reference_field_uids and its children reference

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReference(['reference_field_uid', 'reference_field_uid.child_reference_field_uid']).toJSON().find();

Include Reference with reference_field_uid:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReference('reference_field_uid').toJSON().find();

referenceIn

Retrieve entries based on raw queries

NameTypeDescription
fieldUidstring

Reference field Uid

queryobject

RAW (JSON) queries

referenceIn with Query instances

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});


const Query1 = Stack.ContentType('content_type_1').Query().where('title', 'Demo');


const result = await Stack.ContentType('content_type_uid').Query().referenceIn('brand', Query1).toJSON().find();

referenceIn with raw queries:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});


const result = await Stack.ContentType('content_type_uid').Query().referenceIn('brand', {'title': 'Demo'}).toJSON().find();

referenceNotIn

Retrieve entries based on raw queries

NameTypeDescription
fieldUidstring

Reference field Uid

queryobject

RAW (JSON) queries

referenceNotIn with Query instances:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});


const Query1 = Stack.ContentType('content_type_1').Query().where('title', 'Demo');


const result = await Stack.ContentType('content_type_uid').Query().referenceNotIn('brand', Query1).toJSON().find();

referenceNotIn with raw queries:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().referenceNotIn('brand', {'title': 'Demo'}).toJSON().find();

includeReferenceContentTypeUID

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

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeReferenceContentTypeUID().toJSON().find();

includeCount

Includes the total number of entries returned in the response.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeCount().toJSON().find();

includeContentType

Include the details of the content type along with the entry/entries details.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeContentType().toJSON().find();

includeBranch

Include the Branch for publish content.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeBranch().toJSON().find();

includeEmbeddedItems

Include Embedded Objects (Entries and Assets) along with entry/entries details.
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().includeEmbeddedItems().toJSON().find();

includeFallback

Include the fallback locale publish content, if specified locale content is not publish.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

Stack.ContentType('content_type_uid;).Query().includeFallback().fetch()

query

Retrieve entries based on raw queries

NameTypeDescription
queryobject

RAW (JSON) queries

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().query({'brand': {'$nin_query': {'title': 'Apple Inc.'}}}).toJSON().find();

addQuery

Adds query to Entry object

NameTypeDescription
keystring

Key of the query

valueany

Value of the query

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().addQuery('include_content_type', true).toJSON().find();

getQuery

Returns the raw (JSON) query based on the filters applied on Query object.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const rawQuery = await Stack.ContentType('content_type_uid').Query().where('title', 'Demo').getQuery();

language

Sets the language code of which you want to retrieve data.
NameTypeDescription
language_codestring

language code. e.g. 'en-us', 'ja-jp', etc.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().language('language_code').toJSON().find();

find

Retrieves entries that satisfied the specified query

NameTypeDescription
paramobject

Fetch options to fetch particular query

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().toJSON().find();

findOne

Retrieves entries that satisfied the specified query

NameTypeDescription
paramobject

Fetch options to fetch particular query

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().toJSON().findOne();

count

Returns the total number of entries

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Query().count().toJSON().find();

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.

NoteThis query is applicable for the stack.Taxonomies() and stack.ContentType('uid').Query() methods.

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as taxonomies.<taxonomy_uid>

value (required)string

UID of the term to match or compare

levels int

Depth level till which terms will be matched

Example:

let data;

stack

.ContentType('ct_uid')

.Query()

.equalAndBelow("taxonomies.taxonomy_uid", "term_uid", 3)

.toJSON()

.find()

.then(response => {

  // the response

  data = 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.

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

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as taxonomies.<taxonomy_uid>

value (required)string

UID of the term to match or compare

levels int

Depth level till which terms will be matched

Example:

let data;

stack

.ContentType('ct_uid')

.Query()

.below("taxonomies.taxonomy_uid", "term_uid", 3)

.toJSON()

.find()

.then(response => {

  // the response

  data = response;

})

equalAndAbove

The equalAndAbove 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.

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

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as taxonomies.<taxonomy_uid>

value (required)string

UID of the term to match or compare

levels int

Depth level till which terms will be matched

Example:

let data;
stack
.Taxonomies()
.equalAndAbove("taxonomies.taxonomy_uid", "term_uid", 3)
.toJSON()
.find()
.then(response => {
  // the response
  data = 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.

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

NameTypeDescription
key (required)string

UID of the taxonomy field, specified as taxonomies.<taxonomy_uid>

value (required)string

UID of the term to match or compare

levels int

Depth level till which terms will be matched

Example:

let data;
stack
.ContentType('ct_uid')
.Query()
.above("taxonomies.taxonomy_uid", "term_uid", 3)
.toJSON()
.find()
.then(response => {
  // the response
  data = response;
})