Namespace: ContentfulSpaceAPI

ContentfulSpaceAPI

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 #

Type:
Object
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
Source:

Methods

(static) createApiKey(data) → {Promise.<ApiKey.ApiKey>} #

Creates a Api Key
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>
Source:
See:
Example
space.createApiKey({})
.then(apiKey => console.log(apiKey))

(static) createApiKeyWithId(id, data) → {Promise.<ApiKey.ApiKey>} #

Creates a Api Key with a specific id
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>
Source:
See:
Example
space.createApiKey('id', {})
.then(apiKey => console.log(apiKey))

(static) createAsset(data) → {Promise.<Asset.Asset>} #

Creates a Asset. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
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>
Source:
See:
Example
space.createAsset({fields: {
  fields: {
    file: {
      'en-US': {
         contentType: 'image/jpeg',
         fileName: 'filename_english.jpg',
         upload: 'http://example.com/filename_original_en.jpg'
      },
      'de-DE': {
         contentType: 'image/jpeg',
         fileName: 'filename_german.jpg',
         upload: 'http://example.com/filename_original_de.jpg'
      }
    }
  }
})
.then(e => console.log(e))

(static) createAssetWithId(id, data) → {Promise.<Asset.Asset>} #

Creates a Asset with a specific id. After creation, call asset.processForLocale or asset.processForAllLocales to start asset processing.
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>
Source:
See:
Example
space.createAssetWithId('image', {
  fields: {
    file: {
      'en-US': {
         contentType: 'image/jpeg',
         fileName: 'filename_english.jpg',
         upload: 'http://example.com/filename_original_en.jpg'
      },
      'de-DE': {
         contentType: 'image/jpeg',
         fileName: 'filename_german.jpg',
         upload: 'http://example.com/filename_original_de.jpg'
      }
    }
  }
})
.then(e => console.log(e))

(static) createContentType(data) → {Promise.<ContentType.ContentType>} #

Creates a Content Type
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>
Source:
See:
Example
space.createContentType({name: 'Post', fields: []})
.then(ct => console.log(ct))

(static) createContentTypeWithId(id, data) → {Promise.<ContentType.ContentType>} #

Creates a Content Type with a specific id
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>
Source:
See:
Example
space.createContentType('post', {name: 'Post', fields: []})
.then(ct => console.log(ct))

(static) createEntry(contentTypeId, data) → {Promise.<Entry.Entry>} #

Creates a Entry
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>
Source:
See:
Example
space.createEntry('contentTypeId', {
  fields: {
    title: {
      'en-US': 'english content',
      'de-DE': 'german content'
    }
  }
})
.then(e => console.log(e))

(static) createEntryWithId(contentTypeId, id, data) → {Promise.<Entry.Entry>} #

Creates a Entry with a specific id
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>
Source:
See:
Example
space.createEntryWithId('contentTypeId', 'entryId', {
  fields: {
    title: {
      'en-US': 'english content',
      'de-DE': 'german content'
    }
  }
})
.then(e => console.log(e))

(static) createLocale(data) → {Promise.<Locale.Locale>} #

Creates a Locale
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>
Source:
See:
Example
space.createLocale({name: 'German (Germany)', code: 'de-DE'})
.then(e => console.log(e))

(static) createRole(data) → {Promise.<Role.Role>} #

Creates a Role
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>
Source:
See:
Example
space.createRole({})
.then(role => console.log(role))

(static) createRoleWithId(id, data) → {Promise.<Role.Role>} #

Creates a Role with a specific id
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>
Source:
See:
Example
space.createRole('id', {})
.then(role => console.log(role))

(static) createSpaceMembership(data) → {Promise.<SpaceMembership.SpaceMembership>} #

Creates a Space Membership
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>
Source:
See:
Example
space.createSpaceMembership({})
.then(spaceMembership => console.log(spaceMembership))

(static) createSpaceMembershipWithId(id, data) → {Promise.<SpaceMembership.SpaceMembership>} #

Creates a Space Membership with a specific id
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>
Source:
See:
Example
space.createSpaceMembership('id', {})
.then(spaceMembership => console.log(spaceMembership))

(static) createWebhook(data) → {Promise.<Webhook.Webhook>} #

Creates a Webhook
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>
Source:
See:
Example
space.createWebhook({})
.then(webhook => console.log(webhook))

(static) createWebhookWithId(id, data) → {Promise.<Webhook.Webhook>} #

Creates a Webhook with a specific id
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>
Source:
See:
Example
space.createWebhook('id', {})
.then(webhook => console.log(webhook))

(static) getApiKey(id) → {Promise.<ApiKey.ApiKey>} #

Gets a Api Key
Parameters:
Name Type Description
id string
Returns:
Promise for a Api Key
Type:
Promise.<ApiKey.ApiKey>
Source:
Example
space.getApiKey('id')
.then(apiKey => console.log(apiKey))

(static) getApiKeys() → {Promise.<ApiKey.ApiKeyCollection>} #

Gets a collection of Api Keys
Returns:
Promise for a collection of Api Keys
Type:
Promise.<ApiKey.ApiKeyCollection>
Source:
Example
space.getApiKeys()
.then(apiKeys => console.log(apiKeys.items))

(static) getAsset(id, queryopt) → {Promise.<Asset.Asset>} #

Gets an Asset
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>
Source:
Example
space.getAsset('assetId')
.then(asset => console.log(asset))

(static) getAssets(queryopt) → {Promise.<Asset.AssetCollection>} #

Gets a collection of Assets
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>
Source:
Example
space.getAssets()
.then(assets => console.log(assets.items))

(static) getContentType(id) → {Promise.<ContentType.ContentType>} #

Gets a Content Type
Parameters:
Name Type Description
id string
Returns:
Promise for a Content Type
Type:
Promise.<ContentType.ContentType>
Source:
Example
space.getContentType('contentTypeId')
.then(contentType => console.log(contentType))

(static) getContentTypes(queryopt) → {Promise.<ContentType.ContentTypeCollection>} #

Gets a collection of Content Types
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 Content Types
Type:
Promise.<ContentType.ContentTypeCollection>
Source:
Example
space.getContentTypes()
.then(contentTypes => console.log(contentTypes.items))

(static) getEditorInterfaceForContentType(contentTypeId) → {Promise.<EditorInterface.EditorInterface>} #

Gets an EditorInterface for a ContentType
Parameters:
Name Type Description
contentTypeId string
Returns:
Promise for an EditorInterface
Type:
Promise.<EditorInterface.EditorInterface>
Source:
Example
space.getEditorInterfaceForContentType('contentTypeId')
.then(editorInterface => console.log(editorInterface))

(static) getEntries(queryopt) → {Promise.<Entry.EntryCollection>} #

Gets a collection of Entries
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>
Source:
Example
space.getEntries({content_type: 'contentTypeId'})
.then(entries => console.log(entries.items))

(static) getEntry(id, queryopt) → {Promise.<Entry.Entry>} #

Gets an Entry
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>
Source:
Example
space.getEntry('entryId')
.then(entry => console.log(entry))

(static) getLocale(id) → {Promise.<Locale.Locale>} #

Gets a Locale
Parameters:
Name Type Description
id string
Returns:
Promise for an Locale
Type:
Promise.<Locale.Locale>
Source:
Example
space.getLocale('localeId')
.then(locale => console.log(locale))

(static) getLocales() → {Promise.<Locale.LocaleCollection>} #

Gets a collection of Locales
Returns:
Promise for a collection of Locales
Type:
Promise.<Locale.LocaleCollection>
Source:
Example
space.getLocales()
.then(locales => console.log(locales.items))

(static) getRole(id) → {Promise.<Role.Role>} #

Gets a Role
Parameters:
Name Type Description
id string
Returns:
Promise for a Role
Type:
Promise.<Role.Role>
Source:
Example
space.getRole('id')
.then(role => console.log(role))

(static) getRoles() → {Promise.<Role.RoleCollection>} #

Gets a collection of Roles
Returns:
Promise for a collection of Roles
Type:
Promise.<Role.RoleCollection>
Source:
Example
space.getRoles()
.then(roles => console.log(roles.items))

(static) getSpaceMembership(id) → {Promise.<SpaceMembership.SpaceMembership>} #

Gets a Space Membership
Parameters:
Name Type Description
id string
Returns:
Promise for a Space Membership
Type:
Promise.<SpaceMembership.SpaceMembership>
Source:
Example
space.getSpaceMembership('id')
.then(spaceMembership => console.log(spaceMembership))

(static) getSpaceMemberships() → {Promise.<SpaceMembership.SpaceMembershipCollection>} #

Gets a collection of Space Memberships
Returns:
Promise for a collection of Space Memberships
Type:
Promise.<SpaceMembership.SpaceMembershipCollection>
Source:
Example
space.getSpaceMemberships()
.then(spaceMemberships => console.log(spaceMemberships.items))

(static) getWebhook(id) → {Promise.<Webhook.Webhook>} #

Gets a Webhook
Parameters:
Name Type Description
id string
Returns:
Promise for a Webhook
Type:
Promise.<Webhook.Webhook>
Source:
Example
space.getWebhook('id')
.then(webhook => console.log(webhook))

(static) getWebhooks() → {Promise.<Webhook.WebhookCollection>} #

Gets a collection of Webhooks
Returns:
Promise for a collection of Webhooks
Type:
Promise.<Webhook.WebhookCollection>
Source:
Example
space.getWebhooks()
.then(webhooks => console.log(webhooks.items))