HTTP Client for The Hive CMS Content API
npm install @thehive/cms-content-api
npm install @thehive/cms-content-api
`
Create an instance:
`typescript
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:
`typescript
// Content
contentApi.content.getPage(
'type',
{ pageNumber: 0, pageSize: 10 }
)
contentApi.content.getById('type', entryId)
contentApi.content.getByUniqueField('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')
``