Examples

HTML Publishing

Simple HTML Page

curl -X POST https://brewpage.app/api/html \
  -H "Content-Type: application/json" \
  -d '{
    "namespace": "demo",
    "content": "<html><body><h1>Hello!</h1></body></html>",
    "format": "HTML"
  }'

Markdown with Password Protection

curl -X POST https://brewpage.app/api/html \
  -H "Content-Type: application/json" \
  -d '{
    "namespace": "private",
    "content": "# Secret Notes\n\nThis page requires a password.",
    "format": "MARKDOWN",
    "password": "mysecret"
  }'

Custom TTL (Time to Live)

curl -X POST https://brewpage.app/api/html \
  -H "Content-Type: application/json" \
  -d '{
    "namespace": "temp",
    "content": "<p>This expires in 30 days</p>",
    "format": "HTML",
    "ttlDays": 30
  }'

Key-Value Store

Configuration Storage

# Store app configuration
curl -X PUT https://brewpage.app/api/kv/myapp/config/api_url \
  -H "Content-Type: application/json" \
  -d '{"value": "https://api.example.com"}'

curl -X PUT https://brewpage.app/api/kv/myapp/config/debug \
  -H "Content-Type: application/json" \
  -d '{"value": "false"}'

# List all keys
curl https://brewpage.app/api/kv/myapp/config

# Get specific key
curl https://brewpage.app/api/kv/myapp/config/api_url

Feature Flags

curl -X PUT https://brewpage.app/api/kv/myapp/flags/dark_mode \
  -H "Content-Type: application/json" \
  -d '{"value": "true"}'

# Check flag from your app
curl -s https://brewpage.app/api/kv/myapp/flags/dark_mode | jq -r '.value'

JSON Documents

Store Structured Data

# Create a document
curl -X POST https://brewpage.app/api/json/myapp/users \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "name": "Alice",
      "email": "alice@example.com",
      "role": "admin"
    }
  }'

# Query documents
curl https://brewpage.app/api/json/myapp/users

File Hosting

Upload and Share Files

# Upload an image
curl -X POST https://brewpage.app/api/files/uploads \
  -F "namespace=assets" \
  -F "file=@screenshot.png"

# Upload a document
curl -X POST https://brewpage.app/api/files/uploads \
  -F "namespace=docs" \
  -F "file=@report.pdf"

Sites (Multi-File HTML)

Upload a Site

Upload a multi-file HTML site and get a public URL:

curl -X POST "https://brewpage.app/api/sites" \
  -F "files=@index.html;type=text/html" \
  -F "files=@style.css;type=text/css" \
  -F "paths=index.html" \
  -F "paths=style.css"

Response:

{
  "id": "aBcDeFgHiJ",
  "namespace": "public",
  "entryFile": "index.html",
  "link": "https://brewpage.app/public/aBcDeFgHiJ",
  "ownerLink": "https://brewpage.app/api/sites/public/aBcDeFgHiJ",
  "fileCount": 2,
  "totalSizeBytes": 1024,
  "expiresAt": "2026-04-25T12:00:00Z",
  "tags": [],
  "ownerToken": "your-secret-token"
}

Or upload via ZIP archive:

curl -X POST "https://brewpage.app/api/sites" \
  -F "archive=@site.zip;type=application/zip"

JavaScript / Fetch

Publish from Browser

const response = await fetch('https://brewpage.app/api/html', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    namespace: 'webapp',
    content: '<h1>Published from JS</h1>',
    format: 'HTML'
  })
});

const { url, ownerToken } = await response.json();
console.log('Published at:', url);
console.log('Owner token:', ownerToken); // Save this!

Read KV from Browser

const res = await fetch('https://brewpage.app/api/kv/myapp/config/theme');
const { value } = await res.json();
document.body.dataset.theme = value;

Python

Publish HTML

import requests

resp = requests.post('https://brewpage.app/api/html', json={
    'namespace': 'scripts',
    'content': '# Report\n\nGenerated by Python script.',
    'format': 'MARKDOWN'
})

data = resp.json()
print(f"URL: {data['url']}")
print(f"Owner token: {data['ownerToken']}")  # Save this!

Platform Statistics

# Get overall stats
curl -s https://brewpage.app/api/stats | jq .
# Browse public pages
curl https://brewpage.app/api/gallery/pages

# Browse public files
curl https://brewpage.app/api/gallery/files

# Search gallery
curl "https://brewpage.app/api/gallery/pages?search=hello"