Template
Blog REST API
Posts, authors, categories and comments, related to each other. Everyone can read; only admins publish. Load a post with its author and category inline using ?populate=author,category.
- A headless blog behind a Next.js or Astro site
- Changelogs and news sections
- Apps that need moderated comments
What's inside
Anyone can read posts and leave comments. Only admins can write posts, manage authors and categories, and approve comments.
Authors
/authorsPeople who write posts
| name | string | required |
| bio | text | |
| avatar_url | url |
Read: Anyone with the API key · Write: Admins
Categories
/categoriesPost categories
| name | string | required |
| slug | string | required |
Read: Anyone with the API key · Write: Admins
Posts
/postsBlog posts
| title | string | required |
| slug | string | required |
| excerpt | text | |
| content | text | required |
| author | → authors | |
| category | → categories | |
| cover_image_url | url | |
| is_published | boolean | |
| published_at | datetime |
Read: Anyone with the API key · Write: Admins
Comments
/commentsComments on posts, shown once approved
| post | → posts | required |
| author_name | string | required |
| content | text | required |
| approved | boolean |
Read: Anyone with the API key · Write: Anyone with the API key
Call it from your app
Every entity is a REST endpoint with filtering, sorting and paging. Sample data is included so the first request returns something.
curl "https://YOUR_PROJECT.codefreeapi.com/api/v1/posts?sort=-createdAt&limit=20" \ -H "X-API-Key: YOUR_API_KEY"
curl -X POST "https://YOUR_PROJECT.codefreeapi.com/api/v1/posts" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "title": "Hello world", "slug": "hello-world", "content": "Welcome! This post comes from your blog API. Edit it in the dashboard, or fetch it with GET /api/v1/posts." }'{
"id": "b3f1…",
"title": "Hello world",
"slug": "hello-world",
"excerpt": "The first post on our new blog.",
"content": "Welcome! This post comes from your blog API. Edit it in the dashboard, or fetch it with GET /api/v1/posts.",
"author": "authors-record-id",
"category": "categories-record-id",
"is_published": true,
"published_at": "2026-12-31T09:00:00.000Z",
"createdAt": "2026-10-26T09:00:00.000Z"
}Other templates
Start your blog backend now
Free plan, no credit card. One click copies this template into your account.