Contentful Delivery API Client. Contains methods which allow access to the
different kinds of entities present in Contentful (Entries, Assets, etc).
- See:
Type Definitions
ClientAPI #
- Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
getSpace |
function | |
getContentType |
function | |
getContentTypes |
function | |
getEntry |
function | |
getEntries |
function | |
getAsset |
function | |
getAssets |
function | |
sync |
function |
- Source:
Methods
(static) getAsset(id, queryopt) → {Promise.<Entities.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.<Entities.Asset>
- Source:
Example
client.getAsset('assetId')
.then(asset => console.log(asset))
(static) getAssets(queryopt) → {Promise.<Entities.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.<Entities.AssetCollection>
- Source:
Example
client.getAssets()
.then(assets => console.log(assets.items))
(static) getContentType(id) → {Promise.<Entities.ContentType>} #
Gets a Content Type
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns:
Promise for a Content Type
- Type:
- Promise.<Entities.ContentType>
- Source:
Example
client.getContentType('contentTypeId')
.then(contentType => console.log(contentType))
(static) getContentTypes(queryopt) → {Promise.<Entities.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.<Entities.ContentTypeCollection>
- Source:
Example
client.getContentTypes()
.then(contentTypes => console.log(contentTypes.items))
(static) getEntries(queryopt) → {Promise.<Entities.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.
Properties
|
Returns:
Promise for a collection of Entries
- Type:
- Promise.<Entities.EntryCollection>
- Source:
Example
client.getEntries({content_type: 'contentTypeId'})
.then(entries => console.log(entries.items))
(static) getEntry(id, queryopt) → {Promise.<Entities.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.<Entities.Entry>
- Source:
Example
client.getEntry('entryId')
.then(entry => console.log(entry))
(static) getSpace() → {Promise.<Entities.Space>} #
Gets the Space which the client is currently configured to use
Returns:
Promise for a Space
- Type:
- Promise.<Entities.Space>
- Source:
Example
client.getSpace()
.then(space => console.log(space))
(static) sync(query) → {Promise.<Sync.SyncCollection>} #
Synchronizes either all the content or only new content since last sync
See Synchronization for more information.
Important note: The the sync api endpoint does not support include or link resolution.
However contentful.js is doing link resolution client side if you only make an initial sync.
For the delta sync (using nextSyncToken) it is not possible since the sdk wont have access to all the data to make such an operation.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query |
Object | Query object for the sync call. One of initial or nextSyncToken always needs to be specified, but not both.
Properties
|
Returns:
Promise for the collection resulting of a sync operation
- Type:
- Promise.<Sync.SyncCollection>
- Source:
Example
client.sync()
.then((response) => console.log(response.entries, response.assets, response.nextSyncToken))