Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@kentico/kontent-management
Advanced tools
Javascript SDK for the Kontent Management. Helps you manage content in your Kentico Kontent projects. Supports both
node.js
andbrowsers
.
To get started, you'll first need to have access to your Kentico Kontent project where you need to enable Content management API and generate access token
that will be used to authenticate all requests made by this library.
This library has a peer dependency on rxjs
which means you need to install it as well. You install it using npm
or use it directly in browser using one of the cdn
bundles.
npm i rxjs --save
npm i @kentico/kontent-management --save
If you'd like to use this library directly in browser, place following script tags to your html page. You may of course download it and refer to local versions of scripts.
<script src="https://cdn.jsdelivr.net/npm/rxjs/bundles/rxjs.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@kentico/kontent-management/_bundles/kontent-management.umd.min.js"></script>
The following code example shows how to create new content item in your Kentico Kontent project.
import { ManagementClient } from '@kentico/kontent-management';
const client = new ManagementClient({
projectId: 'xxx', // id of your Kentico Kontent project
apiKey: 'yyy', // Content management API token
});
client.addContentItem()
.withData(
{
name: 'New article',
type: {
codename: 'article' // codename of content type
}
}
)
.toObservable()
.subscribe((response) => {
// work with response
},
(error) => {
// handle error
});
If you are using UMD
bundles directly in browsers, you can find this library under KontentManagement
global variable.
<!DOCTYPE html>
<html>
<head>
<title>Kontent management | jsdelivr cdn</title>
<script src="https://cdn.jsdelivr.net/npm/rxjs/bundles/rxjs.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@kentico/kontent-management/_bundles/kontent-management.umd.min.js"></script>
</head>
<body>
<script type="text/javascript">
var KontentManagement = window['KontentManagement'];
var client = new KontentManagement.ManagementClient({
projectId: 'xxx',
// using CM API key in browser is NOT safe. If you need to use SDK in browsers
// you should use proxy server and set authorization header there rather than here
apiKey: 'yyy'
});
client.addContentItem()
.withData(
{
name: 'New article',
type: {
codename: 'article'
},
}
)
.toObservable()
.subscribe((response) => {
// work with response
},
(error) => {
// handle error
});
</script>
</body>
</html>
The ManagementClient
contains several configuration options:
const client = new ManagementClient({
// configuration options
});
Option | Default | Description |
---|---|---|
projectId | N/A | Required - Id of your Kentico Kontent project |
apiKey | N/A | Required - Content management API Token |
baseUrl | https://manage.kontent.ai/v2/projects | Base URL of REST api. Can be useful if you are using custom proxy or for testing purposes |
retryStrategy | undefined | Retry strategy configuration. If not set, default strategy is used. |
httpService | HttpService | Used to inject implementation of IHttpService used to make HTTP request across network. Can also be useful for testing purposes by returning specified responses. |
If you want to mock http responses, it is possible to use external implementation of configurable Http Service as a part of the client configuration.
If you have any issues or want to share your feedback, please feel free to create an issue in this GitHub repository.
Contributions are welcomed. If you have an idea of what you would like to implement, let us know and lets discuss details of your PR.
FAQs
Official Kentico kontent Content management API SDK
We found that @kentico/kontent-management demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.