- Source:
Contentful Space API. Contains methods to access any operations at a space
level, such as creating and reading entities contained in a space.
Type Definitions
ContentfulSpaceAPI
- Source:
Properties:
Name | Type | Description |
---|---|---|
delete |
function | |
update |
function | |
getContentType |
function | |
getContentTypes |
function | |
createContentType |
function | |
createContentTypeWithId |
function | |
getEntry |
function | |
getEntries |
function | |
createEntry |
function | |
createEntryWithId |
function | |
getAsset |
function | |
getAssets |
function | |
createAsset |
function | |
createAssetWithId |
function | |
getLocale |
function | |
getLocales |
function | |
createLocale |
function | |
getWebhook |
function | |
getWebhooks |
function | |
createWebhook |
function | |
createWebhookWithId |
function | |
getRole |
function | |
getRoles |
function | |
createRole |
function | |
createRoleWithId |
function | |
getSpaceMembership |
function | |
getSpaceMemberships |
function | |
createSpaceMembership |
function | |
createSpaceMembershipWithId |
function | |
getApiKey |
function | |
getApiKeys |
function | |
createApiKey |
function | |
createApiKeyWithId |
function | |
getUiExtension |
function | |
getUiExtensions |
function | |
createUiExtension |
function | |
createUiExtensionWithId |
function | |
getEntrySnapshots |
function | |
getContentTypeSnapshots |
function |
Type:
- Object
Methods
(static) createApiKey(data) → {Promise.<ApiKey.ApiKey>}
- Source:
- See:
Creates a Api Key
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createApiKey({
name: 'API Key name'
}
}))
.then((apiKey) => console.log(apiKey))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the Api Key to be created |
Returns:
Promise for the newly created Api Key
- Type
- Promise.<ApiKey.ApiKey>
(static) createApiKeyWithId(id, data) → {Promise.<ApiKey.ApiKey>}
- Source:
- See:
Creates a Api Key with a custom id
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createApiKeyWithId('<custom-id>', {
name: 'API Key name'
}
}))
.then((apiKey) => console.log(apiKey))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Api Key ID |
data |
object | Object representation of the Api Key to be created |
Returns:
Promise for the newly created Api Key
- Type
- Promise.<ApiKey.ApiKey>
(static) createAsset(data) → {Promise.<Asset.Asset>}
- Source:
- See:
Creates a Asset. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
Example
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
// Create asset
client.getSpace('<space_id>')
.then((space) => space.createAsset({
fields: {
title: {
'en-US': 'Playsam Streamliner'
},
file: {
'en-US': {
contentType: 'image/jpeg',
fileName: 'example.jpeg',
upload: 'https://example.com/example.jpg'
}
}
}
}))
.then((asset) => asset.process())
.then((asset) => console.log(asset))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the Asset to be created. Note that the field object should have an upload property on asset creation, which will be removed and replaced with an url property when processing is finished. |
Returns:
Promise for the newly created Asset
- Type
- Promise.<Asset.Asset>
(static) createAssetFromFiles(data) → {Promise.<Asset.Asset>}
- Source:
- See:
Creates a Asset based on files. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
Example
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createAssetFromFiles({
fields: {
file: {
'en-US': {
contentType: 'image/jpeg',
fileName: 'filename_english.jpg',
file: createReadStream('path/to/filename_english.jpg')
},
'de-DE': {
contentType: 'image/svg+xml',
fileName: 'filename_german.svg',
file: '<svg><path fill="red" d="M50 50h150v50H50z"/></svg>'
}
}
}
}))
.then((asset) => console.log(asset))
.catch(console.error)
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
data |
object | Object representation of the Asset to be created. Note that the field object should have an uploadFrom property on asset creation, which will be removed and replaced with an url property when processing is finished.
Properties
|
Returns:
Promise for the newly created Asset
- Type
- Promise.<Asset.Asset>
(static) createAssetWithId(id, data) → {Promise.<Asset.Asset>}
- Source:
- See:
Creates a Asset with a custom id. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
Example
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
// Create asset
client.getSpace('<space_id>')
.then((space) => space.createAssetWithId('<asset_id>', {
title: {
'en-US': 'Playsam Streamliner'
},
file: {
'en-US': {
contentType: 'image/jpeg',
fileName: 'example.jpeg',
upload: 'https://example.com/example.jpg'
}
}
}))
.then((asset) => asset.process())
.then((asset) => console.log(asset))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Asset ID |
data |
object | Object representation of the Asset to be created. Note that the field object should have an upload property on asset creation, which will be removed and replaced with an url property when processing is finished. |
Returns:
Promise for the newly created Asset
- Type
- Promise.<Asset.Asset>
(static) createContentType(data) → {Promise.<ContentType.ContentType>}
- Source:
- See:
Creates a Content Type
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createContentType({
name: 'Blog Post',
fields: [
{
id: 'title',
name: 'Title',
required: true,
localized: false,
type: 'Text'
}
]
}))
.then((contentType) => console.log(contentType))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the Content Type to be created |
Returns:
Promise for the newly created Content Type
- Type
- Promise.<ContentType.ContentType>
(static) createContentTypeWithId(id, data) → {Promise.<ContentType.ContentType>}
- Source:
- See:
Creates a Content Type with a custom id
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createContentTypeWithId('<custom-id>', {
name: 'Blog Post',
fields: [
{
id: 'title',
name: 'Title',
required: true,
localized: false,
type: 'Text'
}
]
}))
.then((contentType) => console.log(contentType))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Content Type ID |
data |
object | Object representation of the Content Type to be created |
Returns:
Promise for the newly created Content Type
- Type
- Promise.<ContentType.ContentType>
(static) createEntry(contentTypeId, data) → {Promise.<Entry.Entry>}
- Source:
- See:
Creates a Entry
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createEntry('<content_type_id>', {
fields: {
title: {
'en-US': 'Entry title'
}
}
}))
.then((entry) => console.log(entry))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
contentTypeId |
string | The Content Type which this Entry is based on |
data |
object | Object representation of the Entry to be created |
Returns:
Promise for the newly created Entry
- Type
- Promise.<Entry.Entry>
(static) createEntryWithId(contentTypeId, id, data) → {Promise.<Entry.Entry>}
- Source:
- See:
Creates a Entry with a custom id
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
// Create entry
client.getSpace('<space_id>')
.then((space) => space.createEntryWithId('<content_type_id>', '<entry_id>', {
fields: {
title: {
'en-US': 'Entry title'
}
}
}))
.then((entry) => console.log(entry))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
contentTypeId |
string | The Content Type which this Entry is based on |
id |
string | Entry ID |
data |
object | Object representation of the Entry to be created |
Returns:
Promise for the newly created Entry
- Type
- Promise.<Entry.Entry>
(static) createLocale(data) → {Promise.<Locale.Locale>}
- Source:
- See:
Creates a Locale
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
// Create locale
client.getSpace('<space_id>')
.then((space) => space.createLocale({
name: 'German (Austria)',
code: 'de-AT',
fallbackCode: 'de-DE',
optional: true
}))
.then((locale) => console.log(locale))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the Locale to be created |
Returns:
Promise for the newly created Locale
- Type
- Promise.<Locale.Locale>
(static) createRole(data) → {Promise.<Role.Role>}
- Source:
- See:
Creates a Role
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createRole({
name: 'My Role',
description: 'foobar role',
permissions: {
ContentDelivery: 'all',
ContentModel: ['read'],
Settings: []
},
policies: [
{
effect: 'allow',
actions: 'all',
constraint: {
and: [
{
equals: [
{ doc: 'sys.type' },
'Entry'
]
},
{
equals: [
{ doc: 'sys.type' },
'Asset'
]
}
]
}
}
]
}))
.then((role) => console.log(role))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the Role to be created |
Returns:
Promise for the newly created Role
- Type
- Promise.<Role.Role>
(static) createRoleWithId(id, data) → {Promise.<Role.Role>}
- Source:
- See:
Creates a Role with a custom id
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createRoleWithId(<custom-id>, {
name: 'My Role',
description: 'foobar role',
permissions: {
ContentDelivery: 'all',
ContentModel: ['read'],
Settings: []
},
policies: [
{
effect: 'allow',
actions: 'all',
constraint: {
and: [
{
equals: [
{ doc: 'sys.type' },
'Entry'
]
},
{
equals: [
{ doc: 'sys.type' },
'Asset'
]
}
]
}
}
]
}))
.then((role) => console.log(role))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Role ID |
data |
object | Object representation of the Role to be created |
Returns:
Promise for the newly created Role
- Type
- Promise.<Role.Role>
(static) createSpaceMembership(data) → {Promise.<SpaceMembership.SpaceMembership>}
- Source:
- See:
Creates a Space Membership
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createSpaceMembership({
admin: false,
roles: [
{
type: 'Link',
linkType: 'Role',
id: '<role_id>'
}
],
email: 'foo@example.com'
}))
.then((spaceMembership) => console.log(spaceMembership))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the Space Membership to be created |
Returns:
Promise for the newly created Space Membership
- Type
- Promise.<SpaceMembership.SpaceMembership>
(static) createSpaceMembershipWithId(id, data) → {Promise.<SpaceMembership.SpaceMembership>}
- Source:
- See:
Creates a Space Membership with a custom id
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createSpaceMembershipWithId('<custom-id>', {
admin: false,
roles: [
{
type: 'Link',
linkType: 'Role',
id: '<role_id>'
}
],
email: 'foo@example.com'
}))
.then((spaceMembership) => console.log(spaceMembership))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Space Membership ID |
data |
object | Object representation of the Space Membership to be created |
Returns:
Promise for the newly created Space Membership
- Type
- Promise.<SpaceMembership.SpaceMembership>
(static) createUiExtension(data) → {Promise.<UiExtension.UiExtension>}
- Source:
- See:
Creates a UI Extension
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createUiExtension({
extension: {
name: 'My awesome extension',
src: 'https://example.com/my',
fieldTypes: [
{
type: 'Symbol'
},
{
type: 'Text'
}
],
sidebar: false
}
}))
.then((uiExtension) => console.log(uiExtension))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the UI Extension to be created |
Returns:
Promise for the newly created UI Extension
- Type
- Promise.<UiExtension.UiExtension>
(static) createUiExtensionWithId(id, data) → {Promise.<UiExtension.UiExtension>}
- Source:
- See:
Creates a UI Extension with a custom ID
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createUiExtensionWithId('<extension_id>', {
extension: {
name: 'My awesome extension',
src: 'https://example.com/my',
fieldTypes: [
{
type: 'Symbol'
},
{
type: 'Text'
}
],
sidebar: false
}
}))
.then((uiExtension) => console.log(uiExtension))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | |
data |
object | Object representation of the UI Extension to be created |
Returns:
Promise for the newly created UI Extension
- Type
- Promise.<UiExtension.UiExtension>
(static) createUpload(data) → {Promise.<Upload>}
- Source:
Creates a Upload.
Example
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
const uploadStream = createReadStream('path/to/filename_english.jpg')
client.getSpace('<space_id>')
.then((space) => space.createUpload({file: uploadStream, 'image/png'})
.then((upload) => console.log(upload))
.catch(console.error)
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
data |
object | Object with file information.
Properties
|
Returns:
Upload object containing information about the uploaded file.
- Type
- Promise.<Upload>
(static) createWebhook(data) → {Promise.<Webhook.Webhook>}
- Source:
- See:
Creates a Webhook
Example
const contentful = require('contentful-management')
client.getSpace('<space_id>')
.then((space) => space.createWebhook({
'name': 'My webhook',
'url': 'https://www.example.com/test',
'topics': [
'Entry.create',
'ContentType.create',
'*.publish',
'Asset.*'
]
}))
.then((webhook) => console.log(webhook))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Object representation of the Webhook to be created |
Returns:
Promise for the newly created Webhook
- Type
- Promise.<Webhook.Webhook>
(static) createWebhookWithId(id, data) → {Promise.<Webhook.Webhook>}
- Source:
- See:
Creates a Webhook with a custom id
Example
const contentful = require('contentful-management')
client.getSpace('<space_id>')
.then((space) => space.createWebhookWithId('<webhook_id>', {
'name': 'My webhook',
'url': 'https://www.example.com/test',
'topics': [
'Entry.create',
'ContentType.create',
'*.publish',
'Asset.*'
]
}))
.then((webhook) => console.log(webhook))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Webhook ID |
data |
object | Object representation of the Webhook to be created |
Returns:
Promise for the newly created Webhook
- Type
- Promise.<Webhook.Webhook>
(static) getApiKey(id) → {Promise.<ApiKey.ApiKey>}
- Source:
Gets a Api Key
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getApiKey('<apikey-id>'))
.then((apikey) => console.log(apikey))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for a Api Key
- Type
- Promise.<ApiKey.ApiKey>
(static) getApiKeys() → {Promise.<ApiKey.ApiKeyCollection>}
- Source:
Gets a collection of Api Keys
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getApiKeys())
.then((response) => console.log(response.items))
.catch(console.error)
Returns:
Promise for a collection of Api Keys
- Type
- Promise.<ApiKey.ApiKeyCollection>
(static) getAsset(id, queryopt) → {Promise.<Asset.Asset>}
- Source:
Gets an Asset
Warning: if you are using the select operator, when saving, any field that was not selected will be removed
from your entry in the backend
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getAsset('<asset_id>'))
.then((asset) => console.log(asset))
.catch(console.error)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | ||
query |
Object |
<optional> |
Object with search parameters. In this method it's only useful for `locale`. |
Returns:
Promise for an Asset
- Type
- Promise.<Asset.Asset>
(static) getAssets(queryopt) → {Promise.<Asset.AssetCollection>}
- Source:
Gets a collection of Assets
Warning: if you are using the select operator, when saving, any field that was not selected will be removed
from your entry in the backend
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getAssets())
.then((response) => console.log(response.items))
.catch(console.error)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. |
Returns:
Promise for a collection of Assets
- Type
- Promise.<Asset.AssetCollection>
(static) getContentType(id) → {Promise.<ContentType.ContentType>}
- Source:
Gets a Content Type
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<content_type_id>'))
.then((contentType) => console.log(contentType))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for a Content Type
- Type
- Promise.<ContentType.ContentType>
(static) getContentTypes({Object) → {Promise.<ContentType.ContentTypeCollection>}
- Source:
Gets a collection of Content Types
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentTypes())
.then((response) => console.log(response.items))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
{Object |
Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. |
Returns:
Promise for a collection of Content Types
- Type
- Promise.<ContentType.ContentTypeCollection>
(static) getEditorInterfaceForContentType(contentTypeId) → {Promise.<EditorInterface.EditorInterface>}
- Source:
Gets an EditorInterface for a ContentType
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEditorInterfaceForContentType('<content_type_id>'))
.then((EditorInterface) => console.log(EditorInterface))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
contentTypeId |
string |
Returns:
Promise for an EditorInterface
- Type
- Promise.<EditorInterface.EditorInterface>
(static) getEntries(queryopt) → {Promise.<Entry.EntryCollection>}
- Source:
Gets a collection of Entries
Warning: if you are using the select operator, when saving, any field that was not selected will be removed
from your entry in the backend
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEntries({'content_type': 'foo'})) // you can add more queries as 'key': 'value'
.then((response) => console.log(response.items))
.catch(console.error)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. |
Returns:
Promise for a collection of Entries
- Type
- Promise.<Entry.EntryCollection>
(static) getEntry(id, queryopt) → {Promise.<Entry.Entry>}
- Source:
Gets an Entry
Warning: if you are using the select operator, when saving, any field that was not selected will be removed
from your entry in the backend
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEntry('<entry-id>'))
.then((entry) => console.log(entry))
.catch(console.error)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | ||
query |
Object |
<optional> |
Object with search parameters. In this method it's only useful for `locale`. |
Returns:
Promise for an Entry
- Type
- Promise.<Entry.Entry>
(static) getLocale(id) → {Promise.<Locale.Locale>}
- Source:
Gets a Locale
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getLocale('<locale_id>'))
.then((locale) => console.log(locale))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for an Locale
- Type
- Promise.<Locale.Locale>
(static) getLocales() → {Promise.<Locale.LocaleCollection>}
- Source:
Gets a collection of Locales
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getLocales())
.then((response) => console.log(response.items))
.catch(console.error)
Returns:
Promise for a collection of Locales
- Type
- Promise.<Locale.LocaleCollection>
(static) getRole(id) → {Promise.<Role.Role>}
- Source:
Gets a Role
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.createRole({
fields: {
title: {
'en-US': 'Role title'
}
}
}))
.then((role) => console.log(role))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for a Role
- Type
- Promise.<Role.Role>
(static) getRoles() → {Promise.<Role.RoleCollection>}
- Source:
Gets a collection of Roles
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getRoles())
.then((response) => console.log(response.items))
.catch(console.error)
Returns:
Promise for a collection of Roles
- Type
- Promise.<Role.RoleCollection>
(static) getSnapshots()
- Source:
Gets all snapshots of a contentType
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentTypeSnapshots('<contentTypeId>'))
.then((snapshots) => console.log(snapshots.items))
.catch(console.error)
Returns:
Promise
(static) getSnapshots()
- Source:
Gets all snapshots of an entry
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEntrySnapshots('<entry_id>'))
.then((snapshots) => console.log(snapshots.items))
.catch(console.error)
Returns:
Promise
(static) getSpaceMembership(id) → {Promise.<SpaceMembership.SpaceMembership>}
- Source:
Gets a Space Membership
Example
const contentful = require('contentful-management')
client.getSpace('<space_id>')
.then((space) => space.getSpaceMembership('id'))
.then((spaceMembership) => console.log(spaceMembership))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for a Space Membership
- Type
- Promise.<SpaceMembership.SpaceMembership>
(static) getSpaceMemberships(queryopt) → {Promise.<SpaceMembership.SpaceMembershipCollection>}
- Source:
Gets a collection of Space Memberships
Example
const contentful = require('contentful-management')
client.getSpace('<space_id>')
.then((space) => space.getSpaceMemberships({'limit': 100})) // you can add more queries as 'key': 'value'
.then((response) => console.log(response.items))
.catch(console.error)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
query |
Object |
<optional> |
Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. |
Returns:
Promise for a collection of Space Memberships
- Type
- Promise.<SpaceMembership.SpaceMembershipCollection>
(static) getUiExtension(id) → {Promise.<UiExtension.UiExtension>}
- Source:
Gets an UI Extension
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getUiExtension('<ui-extension-id>'))
.then((uiExtension) => console.log(uiExtension))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for an UI Extension
- Type
- Promise.<UiExtension.UiExtension>
(static) getUiExtensions() → {Promise.<UiExtension.UiExtensionCollection>}
- Source:
Gets a collection of UI Extension
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getUiExtensions()
.then((response) => console.log(response.items))
.catch(console.error)
Returns:
Promise for a collection of UI Extensions
- Type
- Promise.<UiExtension.UiExtensionCollection>
(static) getUpload(id) → {Promise.<Upload>}
- Source:
Gets an Upload
Example
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
const uploadStream = createReadStream('path/to/filename_english.jpg')
client.getSpace('<space_id>')
.then((space) => space.getUpload('<upload-id>')
.then((upload) => console.log(upload))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for an Upload
- Type
- Promise.<Upload>
(static) getWebhook(id) → {Promise.<Webhook.Webhook>}
- Source:
Gets a Webhook
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getWebhook('<webhook_id>'))
.then((webhook) => console.log(webhook))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for a Webhook
- Type
- Promise.<Webhook.Webhook>
(static) getWebhooks() → {Promise.<Webhook.WebhookCollection>}
- Source:
Gets a collection of Webhooks
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getWebhooks())
.then((response) => console.log(response.items))
.catch(console.error)
Returns:
Promise for a collection of Webhooks
- Type
- Promise.<Webhook.WebhookCollection>