ContentfulClientAPI

ContentfulClientAPI

Source:
Contentful Management API Client. Contains methods which allow access to any operations that can be performed with a management token.

Type Definitions

ClientAPI

Source:
Properties:
Name Type Description
getSpace function
getSpaces function
createSpace function
Type:
  • Object

Methods

(static) createSpace(data, organizationIdopt) → {Promise.<Space.Space>}

Source:
See:
Creates a space
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.createSpace({
  name: 'Name of new space'
})
.then((space) => console.log(space))
.catch(console.error)
Parameters:
Name Type Attributes Description
data object Object representation of the Space to be created
organizationId string <optional>
Organization ID, if the associated token can manage more than one organization.
Returns:
Promise for the newly created Space
Type
Promise.<Space.Space>

(static) getSpace(id) → {Promise.<Space.Space>}

Source:
Gets a space
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpace('<space_id>')
.then((space) => console.log(space))
.catch(console.error)
Parameters:
Name Type Description
id string Space ID
Returns:
Promise for a Space
Type
Promise.<Space.Space>

(static) getSpaces() → {Promise.<Space.SpaceCollection>}

Source:
Gets all spaces
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.getSpaces()
.then((response) => console.log(response.items))
.catch(console.error)
Returns:
Promise for a collection of Spaces
Type
Promise.<Space.SpaceCollection>

(static) rawRequest(opts) → {Promise.<Object>}

Source:
Make a custom request to the Contentful management API's /spaces endpoint
Example
const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

client.rawRequest({
  method: 'GET',
  url: '/custom/path'
})
.then((responseData) => console.log(responseData))
.catch(console.error)
Parameters:
Name Type Description
opts Object axios request options (https://github.com/mzabriskie/axios)
Returns:
Promise for the response data
Type
Promise.<Object>