npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

contensis-management-api

v2.1.9

Published

Contensis Javascript Management API

Downloads

4,541

Readme

contensis-management-api NPM version

Contensis JavaScript Management API implementation written in TypeScript. This version targets Contensis 14.0 and above.

The contensis-management-api-examples repo contains Express and React examples.

Installing and importing the client npm package

The Contensis JS Management API client is delivered as an npm package, with publicly available source code and examples.
The client package can be used in a modern browser, in Node.js or as cross-platform client (e.g. a React.js application, a Node.js console application, an Express.js web application, a JavaScript or TypeScript library).

Note

Before following the rest of the examples we assume you have an existing Node.js or Express.js application that is already created, that targets Node.js >= 10 and uses the CommonJS module system (you can also use native JavaScript modules - see examples).
The Contensis JS Management API client is using the fetch API to maintain consistency with the Contensis JS Delivery API client. The fetch API is not a native Node.js API and it is loaded from the node-fetch npm package when the Contensis JS Management API client runs in a Node.js environment (if it runs in a browser enviroment the native fetch API will be used instead).

To install the required packages for the Contensis JS Management API client please run the following Node.js command:

npm install contensis-management-api

Import default Client if you are using CommonJS modules:

const Client = require('contensis-management-api').Client;

Import the default Client if you are using native JavaScript modules:

import { Client } from 'contensis-management-api';

The default Client class exported in the contensis-management-api package targets primarily a modern browser and assumes the fetch API is already made available.

As an alternative you can use the UniversalClient class that ensures fetch API is always made available regardless if you are in a browser context or a Node.js context.

Import UniversalClient if you are using CommonJS modules:

const UniversalClient = require('contensis-management-api/lib/client').UniversalClient;

Import UniversalClient if you are using native JavaScript modules:

import { UniversalClient } from 'contensis-management-api/lib/client';

Some Contensis JS Management API functionality is only available in a Node.js environment (e.g. creating and updating assets). In this scenario you need to use the NodejsClient class ensures fetch API is made available.

Import NodejsClient if you are using CommonJS modules:

const NodejsClient = require('contensis-management-api/lib/client').NodejsClient;

Import NodejsClient if you are using native JavaScript modules:

import { NodejsClient } from 'contensis-management-api/lib/client';

Creating and using the client instance

All operations for the API hang off the Client type (or UniversalClient and NodejsClient if you are using those), which is created using the static method call Client.create(options). The options object represents the shared configuration that will be used by all Management API calls and is of type Config:

const client = Client.create({
  clientType: "client_credentials",
  clientDetails: {
    clientId: '6f8cf1e8-b2ee-49ad-9b94-2dbb09871903',
    clientSecret: '6d80c9a356ce4317bd71d92c5734d67a-4a837b1336344f63b1b24ce2dfa73945-ef09daa8d0f74b1e8e223779c392a67b'
  }
  projectId: 'website',
  rootUrl: 'https://cms-example.cloud.contensis.com'
});

client.contentTypes.list()
  .then(result => {      
      console.log('API call result: ', result);        
      return result;      
  })
  .catch(error => {
    console.log('API call fetch error: ', error);      
    throw error;
  });