This document describes the API requests that a custom extension can use to communicate with Contentstack.
You will need to include the contentstack-extension-sdk library in your HTML5 app:
<script src="https://unpkg.com/@contentstack/[email protected]/dist/ui-extension-sdk.js"></script>- ContentstackUIExtension
- Extension
Class representing an extension from Contentstack UI.
- Entry
Class representing an entry from Contentstack UI. Not available for Dashboard Widget extension.
- Field
Class representing a field from Contentstack UI. Only available for Custom Field extension
- Store
Class used by an extension to store your data in localStorage.
- Window
Class representing an iframe window from Contentstack UI. Not available for Custom Widgets.
- Stack
Class representing the current stack in Contentstack UI.
- Query
Creates an instance of the query
- Promise
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
- localStorage
The read-only localStorage property allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions.
Kind: global class
- ContentstackUIExtension
- .SDK_VERSION :
string - .init() ⇒
Promise
- .SDK_VERSION :
Version of Contentstack UI extension.
Kind: static property of ContentstackUIExtension
ContentstackUIExtension.init() ⇒ Promise
You need to first include Contentstack UI Extensions SDK and Contentstack UI Stylesheet in you HTML file and then call ContentstackUIExtension.init in the script tag.
Kind: static method of ContentstackUIExtension
Returns: Promise - A promise object which will be resolved with an instance of the Extension class which is instantiated using the data received from the Contentstack UI.
Example
HTML
<script src="https://unpkg.com/@contentstack/[email protected]/dist/ui-extension-sdk.js"></script>
<link href="https://unpkg.com/@contentstack/[email protected]/dist/ui-extension-sdk.css" rel="stylesheet" >Example (Custom Filed)
// javascript
ContentstackUIExtension.init().then(function (extension) {
var value = extension.field.getData()
extension.field.setData("New Field Data")
})Example (Custom Widget)
// javascript
ContentstackUIExtension.init().then(function (extension) {
var entry = extension.entry.getData()
})Example (Dashboard Widget)
// javascript
ContentstackUIExtension.init().then(function (extension) {
var stack = extension.stack;
var stackData = stack.getData();
})Class representing an extension from Contentstack UI.
Kind: global class
This method gives you the configuration parameters. Check out our UI Extension documentation .
Kind: instance property of Extension
This object holds details of the current user.
Kind: instance property of Extension
type of extension, 'FIELD' || 'WIDGET' || 'DASHBOARD'.
Kind: instance property of Extension
This method gives you the instance configuration parameters set from the content type builder page in the field settings. This is only available for the Custom Field extension.
Kind: instance property of Extension
extension.field : Field
Gives you the extension field object which allows you to interact with the field. Only available for the Custom Field extension.
Kind: instance property of Extension
extension.store : Store
Store to persist data for extension. Note: Data is stored in the browser localStorage and will be lost if the localStorage is cleared in the browser.
Kind: instance property of Extension
extension.entry : Entry
This gives you the entry object which allows you to interact with the current entry. Not available in case of the Dashboard Widget extension.
Kind: instance property of Extension
extension.window : Window
The window object provides users with methods that allow them to adjust the size of the iframe that contains the extension. Not available in case of custom widgets.
Kind: instance property of Extension
extension.stack : Stack
This method returns stack object which allows users to read and manipulate a range of objects in a stack.
Kind: instance property of Extension
Class representing an entry from Contentstack UI. Not available for Dashboard Widget extension.
Kind: global class
- Entry
- .content_type :
Object - .locale :
string - .getData() ⇒
Object - .getField(uid) ⇒
Object - .onSave(callback)
- .onChange(callback)
- .onPublish(callback)
- .onUnPublish(callback)
- .content_type :
Gets the content type of the current entry.
Kind: instance property of Entry
Gets the locale of the current entry.
Kind: instance property of Entry
Gets data of the current entry.
Kind: instance method of Entry
Returns: Object - Returns entry data.
Gets the field object which allows you to interact with the field. This object will support all the methods and properties that work with extension.field. Note: For fields initialized using the getFields function, the setData function currently works only for the following fields: as single_line, multi_line, RTE, markdown, select, number, boolean, date, link, and extension of data type text, number, boolean, and date.
Kind: instance method of Entry
Returns: Object - Field object
| Param | Type | Description |
|---|---|---|
| uid | string |
Unique ID of the field |
Example
var field = entry.getField('field_uid');
var fieldSchema = field.schema;
var fieldUid = field.uid;
var fieldData = field.getData();This function executes the callback function every time an entry is saved.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| callback | function |
The function to be called when an entry is saved. |
This function executes the callback function every time an entry is saved.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| callback | function |
The function to be called when an entry is saved. |
The onChange() function executes the callback function every time an entry has been updated.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| callback | function |
The function to be called when an entry is updated. |
The onPublish() function executes the callback function every time an entry has been published with the respective payload.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| callback | function |
The function to be called when an entry is published. |
The onPublish() function executes the callback function every time an entry has been unpublished with the respective payload.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| callback | function |
The function to be called when an entry is unpublished. |
Class representing a field from Contentstack UI. Only available for Custom Field extension
Kind: global class
- Field
- .uid :
string - .data_type :
string - .schema :
Object - .setData(data) ⇒
Promise - .getData(options) ⇒
Object|string|number - .setFocus() ⇒
Object - .onChange(callback)
- .uid :
The UID of the current field is defined in the content type of the entry.
Kind: instance property of Field
The data type of the current field is set using this method.
Kind: instance property of Field
The schema of the current field (schema of fields such as ‘Single Line Textbox’, ‘Number’, and so on) is set using this method.
Kind: instance property of Field
field.setData(data) ⇒ Promise
Sets the data for the current field.
Kind: instance method of Field
Returns: Promise - A promise object which is resolved when data is set for a field. Note: The data set by this function will only be saved when user saves the entry.
| Param | Type | Description |
|---|---|---|
| data | Object | string | number |
Data to be set on the field |
Gets the data of the current field
Kind: instance method of Field
Returns: Object | string | number - Returns the field data.
| Param | Type | Description |
|---|---|---|
| options | Object |
Options object for get Data method. |
| options.resolved | boolean |
If the resolved parameter is set to true for the File field, then the method will return a resolved asset object along with all the field metadata, e.g. 'field.getData({resolved:true})'. |
Sets the focus for a field when an extension is being used. This method shows user presence and highlights the extension field that the user is currently accessing in Contentstack UI.
Kind: instance method of Field
Returns: Object - A promise object which is resolved when Contentstack UI returns an acknowledgement of the focused state.
The field.onChange() function is called when another extension programmatically changes the data of the current extension field using the field.setData() function. This function is only available for extension fields that support the following data types: text, number, boolean, or date.
Kind: instance method of Field
| Param | Type | Description |
|---|---|---|
| callback | function |
The function to be called when an entry is published. |
Class used by an extension to store your data in localStorage.
Kind: global class
store.get(key) ⇒ Promise
Gets the value of key
Kind: instance method of Store
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the stored data |
Example
extension.store.get('key').then((value) => console.log(value)) // will log value for the given keystore.getAll() ⇒ Promise
Gets an object with all the stored key-value pairs.
Kind: instance method of Store
Example
extension.store.getAll().then((obj) => obj)store.set(key, value) ⇒ Promise
Sets the value of a key
Kind: instance method of Store
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the stored data. |
| value | * |
Data to be stored. |
Example
extension.store.set('key', 'value').then((success) => console.log(success)) // will log ‘true’ when value is setstore.remove(key) ⇒ Promise
Removes the value of a key
Kind: instance method of Store
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the data to be removed from the store |
Example
extension.store.remove('key').then((success) => console.log(success)) // will log ‘true’ when value is removedstore.clear() ⇒ Promise
Clears all the stored data of an extension
Kind: instance method of Store
Example
extension.store.clear().then((success) => console.log(success)) // will log ‘true’ when values are clearedClass representing an iframe window from Contentstack UI. Not available for Custom Widgets.
Kind: global class
window.enableResizing() ⇒ Promise
This method activates the resize button that gives you the provision to resize the window size of your Dashboard Widget.
Kind: instance method of Window
Returns: Promise - A promise object which will resolve when a resize button is visible on the Dashboard Widget.
This function executes the callback function whenever a Dashboard Widget extension is maximized or minimized. Only applicable on Dashboard Widget extensions.
Kind: instance method of Window
Returns: boolean - Will return true
| Param | Type | Description |
|---|---|---|
| callback | function |
Function to be called when a Dashboard Widget extension is maximized or minimized |
window.updateHeight(height) ⇒ Promise
This method updates the extension height on Contentstack UI. If the ‘height’ argument is not passed, it will calculate the scroll height and set the height of extension window accordingly.
Kind: instance method of Window
Returns: Promise - A promise object which will be resolved when Contentstack UI sends an acknowledgement stating that the height has been updated.
| Param | Type | Description |
|---|---|---|
| height | string | number |
Desired height of the iframe window |
window.enableAutoResizing() ⇒ Window
This method enables auto resizing of the extension height.
Kind: instance method of Window
Returns: Window - .
window.disableAutoResizing() ⇒ Window
This method disables auto resizing of the extension height.
Kind: instance method of Window
Returns: Window - .
Class representing the current stack in Contentstack UI.
Kind: global class
- Stack
- .ContentType
- new this.ContentType(uid)
- .Entry
- new Entry()
- instance
- .only([key], values) ⇒
Entry - .except([key], values) ⇒
Entry - .addParam(key, value) ⇒
Entry - .getReferences() ⇒
Promise - .delete() ⇒
Promise - .fetch() ⇒
Promise - .includeReference() ⇒
Entry - .language(languageCode) ⇒
Entry - .environment(environment_uid) ⇒
Entry - .addQuery(key, value) ⇒
Entry - .includeSchema() ⇒
Entry - .includeContentType() ⇒
Entry - .includeOwner() ⇒
Entry - .getLanguages() ⇒
Promise - .unlocalize(locale) ⇒
Promise - .publish(payload) ⇒
Promise - .unpublish(payload) ⇒
Promise - .setWorkflowStage(payload) ⇒
Promise - .update(payload, [locale]) ⇒
Promise
- .only([key], values) ⇒
- static
- .Asset
- new this.Asset(uid)
- instance
- static
- .getData() ⇒
Object - .getContentType(uid, params) ⇒
Object - .getContentTypes(query, params) ⇒
Object - .getEnvironment(name, params) ⇒
Object - .getEnvironments(query, params) ⇒
Object - .getLocale(code, params) ⇒
Object - .getLocales(query, params) ⇒
Object
- .ContentType
Kind: instance class of Stack
See: ContentType
Version: 2.0.0
- .ContentType
- new this.ContentType(uid)
- .Entry
- new Entry()
- instance
- .only([key], values) ⇒
Entry - .except([key], values) ⇒
Entry - .addParam(key, value) ⇒
Entry - .getReferences() ⇒
Promise - .delete() ⇒
Promise - .fetch() ⇒
Promise - .includeReference() ⇒
Entry - .language(languageCode) ⇒
Entry - .environment(environment_uid) ⇒
Entry - .addQuery(key, value) ⇒
Entry - .includeSchema() ⇒
Entry - .includeContentType() ⇒
Entry - .includeOwner() ⇒
Entry - .getLanguages() ⇒
Promise - .unlocalize(locale) ⇒
Promise - .publish(payload) ⇒
Promise - .unpublish(payload) ⇒
Promise - .setWorkflowStage(payload) ⇒
Promise - .update(payload, [locale]) ⇒
Promise
- .only([key], values) ⇒
- static
Content type defines the structure or schema of a page or a section of your web or mobile property
| Param | Type | Description |
|---|---|---|
| uid | string |
Uid of contenttype. |
Example
extension.stack.ContentType('content_type_uid')Kind: instance class of ContentType
See: Entries
Version: 2.0.0
- .Entry
- new Entry()
- instance
- .only([key], values) ⇒
Entry - .except([key], values) ⇒
Entry - .addParam(key, value) ⇒
Entry - .getReferences() ⇒
Promise - .delete() ⇒
Promise - .fetch() ⇒
Promise - .includeReference() ⇒
Entry - .language(languageCode) ⇒
Entry - .environment(environment_uid) ⇒
Entry - .addQuery(key, value) ⇒
Entry - .includeSchema() ⇒
Entry - .includeContentType() ⇒
Entry - .includeOwner() ⇒
Entry - .getLanguages() ⇒
Promise - .unlocalize(locale) ⇒
Promise - .publish(payload) ⇒
Promise - .unpublish(payload) ⇒
Promise - .setWorkflowStage(payload) ⇒
Promise - .update(payload, [locale]) ⇒
Promise
- .only([key], values) ⇒
- static
An entry is the actual piece of content created using one of the defined content types
entry.only([key], values) ⇒ Entry
This method is used to show the selected fields of an entry in the result set.
Kind: instance method of Entry
| Param | Type | Default | Description |
|---|---|---|---|
| [key] | String |
BASE |
Single field of an entry |
| values | Array |
Array of fields to be shown in the result set |
Example ( Only with field UID )
extension.stack.ContentType('content_type_uid').Entry('bltsomething123').only('title').fetch();Example ( Only with field UID )
extension.stack.ContentType('content_type_uid').Entry('bltsomething123').only('BASE','title').fetch();Example ( Only with field UIDs(array) )
extension.stack.ContentType('content_type_uid').Entry('bltsomething123').only(['title','description']).fetch();entry.except([key], values) ⇒ Entry
This method is used to hide the selected fields of an entry in the result set.
Kind: instance method of Entry
| Param | Type | Default | Description |
|---|---|---|---|
| [key] | String |
BASE |
Single field of an entry |
| values | Array |
Array of fields to be hidden in the result set |
Example ( Except with field uid )
extension.stack.ContentType('content_type_uid').Entry('bltsomething123').except('title').fetch();Example ( Except with field uid )
extension.stack.ContentType('content_type_uid').Entry('bltsomething123').except('BASE','title').fetch();Example ( Except with field uids(array) )
extension.stack.ContentType('content_type_uid').Entry('bltsomething123').except(['title','description']).fetch();entry.addParam(key, value) ⇒ Entry
This method includes a query parameter in your query.
Kind: instance method of Entry
Returns: Entry - Returns
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the parameter |
| value | string |
Value of the parameter |
Example
extension.stack.ContentType('content_type_uid').Entry('uid').addParam('include_count', 'true').fetch().then().catch();entry.getReferences() ⇒ Promise
This method will fetch all the entries in which the current entry is referenced.
Kind: instance method of Entry
Returns: Promise - Required data if resolved successfully
See: {@link
https://www.contentstack.com/docs/apis/content-management-api/#get-all-references-of-an-entry|
Entry References}
Example
extension.stack.ContentType('content_type_uid').Entry('uid').getReferences().then().catch();
entry.delete() ⇒ Promise
This method deletes an existing entry.
Kind: instance method of Entry
Returns: Promise - Required data if resolved successfully
See: {@link
https://www.contentstack.com/docs/apis/content-management-api/#delete-an-entry|
Delete Entry}
Example
extension.stack.ContentType('content_type_uid').Entry('uid').delete().then().catch();
entry.fetch() ⇒ Promise
This method fetches information of a specific entry.
Kind: instance method of Entry
Returns: Promise - Required data if resolved successfully
See: {@link
https://www.contentstack.com/docs/apis/content-management-api/#get-a-single-an-entry|
Get A Single Entry}
Example
extension.stack.ContentType('content_type_uid').Entry('uid').fetch().then().catch();
entry.includeReference() ⇒ Entry
This method is used to include referenced entries from other content types.
Kind: instance method of Entry
Example ( .includeReference with reference_field_uids as array )
stack.ContentType('contenttype_uid').Entry('bltsomething123').includeReference(['category', 'author']).fetch()Example ( .includeReference with reference_field_uids )
stack.ContentType('contenttype_uid').Entry('bltsomething123').includeReference('category', 'author').fetch()entry.language(languageCode) ⇒ Entry
This method is used to set the language code of which you want to retrieve the data.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| languageCode | String |
Language code, for e.g. 'en-us', 'ja-jp', and so on |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').language('en-us').fetch()entry.environment(environment_uid) ⇒ Entry
This method is used to set the environment name of which you want to retrieve the data.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| environment_uid | String |
UID/Name of environment |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').environment('development').fetch()entry.addQuery(key, value) ⇒ Entry
This method is used to add a query to an entry object.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| key | String |
Key of the query |
| value | String |
Value of the query |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').addQuery('include_schema',true).fetch()entry.includeSchema() ⇒ Entry
This method is used to include the schema of the current contenttype in result set along with the entry/entries.
Kind: instance method of Entry
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').includeSchema().fetch()entry.includeContentType() ⇒ Entry
This method is used to include the current content type in the result set along with the entry(ies).
Kind: instance method of Entry
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').includeContentType().fetch()entry.includeOwner() ⇒ Entry
This method is used to include the owner of the entry(ies) in the result set.
Kind: instance method of Entry
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').includeOwner().fetch()entry.getLanguages() ⇒ Promise
This method returns the details of all the languages that an entry is localized in.
Kind: instance method of Entry
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').getLanguages()entry.unlocalize(locale) ⇒ Promise
This method is used to unlocalize an entry
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| locale | string |
Locale in which the entry has to be unlocalized |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').unlocalize('fr-fr').then(...).catch(...);entry.publish(payload) ⇒ Promise
This method lets you publish an entry either immediately or schedule it to be published automatically at a later date/time.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| payload | object |
Payload for the request |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').publish({
"entry": {
"environments": ["development"],
"locales": ["en-us"]
},
"locale": "en-us",
"version": 1,
"scheduled_at": "2019-02-14T18:30:00.000Z"
}).then(...).catch(...);entry.unpublish(payload) ⇒ Promise
This method lets you publish an entry either immediately or schedule it to be published automatically at a later date/time.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| payload | object |
Payload for the request |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').unpublish({
"entry": {
"environments": ["development"],
"locales": ["en-us"]
},
"locale": "en-us",
"version": 1,
"scheduled_at": "2019-02-14T18:30:00.000Z"
}).then(...).catch(...);entry.setWorkflowStage(payload) ⇒ Promise
This method allows you to either set a particular workflow stage or update the workflow stage details of an entry.
Kind: instance method of Entry
| Param | Type | Description |
|---|---|---|
| payload | object |
Payload for the request |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').setWorkflowStage({
"workflow": {
"workflow_stage": {
"comment": "Test Comment",
"due_date": "Thu Dec 01 2018",
"notify": false,
"uid": "blt9f52a2cd5e0014fb",
"assigned_to": [{
"uid": "blt296a22e28cc0c63c",
"name": "John Doe",
"email": "[email protected]"
}],
"assigned_by_roles": [{
"uid": "blt5b74c24c7ae25d94",
"name": "Content Manager"
}]
}
}
}).then(...).catch(...);entry.update(payload, [locale]) ⇒ Promise
This call allows you to update entry content.
Kind: instance method of Entry
See: Update Entry
| Param | Type | Description |
|---|---|---|
| payload | object |
Payload for the request |
| [locale] | string |
Passing the ‘locale’ parameter will localize the entry in the specified locale to be localized in the specified locale. |
Example
extension.stack.ContentType('contenttype_uid').Entry('bltsomething123').update(
{
"entry": {
"title": "example",
"url": "/example"
}
}).then(...).catch(...);Entry.Query() ⇒ Query
This static method instantiates the query module for entries. To see the list of methods that can be used for querying entries, refer the Query module.
Kind: static method of Entry
Example
let entryQuery = extension.stack.ContentType('content_type_uid').Entry.Query();
entryQuery.where("field_uid": "10").limit(10).skip(10).find().then(...).catch(...);Entry.create(payload) ⇒ Promise
This method creates a new entry.
Kind: static method of Entry
Returns: Promise - Required data if resolved successfully
See: {@link
https://www.contentstack.com/docs/apis/content-management-api/#create-a-an-entry|
Create Entry}
| Param | Type | Description |
|---|---|---|
| payload | Object |
Data to create an entry |
Example
extension.stack.ContentType('content_type_uid').Entry.create({
"entry": {
"title": "example",
"url": "/example"
}
}).then(...).catch(...);
Kind: instance class of Stack
See: Asset
Version: 2.0.0
- .Asset
- new this.Asset(uid)
- instance
- static
An initializer is responsible for creating an Asset object.
| Param | Type | Description |
|---|---|---|
| uid | string |
UID of the asset. |
Example
extension.stack.Asset('asset_uid')asset.only([key], values) ⇒ Asset
This method is used to show the selected fields of the assets in the result set.
Kind: instance method of Asset
| Param | Type | Default | Description |
|---|---|---|---|
| [key] | String |
BASE |
Single field of an asset |
| values | Array |
Array of fields to be shown in the result set |
Example ( Only with the field UID )
extension.stack.Asset('bltsomething123').only('title').fetch();Example ( Only with the field UID )
extension.stack.Asset('bltsomething123').only('BASE','title').fetch();Example ( Only with the field UIDs(array) )
extension.stack.Asset('bltsomething123').only(['title','description']).fetch();asset.except([key], values) ⇒ Asset
This method is used to hide the selected fields of the assets in result set.
Kind: instance method of Asset
| Param | Type | Default | Description |
|---|---|---|---|
| [key] | String |
BASE |
Single field of an asset |
| values | Array |
Array of fields to be hidden in the result set |
Example ( .Except with the field UID )
extension.stack.Asset('bltsomething123').except('title').fetch();Example ( .Except with the field UID )
extension.stack.Asset('bltsomething123').except('BASE','title').fetch();Example ( .Except with the field UIDs(array) )
extension.stack.Asset('bltsomething123').except(['title','description']).fetch();asset.environment(environment_uid) ⇒ Asset
This method is used to set the environment name of which you want to retrieve the data.
Kind: instance method of Asset
| Param | Type | Description |
|---|---|---|
| environment_uid | String |
UID/Name of environment |
Example
extension.stack.Asset('bltsomething123').environment('development').fetch()asset.addParam(key, value) ⇒ Asset
This method includes a query parameter in your query.
Kind: instance method of Asset
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the parammeter |
| value | string |
Value of the parammeter |
Example
extension.stack.Asset('uid').addParam('key', 'value').fetch().then().catch();
asset.addQuery(key, value) ⇒ Asset
This method includes a query parameter in your query.
Kind: instance method of Asset
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the parammeter |
| value | string |
Value of the parammeter |
Example
extension.stack.Asset('uid').addQuery('key', 'value').fetch().then().catch();
asset.getReferences() ⇒ Promise
This method will fetch the details of the entries and the assets in which the specified asset is referenced.
Kind: instance method of Asset
See: {@link
https://www.contentstack.com/docs/apis/content-management-api/#get-all-references-of-asset|
Asset References}
Example
extension.stack.Asset('uid').getReferences().then().catch();
asset.delete() ⇒ Promise
This method deletes an existing asset.
Kind: instance method of Asset
See: {@link
https://www.contentstack.com/docs/apis/content-management-api/#delete-an-asset|
Delete Asset}
Example
extension.stack.Asset('uid').delete().then().catch();
asset.publish(payload) ⇒ Promise
This method allows you to publish the asset either immediately or schedule the publish for a later date/time.
Kind: instance method of Asset
| Param | Type | Description |
|---|---|---|
| payload | object |
Payload for the request. |
Example
extension.stack.Asset('bltsomething123')
.publish(
{
"asset": {
"locales": [
"en-us"
],
"environments": [
"development"
]
},
"version": 1,
"scheduled_at": "2019-02-08T18:30:00.000Z"
});asset.unpublish(payload) ⇒ Promise
This method will instantly unpublish the asset, and also give you the provision to automatically unpublish the asset at a later date/time.
Kind: instance method of Asset
| Param | Type | Description |
|---|---|---|
| payload | object |
Payload for the request. |
Example
extension.stack.Asset('bltsomething123')
.unpublish({
"asset": {
"locales": [
"en-us"
],
"environments": [
"development"
]
},
"version": 1,
"scheduled_at": "2019-02-08T18:30:00.000Z"
});Asset.Query() ⇒ Query
This static method instantiates the query module for assets. To see the list of methods that can be used for querying assets, refer the Query module.
Kind: static method of Asset
Example
let assetQuery = extension.stack.Asset.Query();
assetQuery.where("title": "main.js").limit(10).skip(10).find().then(...).catch(...);Asset.getRteAssets() ⇒ Promise
This static method retrieves comprehensive information on all assets uploaded through the Rich Text Editor field.
Kind: static method of Asset
Asset.getAssetsOfSpecificTypes(assetType) ⇒ Promise
This static method retrieves assets that are either image or video files, based on the request query.
Kind: static method of Asset
| Param | Type | Description |
|---|---|---|
| assetType | String |
Type of asset to be received for e.g., ‘image/png’ |
This method returns the data of the current stack.
Kind: instance method of Stack
Returns: Object - Returns stack data.
This API allows you to retrieve data of a content type of a stack using the Content Type API requests. This method returns a Promise object.
Kind: instance method of Stack
Returns: Object - A promise object which will be resolved with content type details.
| Param | Type | Description |
|---|---|---|
| uid | string |
Uid of the desired content type |
| params | Object |
Optional parameters for the GET call |
This API allows you to retrieve data of a content types of a stack using the Content Types API requests. This method returns a Promise object.
Kind: instance method of Stack
Returns: Object - A promise object which will be resolved with details of the content type.
| Param | Type | Description |
|---|---|---|
| query | Object |
Query for the GET call |
| params | Object |
Optional parameters for the GET call |
This API allows you to retrieve environment details of a stack using the Environment API requests. This method returns a Promise object.
Kind: instance method of Stack
Returns: Object - A promise object which will be resolved with environment details.
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the desired environment |
| params | Object |
Optional parameters for the GET call |
This API allows you to retrieve details of environments of a stack using the Environments API requests. This method returns a Promise object.
Kind: instance method of Stack
Returns: Object - A Promise object which will be resolved with details of the environments.
| Param | Type | Description |
|---|---|---|
| query | Object |
Query for the GET call |
| params | Object |
Optional parameters for the GET call |
This API allows you to retrive a locale of a stack using the Language API requests. Method returns a Promise object.
Kind: instance method of Stack
Returns: Object - A promise object which will be resolved with locale details.
| Param | Type | Description |
|---|---|---|
| code | string |
Code of the desired locale |
| params | Object |
Optional parameters for the GET call |
This API allows you to retrive the locales of a stack using the Languages API requests. Method returns a Promise object.
Kind: instance method of Stack
Returns: Object - A Promise object which will be resolved with details of the locales.
| Param | Type | Description |
|---|---|---|
| query | Object |
Query for the GET call |
| params | Object |
Optional parameters for the GET call |
Creates an instance of the query
Kind: global class
Version: 2.2.0
- Query
- .lessThan ⇒
Query - .lessThanOrEqualTo ⇒
Query - .only([key], values) ⇒
Query - .except([key], values) ⇒
Query - .addQuery(key, value) ⇒
Query - .greaterThan(key, value) ⇒
Query - .greaterThanOrEqualTo(key, value) ⇒
Query - .notEqualTo(key, value) ⇒
Query - .containedIn(key, value) ⇒
Query - .notContainedIn(key, value) ⇒
Query - .exists(key) ⇒
Query - .notExists(key) ⇒
Query - .ascending(key) ⇒
Query - .descending(key) ⇒
Query - .skip(skip) ⇒
Query - .limit(limit) ⇒
Query - .or(Array) ⇒
Query - .and(Array) ⇒
Query - .addParam(key, value) ⇒
Query - .includeReference() ⇒
Query - .includeSchema() ⇒
Query - .language(languageCode) ⇒
Query - .includeContentType() ⇒
Query - .includeOwner() ⇒
Query - .environment(environment_uid) ⇒
Query - .equalTo(key, value) ⇒
Query - .count() ⇒
Query - .query(query) ⇒
Query - .tags(values) ⇒
Query - .includeCount() ⇒
Query - .getQuery() ⇒
Query - .regex(key, value, [options]) ⇒
Query - .search(value) ⇒
Query - .find()
- .findOne()
- .lessThan ⇒
query.lessThan ⇒ Query
This method provides only the entries with values less than the specified value for a field.
Kind: instance property of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
The value used to match or compare |
Example
extension.stack.ContentType('blog').lessThan('created_at','2015-06-22')query.lessThanOrEqualTo ⇒ Query
This method provides only the entries with values less than or equal to the specified value for a field.
Kind: instance property of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
The value used to match or compare |
Example
extension.stack.ContentType('blog').lessThanOrEqualTo('created_at','2015-03-12')query.only([key], values) ⇒ Query
This method is used to show the selected fields of an entry in the result set.
Kind: instance method of Query
| Param | Type | Default | Description |
|---|---|---|---|
| [key] | String |
BASE |
Single field of an entry |
| values | Array |
Array of fields to be shown in the result set |
Example ( Only with field UID )
extension.stack.ContentType('content_type_uid').Entry.Query().only('title').find();Example ( Only with field UID )
extension.stack.ContentType('content_type_uid').Entry.Query().only('BASE','title').find();Example ( Only with field UIDs(array) )
extension.stack.ContentType('content_type_uid').Entry.Query().only(['title','description']).find();query.except([key], values) ⇒ Query
This method is used to hide the selected fields of an entry in the result set.
Kind: instance method of Query
| Param | Type | Default | Description |
|---|---|---|---|
| [key] | String |
BASE |
Single field of an entry |
| values | Array |
Array of fields to be hidden in the result set |
Example ( Except with field uid )
extension.stack.ContentType('content_type_uid').Entry.Query().except('title').find();Example ( Except with field uid )
extension.stack.ContentType('content_type_uid').Entry.Query().except('BASE','title').find();Example ( Except with field uids(array) )
extension.stack.ContentType('content_type_uid').Entry.Query().except(['title','description']).find();query.addQuery(key, value) ⇒ Query
This method includes a query parameter in your query.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the parammeter |
| value | string |
Value of the parammeter |
Example
extension.stack.ContentType('content_type_uid').Entry.Query().addQuery('key', 'value').find().then().catch();
query.greaterThan(key, value) ⇒ Query
This method provides only the entrieswith values greater than the specified value for a field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
The value used to match or compare |
Example
extension.stack.ContentType('blog').greaterThan('created_at','2015-03-12')query.greaterThanOrEqualTo(key, value) ⇒ Query
This method provides only the entries with values greater than or equal to the specified value for a field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
The value used to match or compare |
Example
extension.stack.ContentType('blog').greaterThanOrEqualTo('created_at', '2015-06-22')query.notEqualTo(key, value) ⇒ Query
This method provides only the entries with values not equal to the specified value for a field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
The value used to match or compare |
Example
extension.stack.ContentType('blog').notEqualTo('title','Demo')query.containedIn(key, value) ⇒ Query
This method provides only the entries with values matching the specified values for a field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
An array of values that are to be used to match or compare |
Example
extension.stack.ContentType('blog').containedIn('title', ['Demo', 'Welcome'])query.notContainedIn(key, value) ⇒ Query
This method provides only the entries that do not contain values matching the specified values for a field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | Array |
An array of values that are to be used to match or compare |
Example
extension.stack.ContentType('blog').notContainedIn('title', ['Demo', 'Welcome'])query.exists(key) ⇒ Query
This method provides only the entries that contains the field matching the specified field UID.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
Example
extension.stack.ContentType('blog').exists('featured')query.notExists(key) ⇒ Query
This method provides only the entries that do not contain the field matching the specified field UID.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
Example
extension.stack.ContentType('blog').notExists('featured')query.ascending(key) ⇒ Query
This parameter sorts the entries in ascending order on the basis of the value of the specified field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
Field UID to be used for sorting. |
Example
extension.stack.ContentType('blog').ascending('created_at')query.descending(key) ⇒ Query
This method sorts the entries in descending order on the basis of the specified field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
Field UID to be used for sorting |
Example
extension.stack.ContentType('blog').descending('created_at')query.skip(skip) ⇒ Query
This method skips the specified number of entries.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| skip | Number |
Number of entries to be skipped |
Example
extension.stack.ContentType('blog').skip(5)query.limit(limit) ⇒ Query
This method limits the response by providing only the specified number of entries.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| limit | Number |
Maximum number of entries to be returned in the result. |
Example
extension.stack.ContentType('blog').limit(10)query.or(Array) ⇒ Query
This method performs the OR operation on the specified query objects and provides only the matching entries.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| Array | object |
of query objects/raw queries to be taken into consideration |
Example ( OR with query instances)
let Query1 = extension.stack.ContentType('blog').Entry.Query().where('title', 'Demo')
let Query2 = extension.stack.ContentType('blog').Entry.Query().lessThan('comments', 10)
let blogQuery = extension.stack.ContentType('blog').or(Query1, Query2)Example ( OR with query instances)
let Query1 = extension.stack.ContentType('blog').Entry.Query().where('title', 'Demo').getQuery()
let Query2 = extension.stack.ContentType('blog').Entry.Query().lessThan('comments', 10).getQuery()
let blogQuery = extension.stack.ContentType('blog').or(Query1, Query2)query.and(Array) ⇒ Query
This method performs the AND operation on the specified query objects and provides only the matching entries.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| Array | object |
of query objects/raw queries to be taken into consideration |
Example ( AND with raw queries)
let Query1 = extension.stack.ContentType('blog').Entry.Query().where('title', 'Demo');
let Query2 = extension.stack.ContentType('blog').Entry.Query().lessThan('comments', 10);
let blogQuery = extension.stack.ContentType('blog').and(Query1, Query2)Example ( .and with raw queries)
let Query1 = extension.stack.ContentType('blog').Entry.Query().where('title', 'Demo').getQuery();
let Query2 = extension.stack.ContentType('blog').Entry.Query().lessThan('comments', 10).getQuery();
let blogQuery = extension.stack.ContentType('blog').and(Query1, Query2)query.addParam(key, value) ⇒ Query
This method includes a query parameter in your query.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | string |
Key of the parammeter |
| value | string |
Value of the parammeter |
Example
extension.stack.ContentType('content_type_uid').Entry.Query().addParam('key', 'value').find().then().catch();
query.includeReference() ⇒ Query
This method is used to include referenced entries from other content types. Note: This method is only valid for querying Entry.
Kind: instance method of Query
Example ( .includeReference with reference_field_uids as array )
stack.ContentType('contenttype_uid').Entry.Query().includeReference(['category', 'author']).find()Example ( .includeReference with reference_field_uids )
stack.ContentType('contenttype_uid').Entry.Query().includeReference('category', 'author').find()query.includeSchema() ⇒ Query
This method is used to include the schema of the current contenttype in result set along with the entry/entries. Note: This method is only valid for querying Entry.
Kind: instance method of Query
Example
extension.stack.ContentType('contenttype_uid').Entry.Query().includeSchema().find()query.language(languageCode) ⇒ Query
This method is used to set the language code of which you want to retrieve the data. Note: This method is only valid for querying Entry.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| languageCode | String |
Language code, for e.g. 'en-us', 'ja-jp', and so on |
Example
extension.stack.ContentType('contenttype_uid').Entry.Query().language('en-us').find()query.includeContentType() ⇒ Query
This method is used to include the current content type in the result set along with the entry(ies). Note: This method is only valid for querying Entry.
Kind: instance method of Query
Example
extension.stack.ContentType('contenttype_uid').Entry.Query().includeContentType().find()query.includeOwner() ⇒ Query
This method is used to include the owner of the entry(ies) in the result set. Note: This method is only valid for querying Entry.
Kind: instance method of Query
Example
extension.stack.ContentType('contenttype_uid').Entry.Query().includeOwner().find()query.environment(environment_uid) ⇒ Query
This method is used to set the environment name of which you want to retrieve the data.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| environment_uid | String |
UID/Name of environment |
Example
extension.stack.ContentType('contenttype_uid').Entry.Query().environment('development').find()query.equalTo(key, value) ⇒ Query
This method provides only the entries containing field values matching the specified condition.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
The value used to match or compare |
Example
extension.stack.ContentType('blog').where('title','Demo')query.count() ⇒ Query
This method provides only the number of entries matching the specified filters.
Kind: instance method of Query
Example
extension.stack.ContentType('blog').count()query.query(query) ⇒ Query
This method is used to set raw queries on the Query instance.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| query | object |
Raw{json} queries to filter the entries in the result set. |
query.tags(values) ⇒ Query
The ’tags’ parameter allows you to specify an array of tags to search for objects.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| values | Array |
Tags |
Example
extension.stack.ContentType('blog').tags(['technology', 'business'])query.includeCount() ⇒ Query
This method also includes the total number of entries returned in the response.
Kind: instance method of Query
Example
extension.stack.ContentType('blog').includeCount()query.getQuery() ⇒ Query
This method provides raw{json} queries based on the filters applied on the Query object.
Kind: instance method of Query
Summary: returns Returns the raw query which can be used for further calls (.and/.or).
Example
extension.stack.ContentType('blog').where('title','Demo').getQuery()query.regex(key, value, [options]) ⇒ Query
This method provides only the entries matching the regular expression for the specified field.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| key | String |
UID of the field |
| value | * |
The value used to match or compare |
| [options] | String |
Match or compare a value in the entry |
Example ( .regex without options)
let blogQuery = extension.stack.ContentType('blog').regex('title','^Demo')Example ( .regex with options)
let blogQuery = extension.stack.ContentType('blog').regex('title','^Demo', 'i')query.search(value) ⇒ Query
This method is used to search data in entries.
Kind: instance method of Query
| Param | Type | Description |
|---|---|---|
| value | string |
Value to search in the entries. |
Example
extension.stack.ContentType('blog').search('Welcome to demo')This method provides all the entries which satisfy the specified query.
Kind: instance method of Query
Example
let blogQuery = extension.stack.ContentType('blog').find()This method provides a single entry from the result set.
Kind: instance method of Query
Example
let blogQuery = extension.stack.ContentType('blog').findOne()The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
Kind: global external
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
The read-only localStorage property allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions.
Kind: global external
See: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage