Zenex CMSDocs

GET Tags

Fetch all tags for a blog.

Endpoint

Endpoint
GET /api/blogs/{blogId}/tags

Response

Response
{
"data": [
{
"id": "tag123",
"name": "JavaScript",
"slug": "javascript",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
},
{
"id": "tag124",
"name": "React",
"slug": "react",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
]
}

Example

example.ts
const blogId = "your-blog-id";
const res = await fetch(
`https://yourdomain.com/api/blogs/${blogId}/tags`
);
const { data: tags } = await res.json();
// Display tags
tags.forEach(tag => {
console.log(`${tag.name} (/tags/${tag.slug})`);
});

Common Use Cases

  • • Display a tag cloud on your blog
  • • Show related tags on post pages
  • • Create tag archive pages
  • • Filter content by tags (available in post data)