Getting Started Deliver your content anywhere, regardless of programming language or device.

Speaking Cosmic

What is a Bucket?

A Bucket is the main piece in the Cosmic JS content structure. It's very flexible and can power the content for your entire website, a portion of your website, or a micro-app on your website that requires dynamic, easy-to-manage content.

What is an Object Type?

An Object Type is any collection of Objects that share a similar function. Pages, articles, projects, etc.

What is an Object?

An Object can be a page, a blog post, or anything you want it to be. Cosmic JS gives you the freedom to create and manage content openly and create your own data structure. Each Object allows for the creation of a title, slug, content and Metafields.

What are Metafields?

Metafields are very powerful pieces of custom data that can be added to objects that can be recursively nested. Current available Metafield types include: text, textarea, HTML textarea, select dropown, file upload, date, object, radio buttons, check boxes and repeater.

A basic way to think of the structure is:

Bucket: Your website
Object Type: The blog posts on your website
Object: A blog post
Metafield: A picture on your blog post
Metafield: The author of your blog post

Getting Started Tutorial

Client Libraries

Cosmic JS has client libraries to help you easily manage content on your website or app. Below are a few examples of how these client libraries can be used to add dynamic content to your website without much custom coding.

Browser Example

Add the cosmicjs.browser.min.js file from the Official Cosmic JS JavaScript Client on GitHub to your app. Here is a real working example application:

Node.js Example

Install the Official Cosmic JS JavaScript Client on NPM.

$ npm install cosmicjs --save

Then get your content:

// in your JavaScript file
import Cosmic from 'cosmicjs';
const bucket = { slug: 'astral' };
Cosmic.getObjects({ bucket }, function(err, res) {
  console.log(res.objects);
});

PHP Example

Add the cosmicjs.php file from the Official Cosmic JS PHP Client on GitHub to your app.

$ git clone https://github.com/cosmicjs/cosmicjs-php

Then get your content:

// in your PHP file
$config = new stdClass();
$config->bucket_slug = "astral";
include("cosmicjs.php");
$objects = $cosmicjs->getObjects();
var_dump($objects);

Simple Curl

$ curl https://api.cosmicjs.com/v1/astral?pretty=true