Back to Documentation
API Reference
Get All Categories
Retrieve a list of all categories that have published posts.
GET
client.getCategories()import { LightweightClient } from 'lightweight-client';
async function getCategories() {
const key = process.env.LIGHTWEIGHT_API_KEY;
if (!key) throw Error('LIGHTWEIGHT_API_KEY environment variable must be set');
const client = new LightweightClient(key);
return client.getCategories();
}Parameters
This endpoint takes no parameters.
Response
[
{
"title": "Development",
"slug": "development"
},
{
"title": "Design",
"slug": "design"
},
{
"title": "Marketing",
"slug": "marketing"
}
]Response Schema
titlestringDisplay name of the category
slugstringURL-friendly identifier for the category
Notes
- •Only categories with at least one published post are returned
- •Use the
slugto fetch posts by category - •Returns an empty array if no categories exist