@remkoj/optimizely-cms-api
TypeScript icon, indicating that this package has built-in type declarations

5.1.3 • Public • Published

License Static Badge

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 the Client
import createClient, { ContentRoots } from '@remkoj/optimizely-cms-integration-api'

// Create an instance of the client
const client = createClient({
    base: "https://example.com",
    clientId: "apiClientID",
    clientSecret: "apiClientSecret"
});

// Start using client
client.content.contentListItems(ContentRoots.SystemRoot).then(response => {
    const items = response.items
    items?.map(item => {
        // Do something with the 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

Environment variable Configuration key Required Usage
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

Readme

Keywords

none

Package Sidebar

Install

npm i @remkoj/optimizely-cms-api

Weekly Downloads

855

Version

5.1.3

License

Apache-2.0

Unpacked Size

161 kB

Total Files

178

Last publish

Collaborators

  • remkoj