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

/authors

People who write posts

namestringrequired
biotext
avatar_urlurl

Read: Anyone with the API key · Write: Admins

Categories

/categories

Post categories

namestringrequired
slugstringrequired

Read: Anyone with the API key · Write: Admins

Posts

/posts

Blog posts

titlestringrequired
slugstringrequired
excerpttext
contenttextrequired
author→ authors
category→ categories
cover_image_urlurl
is_publishedboolean
published_atdatetime

Read: Anyone with the API key · Write: Admins

Comments

/comments

Comments on posts, shown once approved

post→ postsrequired
author_namestringrequired
contenttextrequired
approvedboolean

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.

GET /posts
curl "https://YOUR_PROJECT.codefreeapi.com/api/v1/posts?sort=-createdAt&limit=20" \
  -H "X-API-Key: YOUR_API_KEY"
POST /posts
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." }'
Response (one record)
{
  "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"
}

Start your blog backend now

Free plan, no credit card. One click copies this template into your account.