SDK Reference
Content API

Content API

Access posts, categories, authors, and tags through the Content API.

Posts

sdk.content.getPosts(options)

Get paginated posts with filtering and sorting.

const result = await sdk.content.getPosts({
  filter: { 
    category: 'news',
    author: 'john-doe',
    status: 'published'
  },
  page: 1,
  limit: 10,
  sort: 'createdAt',
  order: 'desc'
});

Parameters:

ParameterTypeDefaultDescription
filter.categorystring-Filter by category slug
filter.authorstring-Filter by author slug
filter.tagstring-Filter by tag slug
filter.statusstring'published'Post status
pagenumber1Page number
limitnumber10Posts per page
sortstring'createdAt'Sort field
orderstring'desc'Sort order ('asc' or 'desc')

Returns:

{
  items: [
    {
      id: '...',
      title: 'Post Title',
      slug: 'post-title',
      url: '/posts/post-title',
      excerpt: 'Short excerpt...',
      featuredImage: '/uploads/image.jpg',
      createdAt: '2026-01-15T...',
      author: { id, name, slug, url },
      category: { id, name, slug, url }
    },
    // ...
  ],
  total: 100,
  page: 1,
  pages: 10
}

sdk.content.getPost(idOrSlug)

Get a single post by ID or slug.

// By slug
const post = await sdk.content.getPost('my-post-slug');
 
// By ID
const post = await sdk.content.getPost('507f1f77bcf86cd799439011');

Returns: Full post object with all fields including content.

sdk.content.getLatestPosts(limit)

Get the most recent posts.

const latest = await sdk.content.getLatestPosts(10);

sdk.content.getFeaturedPosts(limit)

Get featured/highlighted posts.

const featured = await sdk.content.getFeaturedPosts(6);

sdk.content.searchPosts(query, options)

Search posts by keyword.

const results = await sdk.content.searchPosts('chocolate cake', { 
  limit: 20,
  page: 1
});

Categories

sdk.content.getCategories()

Get all categories.

const categories = await sdk.content.getCategories();
 
// Returns:
[
  {
    id: '...',
    name: 'Category Name',
    slug: 'category-name',
    url: '/categories/category-name',
    description: 'Category description',
    image: '/uploads/category.jpg',
    postCount: 25
  },
  // ...
]

sdk.content.getCategory(idOrSlug)

Get a single category.

const category = await sdk.content.getCategory('news');

Authors

sdk.content.getAuthors()

Get all authors.

const authors = await sdk.content.getAuthors();
 
// Returns:
[
  {
    id: '...',
    name: 'Author Name',
    slug: 'author-name',
    url: '/authors/author-name',
    email: '[email protected]',
    bio: 'Author biography...',
    avatar: '/uploads/avatar.jpg',
    postCount: 42
  },
  // ...
]

sdk.content.getAuthor(idOrSlug)

Get a single author.

const author = await sdk.content.getAuthor('john-doe');

Tags

sdk.content.getTags(options)

Get tags.

const tags = await sdk.content.getTags({ 
  limit: 50,
  orderBy: 'postCount' // or 'name'
});
 
// Returns:
[
  {
    id: '...',
    name: 'Tag Name',
    slug: 'tag-name',
    url: '/tags/tag-name',
    postCount: 15
  },
  // ...
]

Usage Examples

In a Theme Template

views/pages/home.html
{# Get featured posts #}
{% const featured = await sdk.content.getFeaturedPosts(3); %}
 
{% if (featured.length > 0) { %}
<section class="featured">
  <h2>Featured</h2>
  {% featured.forEach(post => { %}
    {{{ include('partials/post-card', { post }) }}}
  {% }) %}
</section>
{% } %}

In a Plugin

plugins/my-plugin/index.js
module.exports = async function(sdk) {
  
  // Get posts for a custom widget
  sdk.widgets.registerWidget('popular-posts', {
    name: 'Popular Posts',
    settings: [
      { key: 'count', type: 'number', label: 'Number of posts', default: 5 }
    ],
    render: async (settings) => {
      const posts = await sdk.content.getLatestPosts(settings.count);
      
      let html = '<ul class="popular-posts">';
      posts.forEach(post => {
        html += `<li><a href="${post.url}">${post.title}</a></li>`;
      });
      html += '</ul>';
      
      return html;
    }
  });
  
  return { activate: async () => {}, deactivate: async () => {} };
};