Entry
Entry
| Name | Type | Description |
|---|---|---|
| uid (required) | string | Uid of the entry |
language
| Name | Type | Description |
|---|---|---|
| language_code | string | 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.
| Name | Type | Description |
|---|---|---|
| key | String | URL parameter key. |
| value | String | Value corresponding to the parameter. |
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
| Name | Type | Description |
|---|---|---|
| key | string | Key of the query |
| value | any | 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
| Name | Type | Description |
|---|---|---|
| values | string|array | Field UID of content type |
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
| Name | Type | Description |
|---|---|---|
| values | string|array | Field UID of content type |
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.
| Name | Type | Description |
|---|---|---|
| value | string|array | Field UID of content type |
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();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').Entry('entry_uid').includeReferenceContentTypeUID().toJSON().fetch();includeEmbeddedItems
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();Your response should look like this:
[
[
{
"uid": "blt3458ba16457349d2",
"locale": "en-us",
"_in_progress": false,
"created_at": "2024-09-24T21:37:12.148Z",
"created_by": "bltcd145d6b20c55b33",
"title": "Test1",
"updated_at": "2024-11-11T23:56:55.437Z",
"updated_by": "bltcd145d6b20c55b33",
"publish_details": {
"time": "2024-11-11T23:56:59.408Z",
"user": "bltcd145d6b20c55b33",
"environment": "blt47ebc22ff5bb18d9",
"locale": "en-us"
}
}
],
{
"title": "ct1",
"description": "",
"schema": [
{
"data_type": "text",
"display_name": "Title",
"field_metadata": { "_default": true, "version": 3 },
"mandatory": true,
"uid": "title",
"unique": true,
"multiple": false,
"non_localizable": false
}
],
"uid": "ct1",
"created_at": "2024-09-24T21:23:33.625Z",
"updated_at": "2024-09-24T21:24:42.841Z",
"inbuilt_class": false,
"_version": 2
}
]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();fetch
Fetches a particular entry based on the provided entry UID.
| Name | Type | Description |
|---|---|---|
| param | object | Fetch options to fetch particular entry |
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();Variants
Variants are different versions of content designed to meet specific needs or target audiences. This feature allows content editors to create multiple variations of a single entry, each customized for a particular variant group or purpose.
When Personalize creates a variant in the CMS, it assigns a "Variant Alias" to identify that specific variant. When fetching entry variants using the Delivery API, you can pass variant aliases in place of variant UIDs in the x-cs-variant-uid header.
Single Variant: This method retrieves the details of a specific entry variant.
Example:
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').variants('variant_uid/variant_alias').toJSON().fetch()Layering Variants: This method retrieves the details of entry variants based on the applied query
Example:
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').variants(['variant_uid1/variant_alias1','variant_uid2/variant_alias2']).toJSON().fetch()NoteAll methods in the Query section are applicable for variants filtering as well.
Add Query in Variants: This method adds a query to the entry object
Example:
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').variants('variant_uid/variant_alias').addQuery('include_content_type', true).toJSON().fetch()