GET Categories
Fetch all categories for a blog.
Endpoint
Endpoint
GET /api/blogs/{blogId}/categoriesResponse
Response
{ "data": [ { "id": "cat123", "name": "Technology", "slug": "technology", "description": "Posts about technology", "createdAt": "2024-01-01T00:00:00.000Z", "updatedAt": "2024-01-01T00:00:00.000Z" }, { "id": "cat124", "name": "Design", "slug": "design", "description": "Posts about design", "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}/categories`);const { data: categories } = await res.json();
// Use categories for filtering postscategories.forEach(category => { console.log(`${category.name}: ${category.slug}`);});Filter Posts by Category
Use the category ID to filter posts in the posts endpoint.
example.ts
const categoryId = "cat123";const res = await fetch( `https://yourdomain.com/api/blogs/${blogId}/posts?category=${categoryId}`);