Giter Club home page Giter Club logo

contentful.js's Introduction

contentful.js Build Status

Javascript client for Contentful's Content Delivery API:

Supported browsers/environments:

  • Chrome
  • Firefox
  • IE10
  • node.js >= 0.8

Install

In node, using npm:

npm install contentful

In a browser, using bower:

bower install contentful
# After installing, add this as a script tag:
# <script src="components/contentful/dist/contentful.min.js"></script>

Latest contentful.min.js.

Note: The next minor version release of dist/contentful.min.js will be much smaller. Please use a package manager to keep your JS dependencies up to date and get the newest version right when it's ready!

Usage

// Don't require if you've already included contentful as a script tag
var contentful = require('contentful');

var client = contentful.createClient({
  // ID of Space
  space: 'cfexampleapi',

  // A valid access token within the Space
  accessToken: 'b4c0n73n7fu1',

  // Enable or disable SSL. Enabled by default.
  secure: true,

  // Set an alternate hostname, default shown.
  host: 'cdn.contentful.com'
});

var log = console.log.bind(console); // wat

// Get Space
client.space().then(log, log);

// Get all Entries
client.entries().then(log, log);

// Get Assets using callback interface
client.entries({}, function(err, entries) {
  if (err) { console.log(err); return; }
  console.log(entries);
});

var syncToken;
// Get all data in a space
client.sync({initial: true})
.then(function(data){
  syncToken = data.nextSyncToken;
});

// Get all data since the last sync
client.sync({nextSyncToken: syncToken})
.then(function(data){
  syncToken = data.nextSyncToken;
});

For now, please check out the Content Delivery API documentation to learn how the API and the JavaScript client work.

Functionality

supported

  • .space() = get details of current space
  • .contentTypes() = get content types of current space
  • .entries() = get entries of current space
  • .sync() = get all the data in a space

License

MIT

contentful.js's People

Contributors

seidtgeist avatar sdepold avatar trodrigues avatar grncdr avatar tstrothjohann avatar janpio avatar mircobabini avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.