Open app

Public Blog API

API reference for fetching published blogs on static sites, custom frontends, and headless setups.

The Public Blog API lets you fetch your published blog content from theStacc and display it on any website — including static sites hosted on Cloudflare Pages, Vercel, Netlify, or any other platform. No CMS required.

When to use this

Use the Public Blog API when:

  • Your site runs on Cloudflare Pages, Vercel, Netlify, or GitHub Pages
  • You don't use a CMS like WordPress, Ghost, or Webflow
  • Your site is built with a static site generator (Astro, Next.js, Hugo, Gatsby, 11ty, etc.)
  • You want full control over how blog content is rendered on your site

If you use WordPress, Ghost, or Webflow, you don't need this — use the direct publishing integrations instead.

How it works

theStacc generates and stores your blog content. The Public Blog API exposes that content as JSON. Your static site fetches it at build time and generates static HTML pages.

theStacc generates blog → stored in theStacc database
                                    ↓
Your site rebuilds → fetches blogs from Public Blog API
                                    ↓
Static HTML pages generated → deployed to your CDN
                                    ↓
Google crawls → sees full static HTML → indexes and ranks normally

Because content is fetched at build time (not in the browser), Google sees fully rendered HTML pages. SEO is identical to any other static site — Google has no idea the content came from an API.

Authentication

Every project gets a unique API key for public access. Find it under Settings > Publishing > API Access.

Include the API key in every request as a query parameter or header:

# Query parameter
GET https://api.thestacc.com/blog/api/v1/public/blogs?api_key=YOUR_API_KEY

# Or as a header
GET https://api.thestacc.com/blog/api/v1/public/blogs
Authorization: Bearer YOUR_API_KEY

Keep your API key private. Use environment variables in your build process — never commit it to your repository.

Endpoints

List all published blogs

GET /blog/api/v1/public/blogs?api_key=YOUR_API_KEY

Returns all blogs with status: published, sorted by published_at (newest first). By default returns metadata only (no content). Pass include_content=true to get full HTML content.

Query parameters:

  • api_key (required) — your project API key
  • limit (optional) — number of blogs to return (default: 50, max: 100)
  • offset (optional) — pagination offset (default: 0)
  • category (optional) — filter by category name
  • include_content (optional) — set to true to include full blog HTML content (default: false)

Response (default — without content):

{
  "blogs": [
    {
      "id": "abc-123",
      "title": "10 SEO Tips for Small Businesses",
      "slug": "seo-tips-small-businesses",
      "excerpt": "Discover actionable SEO strategies that...",
      "meta_title": "10 SEO Tips for Small Businesses | Your Brand",
      "meta_description": "Discover 10 actionable SEO strategies...",
      "featured_image_url": "https://storage.thestacc.com/images/seo-tips.webp",
      "categories": ["SEO", "Marketing"],
      "tags": ["seo", "small-business", "organic-traffic"],
      "published_at": "2026-03-28T10:00:00Z"
    }
  ],
  "total": 42,
  "limit": 50,
  "offset": 0
}

When include_content=true is passed, each blog also includes a content field with the full HTML body.

Get a single blog by slug

GET /blog/api/v1/public/blogs/:slug?api_key=YOUR_API_KEY

Returns the full blog content for a specific slug (always includes content).

Response:

{
  "id": "abc-123",
  "title": "10 SEO Tips for Small Businesses",
  "slug": "seo-tips-small-businesses",
  "excerpt": "Discover actionable SEO strategies that...",
  "content": "<h2>Why SEO matters</h2><p>Search engine optimization...</p>",
  "meta_title": "10 SEO Tips for Small Businesses | Your Brand",
  "meta_description": "Discover 10 actionable SEO strategies...",
  "featured_image_url": "https://storage.thestacc.com/images/seo-tips.webp",
  "categories": ["SEO", "Marketing"],
  "tags": ["seo", "small-business", "organic-traffic"],
  "published_at": "2026-03-28T10:00:00Z",
  "updated_at": "2026-03-29T14:30:00Z",
  "word_count": 1850
}

Returns 404 if the slug doesn't exist or the blog isn't published.

Get blog sitemap data

GET /blog/api/v1/public/blogs/sitemap?api_key=YOUR_API_KEY

Returns a lightweight list of all published blogs for generating your XML sitemap. Only includes slug, published_at, and updated_at.

Response:

{
  "blogs": [
    {
      "slug": "seo-tips-small-businesses",
      "published_at": "2026-03-28T10:00:00Z",
      "updated_at": "2026-03-29T14:30:00Z"
    }
  ],
  "total": 42
}

Content format

The content field contains HTML — the same HTML that gets published to WordPress or Ghost. It includes:

  • Headings (h2, h3, h4)
  • Paragraphs, lists, blockquotes
  • Links (internal and external)
  • Images with alt text
  • Inline styles for formatting

You can render it directly with set:html (Astro), dangerouslySetInnerHTML (React/Next.js), or | safe (Hugo). Apply your own CSS to match your site's design.

Rate limits

The Public Blog API is designed for build-time fetching, not real-time client requests. A typical static site build makes 1-3 requests total. Avoid calling the API from client-side browser code — use it at build time only.

Error handling

All errors return a JSON object with a detail field:

{
  "detail": "Invalid API key. Check that your key is correct and hasn't been revoked."
}

Common HTTP status codes:

  • 401 — Invalid or missing API key
  • 404 — Blog not found or not published
  • 500 — Server error (retry after a few seconds)

Next steps