
Optimizely CMS - Integration API Client
A Javascript client for the Integration API provided by the Optimizely CMS. It wraps the Optimizely CMS SaaS Core REST API.
Installation
This package is provides as part of one of the mono-repo style demo sites. Install this package by using a mono-repo style structure for your project and copying this package into your mono-repo.
Requirements
This package works across browser and modern Node.JS environments, which provide an implementation for the Fetch API. The library has been tested with the Fetch API implementation in Node.JS v18 and above.
Usage
import createClient, { ContentRoots } from '@remkoj/optimizely-cms-integration-api'
const client = createClient({
base: "https://example.com",
clientId: "apiClientID",
clientSecret: "apiClientSecret"
});
client.content.contentListItems(ContentRoots.SystemRoot).then(response => {
const items = response.items
items?.map(item => {
})
})
Alternative configuration for Node.JS
The configuration object for the createClient()
method is optional, if it is omitted, the configuration will be read from the environment variables.
Configuration options
The following configuration options are available for
OPTIMIZELY_CMS_URL | base | yes | The URL where the CMS is available |
OPTIMIZELY_CMS_CLIENT_ID | clientId | yes | The API Client ID, as configured within the CMS |
OPTIMIZELY_CMS_CLIENT_SECRET | clientSecret | yes | The API Client Secret as generated by the CMS when creating the client |
OPTIMIZELY_CMS_USER_ID | actAs | no | The username of the CMS user to impersonate |
OPTIMIZELY_CMS_SCHEMA | cmsVersion | no | Override the target Optimizely CMS Version:
OPTI-CMS-12 : Optimizely CMS 12, With CMS Service Preview 1 installed and working.
OPTI-CMS-13 : Optimizely SaaS CMS / CMS 13
Default: SaaS CMS / CMS 13 |