Skip to content

Commit 1ca861d

Browse files
committed
Read me file and unused package removed
1 parent c5f3d79 commit 1ca861d

4 files changed

Lines changed: 160 additions & 1678 deletions

File tree

README.md

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,117 @@
1-
# contentstack-management-javascript
1+
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2+
3+
## Contentstack Management JavaScript SDK
4+
5+
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
6+
7+
This SDK use Content Management API(CMA). The Content Management API (CMA) is used to manage the content of your Contentstack account. This includes creating, updating, deleting, and fetching content of your account. To use the Content Management API, you will need to authenticate yourself with a [Management Token](https://www.contentstack.com/docs/developers/create-tokens/about-management-tokens) or an [Authtoken](https://www.contentstack.com/docs/developers/apis/content-management-api/#how-to-get-authtoken). Read more about it in [Authentication](https://www.contentstack.com/docs/developers/apis/content-management-api/#authentication).
8+
9+
Note: The Content Management APIs also include many GET requests. However, it is highly recommended that you always use the [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/) to deliver content to your web or mobile properties.
10+
11+
### Prerequisite
12+
13+
You need Node.js version 10 or later installed to use the Contentstack JavaScript CMA SDK.
14+
15+
### Installation
16+
#### Node
17+
Install it via npm:
18+
```bash
19+
npm i contentstack-management
20+
```
21+
To import the SDK, use the following command:
22+
```
23+
import contentstack from ‘contentstack-mangement’
24+
```
25+
To initialize the SDK, you will need to pass ```axios``` instance
26+
```
27+
import axios from 'axios'
28+
contentstackClient = contentstack.client(axios, {})
29+
```
30+
31+
### Authentication
32+
To use this SDK you need to authenticate using the user Authtoken, creadentials, or Management Token (stack-level token).
33+
### Authtoken
34+
An **Authtoken** is a read-write token used to make authorized CMA requests, and it is a **user-specific** token.
35+
```
36+
import axios from 'axios'
37+
contentstackClient = contentstack.client(axios, { authtoken: 'AUTHTOKEN' })
38+
```
39+
### Login
40+
To Login to Contentstack using credentials:
41+
```
42+
contentstackClient.login({ email: 'EMAIL', password: 'PASSWORD'})
43+
..then((response) => {
44+
console.log(response.notice)
45+
console.log(response.user)
46+
})
47+
```
48+
49+
### Management Token
50+
**Management Tokens** are **stack-level** tokens, with no users attached to them.
51+
```
52+
contentstackClient.stack('API_KEY', 'MANAGEMENT_TOKEN')
53+
.fetch()
54+
.then((stack) => {
55+
console.log(stack)
56+
})
57+
```
58+
### Contentstack Management JavaScript SDK: 5-minute Quickstart
59+
#### Initializing your SDK:
60+
```
61+
import contentstack from ‘contentstack-mangement’
62+
import axios from 'axios'
63+
64+
var contentstackClient = contentstack.client(axios, { authtoken: 'AUTHTOKEN' })
65+
```
66+
#### Fetch Stack details
67+
The following code snippet is use to get Stack details from Contentstack using this SDK:
68+
```
69+
contentstackClient.stack('API_KEY')
70+
.fetch()
71+
.then((stack) => {
72+
console.log(stack)
73+
})
74+
```
75+
76+
#### Create Entry
77+
The following code snippet is use to create Entry of specific Content Type into Stack using this SDK:
78+
```
79+
var entry = {
80+
title: 'Sample Entry',
81+
url: '/sampleEntry'
82+
}
83+
84+
contentstackClient.stack('API_KEY').contentType('CONTENT_TYPE_UID').entry().create({ entry })
85+
.then((entry) => {
86+
console.log(entry)
87+
})
88+
```
89+
90+
#### Create Asset
91+
The following code snippet is use to create Asset into Stack using this SDK:
92+
```
93+
var asset = {
94+
upload: 'path/to/file',
95+
tit;e: 'Asset Title'
96+
}
97+
98+
contentstackClient.stack('API_KEY').asset().create({ asset })
99+
.then((asset) => {
100+
console.log(asset)
101+
})
102+
```
103+
104+
### Helpful Links
105+
106+
- [Contentstack Website](https://www.contentstack.com/)
107+
- [Official Documentation](https://contentstack.com/docs)
108+
- [Content Management API Docs](https://www.contentstack.com/docs/developers/apis/content-management-api)
109+
-
110+
### The MIT License (MIT)
111+
Copyright © 2012-2020 [Contentstack](https://www.contentstack.com/). All Rights Reserved
112+
113+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
114+
115+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
116+
117+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)