Post list

Get posts for a blog

url

https://zenblog.com/api/public/blogs/:blogId/posts

method

GET

Query

  • offset

    Optional

    The offset for the posts

  • limit

    Optional

    The limit for the posts

  • category

    Optional

    The category slug to filter posts by. Ex: &category=news

  • tags

    Optional

    The tags to filter posts by. Ex: &tags=random,test. Multiple tags are possible.

  • author

    Optional

    The author slug to filter posts by. Ex: &author=carpincho


Response

200

The posts

typescript

{
  data: [{ 
    title: "string",
    html_content: "string",
    slug: "string",
    category?: {
      name: "string",
      slug: "string",
    },
    tags?: [{
      name: "string",
      slug: "string",
    }],
    excerpt?: "string",
    published_at: "string",
    authors?: [{
      slug: "string",
      name: "string",
      image_url?: "string",
      website?: "string",
      twitter?: "string",
    }],
  }],
  total?: number,
  offset?: number,
  limit?: number,
}

Usage

// Get posts for a blog
const { data: posts } = await zenblog.posts.list()
// Get posts for a blog filtered by a category
const { data: posts } = await zenblog.posts.list({
  category: "news",
})
// Get posts limit results to 10
const { data: posts } = await zenblog.posts.list({
  limit: 10,
})
// Get posts filtered by tag slugs
const { data: posts } = await zenblog.posts.list({
  tags: ["tag1", "tag2"],
})
// Get posts filtered by author slug
const { data: posts } = await zenblog.posts.list({
  author: "author-slug",
})