API Reference
Categories
Fetch blog categories from your Wrytze workspace.
The Categories endpoint returns all blog categories for your organization. Categories are hierarchical -- they can have parent categories to create nested structures like "Engineering > Frontend" or "Marketing > SEO".
List categories
GET /api/v1/categoriesReturns all categories across your organization's websites, ordered by sortOrder. You can optionally filter to a specific website.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
website_id | string | No | -- | Filter to a specific website |
Response
Returns an array of category objects wrapped in data. This endpoint returns all categories at once (no pagination) since category lists are typically small.
Cache TTL: 5 minutes.
Examples
curl "https://app.wrytze.com/api/v1/categories?website_id=ws_abc123" \
-H "X-API-Key: wrz_sk_abc123..."import { WrytzeClient } from "@wrytze/sdk";
const client = new WrytzeClient({ apiKey: "wrz_sk_abc123..." });
const { data } = await client.categories.list({
websiteId: "ws_abc123",
});
for (const category of data) {
console.log(category.name, category.slug);
}const response = await fetch(
"https://app.wrytze.com/api/v1/categories?website_id=ws_abc123",
{
headers: {
"X-API-Key": "wrz_sk_abc123...",
},
}
);
const { data } = await response.json();
for (const category of data) {
console.log(category.name, category.slug);
}Response example
{
"data": [
{
"id": "cat_abc123",
"name": "Engineering",
"slug": "engineering",
"description": "Technical articles about software development",
"parentId": null,
"sortOrder": 0,
"websiteId": "ws_abc123"
},
{
"id": "cat_def456",
"name": "Frontend",
"slug": "frontend",
"description": "Frontend development topics",
"parentId": "cat_abc123",
"sortOrder": 1,
"websiteId": "ws_abc123"
},
{
"id": "cat_ghi789",
"name": "Marketing",
"slug": "marketing",
"description": "Marketing strategy and insights",
"parentId": null,
"sortOrder": 2,
"websiteId": "ws_abc123"
}
]
}Building a category tree
Since categories support parent-child relationships via the parentId field, you may want to build a nested tree structure on the client side:
interface Category {
id: string;
name: string;
slug: string;
description: string;
parentId: string | null;
sortOrder: number;
websiteId: string;
}
interface CategoryNode extends Category {
children: CategoryNode[];
}
function buildCategoryTree(categories: Category[]): CategoryNode[] {
const map = new Map<string, CategoryNode>();
const roots: CategoryNode[] = [];
// Create nodes
for (const cat of categories) {
map.set(cat.id, { ...cat, children: [] });
}
// Build tree
for (const node of map.values()) {
if (node.parentId && map.has(node.parentId)) {
map.get(node.parentId)!.children.push(node);
} else {
roots.push(node);
}
}
return roots;
}TypeScript Interface
interface Category {
id: string;
name: string;
slug: string;
description: string;
parentId: string | null;
sortOrder: number;
websiteId: string;
}
interface CategoryListResponse {
data: Category[];
}