# Content API

> A read-only REST API for your site's published posts, pages, tags and authors. Plain JSON, no key needed to read.

Use the Content API to show your Quillhive content anywhere: your own frontend (Next.js, Astro, anything), a mobile app, a newsletter, a help center. It returns published content only. To write, use the dashboard or the [MCP server](/docs/mcp).

## Base URL

```text
https://api.quillhive.com/api/public/v1
```

Every endpoint lives under a site:

```text
https://api.quillhive.com/api/public/v1/sites/{siteId}/...
```

Find your **site ID** in the dashboard under **Settings → Developer → API**. That page also has a copyable base URL, an example request and a headless setup checklist.

## Your first request

```bash
curl https://api.quillhive.com/api/public/v1/sites/YOUR_SITE_ID/posts?limit=3
```

```javascript title="JavaScript"
const res = await fetch(
  'https://api.quillhive.com/api/public/v1/sites/YOUR_SITE_ID/posts?limit=3',
)
const { posts, meta } = await res.json()
```

## Authentication

Reading published content is public. No key is needed.

You can send a site API key as a bearer token. A key is **required** only for the [preview endpoint](/docs/api/posts#preview-a-post), which returns drafts.

```bash
curl https://api.quillhive.com/api/public/v1/sites/YOUR_SITE_ID/posts \
  -H "Authorization: Bearer blgg_..."
```

- Create keys in **Settings → Developer → API**. Each key belongs to one site.
- A key must match the `siteId` in the path. A wrong, unknown or mismatched key gets a `401`, even on public endpoints.
- Keys can read drafts. Keep them on your server and never ship them to a browser.

## Endpoints

| Endpoint | Returns |
| --- | --- |
| [`GET /sites/{siteId}`](/docs/api/sites#get-a-site) | Site settings, SEO fields and navigation |
| [`GET /sites/{siteId}/navigation-items`](/docs/api/sites#get-navigation-menus) | Header and footer menus. Filter with `?group=` |
| [`GET /sites/slug/{slug}`](/docs/api/sites#find-a-site-by-slug-or-domain) | A site by its slug |
| [`GET /sites/domain/{domain}`](/docs/api/sites#find-a-site-by-slug-or-domain) | A site by its custom domain |
| [`GET /sites/{siteId}/posts`](/docs/api/posts#list-posts) | Published posts, paginated, filterable by tag and author |
| [`GET /sites/{siteId}/posts/{idOrSlug}`](/docs/api/posts#get-a-post) | One published post or page with HTML |
| [`GET /sites/{siteId}/posts/preview/{idOrUuid}`](/docs/api/posts#preview-a-post) | Any post or page, drafts included. Key required |
| [`GET /sites/{siteId}/pages`](/docs/api/pages#list-pages) | Published pages |
| [`GET /sites/{siteId}/pages/{idOrSlug}`](/docs/api/pages#get-a-page) | One published page with HTML |
| [`GET /sites/{siteId}/tags`](/docs/api/tags#list-tags) | Tags with post counts |
| [`GET /sites/{siteId}/tags/{slug}`](/docs/api/tags#get-a-tag) | One tag |
| [`GET /sites/{siteId}/authors`](/docs/api/authors#list-authors) | Author profiles |
| [`GET /sites/{siteId}/authors/{slug}`](/docs/api/authors#get-an-author) | One author |

## Conventions

- Responses are JSON objects with one named key: `{ "post": … }`, `{ "posts": […] }`.
- Dates are ISO 8601 strings in UTC.
- Only published content is returned. Drafts and scheduled posts return `404`, except through the preview endpoint.
- Content is HTML in `html`, ready to render. It is the same HTML the hosted blog uses.

## Keeping a cache fresh

If you cache responses, register a [webhook](/docs/webhooks). Quillhive sends one when posts, pages, tags or site settings change, so you can drop just what changed.
