All Projects → cosmicjs → Cosmicjs Node

cosmicjs / Cosmicjs Node

Licence: mit
The official JavaScript client for Cosmic. Use it to power content server-side, in the browser and in native apps.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cosmicjs Node

Parvula
An extremely simple & flexible CMS generated from flat files with a complete RESTful API —
Stars: ✭ 76 (-69.84%)
Mutual labels:  api, cms
Next
Directus is a real-time API and App dashboard for managing SQL database content. 🐰
Stars: ✭ 111 (-55.95%)
Mutual labels:  api, cms
Mezzanine Api
RESTful web API for Mezzanine CMS
Stars: ✭ 84 (-66.67%)
Mutual labels:  api, cms
Strapi Sdk Javascript
🔌 Official JavaScript SDK for APIs built with Strapi.
Stars: ✭ 247 (-1.98%)
Mutual labels:  api, cms
Core
The Form Tools Core.
Stars: ✭ 156 (-38.1%)
Mutual labels:  api, cms
Contentjet Ui
Headless API-first content management system
Stars: ✭ 42 (-83.33%)
Mutual labels:  api, cms
Rageframe2
一个基于Yii2高级框架的快速开发应用引擎
Stars: ✭ 1,553 (+516.27%)
Mutual labels:  api, cms
Qor
QOR is a set of libraries written in Go that abstracts common features needed for business applications, CMSs, and E-commerce systems.
Stars: ✭ 4,905 (+1846.43%)
Mutual labels:  api, cms
Payload
Headless CMS and Application Framework built with Node.js, React and MongoDB
Stars: ✭ 154 (-38.89%)
Mutual labels:  api, cms
Nodejs Website Boilerplate
A Node.js website boilerplate that satisfies some common website requirements.
Stars: ✭ 154 (-38.89%)
Mutual labels:  api, cms
Notetoself
Command line note taking app
Stars: ✭ 16 (-93.65%)
Mutual labels:  api, cms
Tensei
🚀 Content management and distribution with a touch of elegance.
Stars: ✭ 217 (-13.89%)
Mutual labels:  api, cms
Notion Api Worker
Notion as CMS with easy API access
Stars: ✭ 806 (+219.84%)
Mutual labels:  api, cms
Core
Backpulse's core. Backpulse is an API Based CMS. Build you own website without worrying about the content administration system.
Stars: ✭ 61 (-75.79%)
Mutual labels:  api, cms
Ponzu
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
Stars: ✭ 5,373 (+2032.14%)
Mutual labels:  api, cms
Strapi
🚀 Open source Node.js Headless CMS to easily build customisable APIs
Stars: ✭ 41,786 (+16481.75%)
Mutual labels:  api, cms
V8 Archive
Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
Stars: ✭ 486 (+92.86%)
Mutual labels:  api, cms
Cms
Decoupled CMS for any Laravel app, gain control of: pages, blogs, galleries, events, images, custom modules and more.
Stars: ✭ 498 (+97.62%)
Mutual labels:  api, cms
Directus
Open-Source Data Platform 🐰 — Directus wraps any SQL database with a real-time GraphQL+REST API and an intuitive app for non-technical users.
Stars: ✭ 13,190 (+5134.13%)
Mutual labels:  api, cms
Api
A high-performance RESTful API layer designed in support of API-first development and COPE. Connects your content to the world
Stars: ✭ 180 (-28.57%)
Mutual labels:  api, cms

Cosmic

📖 View Docs

npm version CircleCI

Cosmic JavaScript Client

This is the official JavaScript client for Cosmic headless CMS.

What is Cosmic?

Cosmic is a headless CMS, meaning we provide a web dashboard to manage content and an API toolkit to deliver content to any website or app.

Why use a Headless CMS?

Teams use Cosmic instead of a legacy installed CMS to help them save time and trouble on CMS infrastructure maintenance. They use our service (either with a paid plan, or generous free plan) and can focus on application business logic and content development instead of CMS infrastructure.

How to use this NPM module

Use this NPM module to connect to your Cosmic Buckets and deliver content to any JavaScript enabled website or app. Advanced features are available including logging into your Cosmic account, managing Buckets, CRUD data management, file uploads, and user management. Use it in the browser or in server-side environments like Node.js.

Getting started

Go to https://www.cosmicjs.com, create an account and set up a Bucket.

Install

npm install cosmicjs

Or include in an HTML file

<script src="https://unpkg.com/[email protected]/cosmicjs.browser.min.js"></script>
<script>
// Exposes the global variable Cosmic
// Never expose your private keys or credentials in any public website's client-side code
</script>

Basic Usage

Connect to Bucket [View Docs]

Use the Cosmic.bucket method to connect to your Bucket. Get your Bucket slug located in Your Bucket > Basic Settings > API Access in your Cosmic Dashboard.

// Use the Cosmic.bucket method to connect to your Bucket.
const Cosmic = require('cosmicjs')()
const bucket = Cosmic.bucket({
  slug: 'your-bucket-slug',
  read_key: 'your-bucket-read-key',
  write_key: 'your-bucket-write-key' // Include only if doing write operations.
})

Get Objects by Type [View Docs]

Get Objects from an Object Type. Uses getObjects method with additional type param. Additional options noted below. See docs for more options including powerful queries and logic.

const params = {
  query: {
    type: 'posts',
    locale: 'en' // optional, if localization set on Objects
  },
  limit: 5,
  props: 'id,slug,title,content', // get only what you need
  sort: '-created_at' // optional, defaults to order in dashboard
}
bucket.getObjects(params).then(data => {
  console.log(data)
}).catch(err => {
  console.log(err)
})

Get Single Object [View Docs]

Returns a single Object from your Bucket.

By Id

bucket.getObject({
  id: '6038150ead9d8a0ee8ebe290', // Object ID
  props: 'slug,title,content' // get only what you need
}).then(data => {
  console.log(data)
}).catch(err => {
  console.log(err)
})

By Slug

Use the getObjects method and query param.

bucket.getObjects({
  query: {
    type: 'pages',
    slug: 'home', // slugs are unique per locale
    locale: 'en'  // optional, if localization set on Objects
  },
  props: 'slug,title,content' // get only what you need
}).then(data => {
  console.log(data)
}).catch(err => {
  console.log(err)
})

Further Documentation

See the API reference and full documentation for more requests and capabilities.

License

This project is published under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].