The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
The current Contentful.js version
A client that will fetch assets and entries with all locales. Only available if not already enabled.
A client that will not resolve links in entries. Only available if not already disabled.
A client that will remove unresolvable links from entries. Only available if not already disabled.
Creates an asset key for signing asset URLs (Embargoed Assets)
Promise for an asset key
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const assetKey = await client.getAssetKey(<UNIX timestamp>)
console.log(assetKey)
Fetches an asset
If provided for a client using allLocales
modifier, response type defines locale keys for asset field values.
Optional
query: AssetQueries<Modifiers>Object with search parameters. In this method it's only useful for locale
.
Optional
Promise for an asset
const contentful = require('contentful')
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const asset = await client.getAsset('<asset_id>')
console.log(asset)
Fetches a collection of assets
If provided for a client using allLocales
modifier, response type defines locale keys for asset field values.
Optional
query: AssetsQueries<AssetFields, Modifiers>Object with search parameters
Optional
Promise for a collection of Assets
const contentful = require('contentful')
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const response = await client.getAssets()
console.log(response.items)
Fetches a content type
The content type’s ID
Promise for a content type
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const contentType = await client.getContentType('<content_type_id>')
console.log(contentType)
Fetches a collection of content types
Optional
query: { Optional
Optional
query?: stringPromise for a collection of content types
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const response = await client.getContentTypes()
console.log(response.items)
Fetches a collection of Entries
Shape of entry fields used to calculate dynamic keys
If provided for a client using allLocales
modifier, response type defines locale keys for entry field values.
Optional
query: EntriesQueries<EntrySkeleton, Modifiers>Object with search parameters
Optional
Promise for a collection of Entries
const contentful = require('contentful')
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const response = await client.getEntries()
console.log(response.items)
Fetches an entry
Shape of entry fields used to calculate dynamic keys
If provided for a client using allLocales
modifier, response type defines locale keys for entry field values.
The entry’s ID
Optional
query: EntryQueries<Modifiers>Object with search parameters. In this method it's only used for locale
when querying.
Optional
Promise for an entry
const contentful = require('contentful')
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const entry = await client.getEntry('<entry_id>')
console.log(entry)
Fetches a collection of locales
Promise for a collection of locales
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const response = await client.getLocales()
console.log(response.items)
Fetches the space which the client is currently configured to use
Promise for the space
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const space = await client.getSpace()
console.log(space)
Fetches a tag
The tag’s ID
Promise for a tag
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const tag = await client.getTag('<asset_id>')
console.log(tag)
Gets a collection of Tags
Optional
query: TagQueriesOptional
Promise for a collection of tags
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const response = await client.getTags()
console.log(response.items)
Parse raw json data into a collection of entries. objects.Links will be resolved also
Shape of entry fields used to calculate dynamic keys
If provided for a client using allLocales
modifier, response type defines locale keys for entry field values.
json data
const data = {items: [
{
sys: {type: 'Entry', locale: 'en-US'},
fields: {
animal: {sys: {type: 'Link', linkType: 'Animal', id: 'oink'}},
anotheranimal: {sys: {type: 'Link', linkType: 'Animal', id: 'middle-parrot'}}
}
}
],
includes: {
Animal: [
{
sys: {type: 'Animal', id: 'oink', locale: 'en-US'},
fields: {
name: 'Pig',
friend: {sys: {type: 'Link', linkType: 'Animal', id: 'groundhog'}}
}
}
]
}
}
console.log( data.items[0].fields.foo ); // undefined
const parsedData = client.parseEntries(data);
console.log( parsedData.items[0].fields.foo ); // foo
Synchronizes either all the content or only new content since last sync. Important note: The Sync API endpoint does not support include or link resolution. However, contentful.js can do link resolution on the client side for the initial sync. For the delta sync (using nextSyncToken) link resolution is not possible since the sdk won’t have access to all linked entities.
Shape of entity fields used to calculate dynamic keys
The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
If provided for a client using allLocales
modifier, response type defines locale keys for entity field values.
Query object
Optional
syncOptions: SyncOptionsOptional
import * as contentful from 'contentful'
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<content_delivery_api_key>'
})
const response = await client.sync({
initial: true
})
console.log({
entries: response.entries,
assets: response.assets,
nextSyncToken: response.nextSyncToken
})
Contentful Delivery API Client. Contains methods which allow access to the different kinds of entities present in Contentful (Entries, Assets, etc).