diff --git a/New_APIs/ContentStack API/Readme.md b/New_APIs/ContentStack API/Readme.md new file mode 100644 index 0000000..5863db4 --- /dev/null +++ b/New_APIs/ContentStack API/Readme.md @@ -0,0 +1,29 @@ +# 📚 Contentstack API + +## Overview + +The **Contentstack API** enables developers to seamlessly integrate Contentstack's headless CMS capabilities into their applications. This API allows you to manage content, deliver it across channels, and create powerful content experiences at scale. + +## Features + +- **Content Management**: Create, update, and delete content entries programmatically. +- **Content Delivery**: Retrieve content across different channels and devices. +- **Multi-language Support**: Manage content in multiple languages with localization features. +- **Custom Queries**: Perform advanced searches and filter content based on various parameters. + +## Getting Started + +### Prerequisites + +- **API Key**: You will need an API key to access the Contentstack API. You can obtain an API key by [signing up](#) on our website. + +### Installation + +To use the Contentstack API, you can install it via npm (if you are building a Node.js application): + +```bash +npm install contentstack +``` + +## Contributor +### Sree Vidya diff --git a/New_APIs/ContentStack API/index.html b/New_APIs/ContentStack API/index.html new file mode 100644 index 0000000..b7f3dae --- /dev/null +++ b/New_APIs/ContentStack API/index.html @@ -0,0 +1,26 @@ + + + + + + + ContentStack API + + +
+

ContentStack API

+
+
+
+

Select Content Type

+ + +
+
+

Content Entries

+ +
+
+ + + diff --git a/New_APIs/ContentStack API/index.js b/New_APIs/ContentStack API/index.js new file mode 100644 index 0000000..e97a594 --- /dev/null +++ b/New_APIs/ContentStack API/index.js @@ -0,0 +1,51 @@ +document.getElementById('fetchContentButton').addEventListener('click', fetchContent); + +const apiKey = 'YOUR_API_KEY'; // Replace with your ContentStack API key +const accessToken = 'YOUR_ACCESS_TOKEN'; // Replace with your ContentStack access token +const apiUrl = 'https://cdn.contentstack.io/v3/content_types'; + +async function fetchContent() { + const contentType = document.getElementById('contentType').value; + + if (!contentType) { + alert('Please enter a Content Type UID.'); + return; + } + + try { + const response = await fetch(`${apiUrl}/${contentType}/entries`, { + method: 'GET', + headers: { + 'api_key': apiKey, + 'access_token': accessToken, + 'Content-Type': 'application/json' + } + }); + + if (response.ok) { + const result = await response.json(); + displayContent(result.entries); + } else { + alert('Failed to fetch content.'); + } + } catch (error) { + console.error('Error:', error); + alert('Error fetching content.'); + } +} + +function displayContent(entries) { + const contentList = document.getElementById('contentList'); + contentList.innerHTML = ''; + + if (entries.length === 0) { + contentList.innerHTML = '
  • No entries found.
  • '; + return; + } + + entries.forEach(entry => { + const listItem = document.createElement('li'); + listItem.textContent = JSON.stringify(entry, null, 2); + contentList.appendChild(listItem); + }); +} diff --git a/New_APIs/ContentStack API/package-lock.json b/New_APIs/ContentStack API/package-lock.json new file mode 100644 index 0000000..973aa06 --- /dev/null +++ b/New_APIs/ContentStack API/package-lock.json @@ -0,0 +1,26 @@ +{ + "name": "contentstack-api-demo", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "contentstack-api-demo", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "contentstack-api-demo": "file:", + "express": "^4.17.1" + } + }, + "node_modules/contentstack-api-demo": { + "resolved": "", + "link": true + }, + "node_modules/express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-G7fYv8zS0D7ftu3gnLsOniwhgLU4k9v+1NEtFPP07/Oa8XJ51FtdUKLqIvsTcZo5ua23NO4s9Hr77BM19DOf1g==" + } + } +} diff --git a/New_APIs/ContentStack API/package.json b/New_APIs/ContentStack API/package.json new file mode 100644 index 0000000..08295a0 --- /dev/null +++ b/New_APIs/ContentStack API/package.json @@ -0,0 +1,15 @@ +{ + "name": "contentstack-api-demo", + "version": "1.0.0", + "description": "A simple app to demonstrate the ContentStack API", + "main": "server.js", + "scripts": { + "start": "node server.js" + }, + "author": "Your Name", + "license": "ISC", + "dependencies": { + "contentstack-api-demo": "file:", + "express": "^4.17.1" + } +} diff --git a/New_APIs/ContentStack API/server.js b/New_APIs/ContentStack API/server.js new file mode 100644 index 0000000..74380f6 --- /dev/null +++ b/New_APIs/ContentStack API/server.js @@ -0,0 +1,8 @@ +const express = require('express'); +const app = express(); + +app.use(express.static('public')); + +app.listen(3000, () => { + console.log('Server is running on port 3000'); +}); diff --git a/New_APIs/ContentStack API/style.css b/New_APIs/ContentStack API/style.css new file mode 100644 index 0000000..6c7706d --- /dev/null +++ b/New_APIs/ContentStack API/style.css @@ -0,0 +1,79 @@ +body { + font-family: 'Arial', sans-serif; + background: linear-gradient(135deg, #f14a7f, #35d1dc); + color: #fff; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + margin: 0; +} + +header { + text-align: center; + margin-bottom: 20px; +} + +header h1 { + font-size: 3em; + text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); +} + +main { + width: 90%; + max-width: 600px; + background: rgba(255, 255, 255, 0.1); + border-radius: 10px; + padding: 20px; + box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); +} + +.content-section, +.result-section { + margin-bottom: 20px; + text-align: center; +} + +input[type="text"] { + display: block; + margin: 0 auto 15px auto; + font-size: 1em; + border: none; + border-radius: 5px; + outline: none; + padding: 10px; + width: 80%; + max-width: 400px; +} + +button { + padding: 10px 20px; + font-size: 1em; + background-color: #444; + color: #fff; + border: none; + border-radius: 5px; + cursor: pointer; + transition: background-color 0.3s; +} + +button:hover { + background-color: #666; +} + +.result-section ul { + list-style-type: none; + padding: 0; + text-align: left; + margin-top: 15px; +} + +.result-section ul li { + background: rgba(0, 0, 0, 0.2); + padding: 10px; + border-radius: 5px; + margin-bottom: 10px; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); + word-wrap: break-word; +}