Skip to content

IndigoHive/the-hive-cms-content-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Hive CMS: Content API

.github/workflows/tests.yml npm NPM npm

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')