Response Shapes
TypeScript shapes used by the hive-cms SDK
Use SDK-exported types in your app code to keep integrations type-safe.
Import types
import type {
PublicAuthor,
PublicCategory,
PublicPostDetail,
PublicPostSummary,
PublicStats,
PublicTag,
} from 'hive-cms';Common shapes
type PostList = {
data: PublicPostSummary[];
total: number;
offset: number;
limit: number;
};
type PostDetail = PublicPostDetail;
type Tags = PublicTag[];
type Categories = PublicCategory[];
type Authors = PublicAuthor[];
type Stats = PublicStats;Error shape
import { HiveApiError } from 'hive-cms';
try {
// SDK call
} catch (error) {
if (error instanceof HiveApiError) {
console.error(error.status, error.code, error.details);
}
}Technical notes
- SDK validates API payloads at runtime before returning typed data.
- Invalid payloads throw
HiveApiErrorwith codeINVALID_API_RESPONSE.
Full payload reference
See API Reference: Response Shapes.
// Fetch posts
const response = await fetch(
'https://api.hivecms.online/api/public/{API_KEY}/posts'
);
const data: PostListResponse = await response.json();
// Fetch a single post
const postResponse = await fetch(
'https://api.hivecms.online/api/public/{API_KEY}/posts/my-post-slug'
);
const post: PostDetail = await postResponse.json();
// Fetch tags
const tagsResponse = await fetch(
'https://api.hivecms.online/api/public/{API_KEY}/tags'
);
const tags: TagCategoryResponse = await tagsResponse.json();