Bear docs

API

Bear has a small API for managing your posts and blog settings. It's available on upgraded blogs.

Getting started

Head to your dashboard → Settings → API and generate a key. Each key works for one blog, and you can regenerate or revoke it there whenever you like.

Your API lives at https://bearblog.dev/YOUR-SUBDOMAIN/api/v1/ (use your Bear subdomain here, even if you have a custom domain). Send your key with every request:

Authorization: Bearer YOUR-API-KEY

Request bodies are JSON, so include Content-Type: application/json when creating or updating.

Keep your key private. Anyone who has it can edit your blog.

Posts

A post's uid never changes, even if its slug does.

Fields

Responses also include uid, url, and last_modified. Dates come back in UTC.

Listing

Lists come back 20 at a time, newest first, without content (fetch a single post for that). You get posts, count, page, page_size, and next_page, which is null on the last page.

Blog

Fields

Responses also include last_modified.

Examples

# List drafts
curl 'https://bearblog.dev/YOUR-SUBDOMAIN/api/v1/post/?status=draft' \
  -H 'Authorization: Bearer YOUR-API-KEY'

# Create a draft
curl -X POST 'https://bearblog.dev/YOUR-SUBDOMAIN/api/v1/post/' \
  -H 'Authorization: Bearer YOUR-API-KEY' \
  -H 'Content-Type: application/json' \
  -d '{"title":"Hello from the API","content":"A **Markdown** draft.","tags":["api"]}'

# Publish it
curl -X PATCH 'https://bearblog.dev/YOUR-SUBDOMAIN/api/v1/post/UID/' \
  -H 'Authorization: Bearer YOUR-API-KEY' \
  -H 'Content-Type: application/json' \
  -d '{"publish":true}'

# Update the home page
curl -X PATCH 'https://bearblog.dev/YOUR-SUBDOMAIN/api/v1/blog/' \
  -H 'Authorization: Bearer YOUR-API-KEY' \
  -H 'Content-Type: application/json' \
  -d '{"content":"Welcome to my blog."}'

# Delete a post
curl -X DELETE 'https://bearblog.dev/YOUR-SUBDOMAIN/api/v1/post/UID/' \
  -H 'Authorization: Bearer YOUR-API-KEY'

Errors and limits

When something goes wrong you get a message like {"error":"title is required"}, and nothing is saved.