@thehive/cms-content-api
v0.12.8
Published
HTTP Client for The Hive CMS Content API
Downloads
166
Keywords
Readme
The Hive CMS: Content API
First, install the package:
npm install @thehive/cms-content-api
Create an instance:
import { CmsContentApi } from '@thehive/cms-content-api'
const contentApi = new CmsContentApi({
apiKey: process.env.THE_HIVE_CMS_API_KEY,
organization: 'my-org',
space: 'my-space',
environment: 'main'
})
Use the client to request content:
// Content
contentApi.content.getPage<MyContentResult>(
'type',
{ pageNumber: 0, pageSize: 10 }
)
contentApi.content.getById<MyContentResult>('type', entryId)
contentApi.content.getByUniqueField<MyContentResult>('type', 'field', value)
// Posts
contentApi.posts.getPage({
pageNumber: 1, pageSize: 10, postType: 'news'
})
contentApi.posts.getById(postId)
contentApi.posts.getBySlug(slug)
contentApi.posts.view(postId)
// Tags
contentApi.tags.getPage(pagination)
contentApi.tags.getBySlug('tag')