API Documentation

Complete guide to ZenBlog's public API endpoints for programmatic access to your blog content.

Authentication

API Key Authentication

Most endpoints require API key authentication. Include your API key in the request headers:

Authorization: Bearer your-api-key-here

You can generate API keys from your dashboard.

V1 API Endpoints (Authenticated)

Blogs

GET/api/v1/blogs

Get all blogs for the authenticated user.

Response:

{
  "blogs": [
    {
      "id": "string",
      "name": "string",
      "description": "string",
      "subdomain": "string",
      "customDomain": "string",
      "isActive": boolean,
      "createdAt": "timestamp",
      "updatedAt": "timestamp"
    }
  ],
  "total": number
}

Posts

GET/api/v1/blogs/{blogId}/posts

Get all posts for a specific blog.

Parameters:

  • blogId (path): The ID of the blog
  • page (query, optional): Page number (default: 1)
  • limit (query, optional): Number of posts per page (default: 10, max: 100)
  • published (query, optional): Filter by publication status ("true" or "false")

Response:

{
  "posts": [
    {
      "id": "string",
      "title": "string",
      "slug": "string",
      "excerpt": "string",
      "status": "published|draft",
      "publishedAt": "timestamp",
      "createdAt": "timestamp",
      "updatedAt": "timestamp",
      "tags": ["string"]
    }
  ],
  "pagination": {
    "page": number,
    "limit": number,
    "total": number,
    "totalPages": number,
    "hasNext": boolean,
    "hasPrev": boolean
  }
}
GET/api/v1/posts/{postId}

Get a specific post by ID.

Parameters:

  • postId (path): The ID of the post

Response:

{
  "post": {
    "id": "string",
    "title": "string",
    "slug": "string",
    "content": "string",
    "excerpt": "string",
    "status": "published|draft",
    "publishedAt": "timestamp",
    "createdAt": "timestamp",
    "updatedAt": "timestamp",
    "tags": ["string"],
    "blogId": "string",
    "blog": {
      "id": "string",
      "name": "string",
      "subdomain": "string",
      "customDomain": "string"
    }
  }
}

Public API Endpoints (No Authentication Required)

Blogs

GET/api/public/blogs/{subdomain}

Get public blog information by subdomain.

Parameters:

  • subdomain (path): The subdomain of the blog

Posts

GET/api/public/blogs/{subdomain}/posts

Get all published posts for a blog.

Parameters:

  • subdomain (path): The subdomain of the blog
GET/api/public/blogs/{subdomain}/posts/{slug}

Get a specific published post by slug.

Parameters:

  • subdomain (path): The subdomain of the blog
  • slug (path): The slug of the post

Error Responses

All endpoints may return error responses in the following format:

{
  "error": "Error message description"
}

Common HTTP Status Codes:

  • 400 - Bad Request
  • 401 - Unauthorized (invalid or missing API key)
  • 404 - Not Found
  • 500 - Internal Server Error

Examples

Get all blogs (cURL)

curl -H "Authorization: Bearer your-api-key" \
  https://yourdomain.com/api/v1/blogs

Get published posts for a blog (cURL)

curl https://yourdomain.com/api/public/blogs/myblog/posts

Get posts with pagination (cURL)

curl -H "Authorization: Bearer your-api-key" \
  "https://yourdomain.com/api/v1/blogs/blog-id/posts?page=2&limit=5&published=true"

Rate Limiting

API requests are subject to rate limiting. If you exceed the rate limit, you will receive a 429 Too Many Requests response.