Creates a Delivery API Client instance. You must provide a configuration object with the required details for the particular service you wish to fetch content from.
Client configuration options
Client configuration options
This function will help construct requests for fetching multiple Content Items or Slots by delivery key or ID. Wraps /content/fetch
endpoint.
Additional documentation
The type of content returned. This is optional and by default the content returned is assumed to be “any”.
The request body. Can include per item parameters as well as global parameters
Promise<FetchResponse<Body>>
This function will help construct requests for filtering Content Items or Slots
json path to property you wish to filter by e.g /_meta/schema
value you want to return matches for
FilterBy<Body>
This function will help construct requests for filtering Content Items or Slots
equivalent to:
client.filterBy('/_meta/schema', contentTypeUri)
Content Type Uri you want to filter
FilterBy<Body>
This function will help construct requests for filtering Content Items or Slots
equivalent to:
client.filterBy('/_meta/hierarchy/parentId', id)
ID of a Hierarchy Content Item
FilterBy<Body>
This function will help construct requests for filtering Content Items or Slots
API options for /content/filter
endpoint docs
This function will load a hierarchy and return the root item with any children attached, it will also fetch the root item if needed.
parameters for the hierarchies request see ContentClientHierarchyRequest
This function will load a hierarchy and return the root item with any children attached, it will also fetch the root item if needed.
parameters for the hierarchies request see ContentClientHierarchyRequest
the function that is applied to filter the tree, elements are removed on a truthy result
This function will load a hierarchy and return the root item with any children attached, it will also fetch the root item if needed.
parameters for the hierarchies request see ContentClientHierarchyRequest
the function that is applied to the content body while building the hierarchy
This function will load a Content Item or Slot by id and return a Promise of the result. If the content is not found the promise will reject with an error. If the content is found the promise will resolve with a parsed version of the content with all dependencies.
The content body will match the format defined by your content type, however keep in mind that if you have evolved your content type some published content may still be in the older format.
Some pre-processing is applied to the content body to make it easier to work with:
You can convert the content back to plain JSON by calling the toJSON() function on the returned ContentItem.
The type of content returned. This is optional and by default the content returned is assumed to be “any”.
Unique id of the Content Item or Slot to load
This function will load a Content Item or Slot by key and return a Promise of the result. If the content is not found the promise will reject with an error. If the content is found the promise will resolve with a parsed version of the content with all dependencies.
A delivery key can be a simple string or a path such as "home-page/feature-banner". This makes it simpler to write your integration code and allows users more control over where items of content are delivered. You can add a delivery key to a slot in the Dynamic Content app or to a content item or slot using the Dynamic Content Management API. Note that a delivery key may not start or end with "/" and must be between 1 and 150 characters. Delivery keys can contain the following alphanumeric characters: a to z, A to Z and 0 to 9. You can also include "-" and "_" and "/" as long as it is not included at the start or end of the key.
The content body will match the format defined by your content type.
Some pre-processing is applied to the content body to make it easier to work with:
You can convert the content back to plain JSON by calling the toJSON() function on the returned ContentItem.
The type of content returned. This is optional and by default the content returned is assumed to be “any”.
This function will help construct requests for fetching multiple Content Items or Slots by delivery key and/or id and is equivalent to:
client.fetchContentItems({
parameters: {
depth: 'all',
format: 'inlined'
},
requests: [
{ id: '6cd4de36-591b-4ca2-874b-1dec7b681d7e' },
{ key: 'blog/article-1' },
],
});
The type of content returned. This is optional and by default the content returned is assumed to be “any”.
An array of delivery IDs of the content you wish to fetch
Optional override of default parameters
Promise<FetchResponse<Body>>
These functions will help construct requests for fetching multiple Content Items or Slots by delivery ID and is equivalent to:
client.fetchContentItems({
parameters: {
depth: 'all',
format: 'inlined'
},
requests: [
{ id: '6cd4de36-591b-4ca2-874b-1dec7b681d7e' },
{ id: 'c6d9e038-591b-4ca2-874b-da354f5d6e61' },
],
});
The type of content returned. This is optional and by default the content returned is assumed to be “any”.
Promise<FetchResponse<Body>>
This function will help construct requests for fetching multiple Content Items or Slots by delivery key and is equivalent to:
client.fetchContentItems({
parameters: {
depth: 'all',
format: 'inlined'
},
requests: [
{ key: 'blog/article-1' },
{ key: 'blog/article-2' },
],
});
The type of content returned. This is optional and by default the content returned is assumed to be “any”.
An array of delivery IDs of the content you wish to fetch
Promise<FetchResponse<Body>>
This function will help construct requests for filtering Content Items or Slots
equivalent to:
client.lookUpBy(key, value)
the key for the lookup eg: HIERARCHY_PARENT_META_DELIVERY_KEY
the value for the lookup
FilterBy<Body>
This function will help construct requests for filtering Content Items or Slots
equivalent to:
client.lookUpBy('HIERARCHY_PARENT_META_DELIVERY_KEY', deliveryKey)
ID of a Hierarchy Content Item
FilterBy<Body>
Converts a Content Item or Slot into a custom format (e.g. HTML / XML) by applying a template server side.
Unique id of the Content Item or Slot to convert using the rendering service
Name of the template to render the content item or slot with. The template must be setup in your account
Custom parameters which will be sent to the rendering API and made avaliable to your template
Generated using TypeDoc
Amplience Content Delivery API client.
This client is intended to be used by end user applications to fetch content so that it can be displayed to users.
You must provide some configuration options in order to create an instance of ContentClient. Example:
const client = new ContentClient({ account: 'test' });
You may override other settings when constructing the client but if no additional configuration is provided sensible defaults will be used.