API Docs

Convert webpages and HTML into Markdown, text, and JSON.

The MVP exposes four core endpoints. Use anonymous calls for quick testing or create an API key for 100 free credits. All endpoints accept either a public URL or raw pasted HTML.

POST /api/convert

Converts one URL or pasted HTML snippet. Body: one of url or html (required, not both), optional sourceUrl for resolving relative links when using html, and optional format of markdown, text, or json.

POST /api/bulk

Converts 1–20 URLs, stores a job record, and returns jobId, status, and results.

GET /api/jobs/:id

Returns a previously created bulk job with success and per-URL error records.

GET /api/usage

Returns anonymous daily usage or API-key credit balance.

POST /api/keys

Creates a free-tier API key (100 credits). The raw key is shown once. Paid-plan keys are provisioned automatically after Stripe checkout.

POST /api/stripe/checkout

Creates a Stripe subscription checkout when STRIPE_SECRET_KEY and STRIPE_PRICE_* are configured.

Examples

# Create a free API key (100 credits)
curl -X POST https://www.contentextractapi.com/api/keys \
  -H "content-type: application/json" \
  -d '{"label":"research agent"}'

# Convert a URL to Markdown
curl -X POST https://www.contentextractapi.com/api/convert \
  -H "authorization: ce_your_key" \
  -H "content-type: application/json" \
  -d '{"url":"https://example.com","format":"markdown"}'

# Convert pasted HTML to plain text
curl -X POST https://www.contentextractapi.com/api/convert \
  -H "authorization: ce_your_key" \
  -H "content-type: application/json" \
  -d '{"html":"<article><h1>Hello</h1><p>World</p></article>","format":"text"}'

# Convert pasted HTML with a source URL (resolves relative links)
curl -X POST https://www.contentextractapi.com/api/convert \
  -H "authorization: ce_your_key" \
  -H "content-type: application/json" \
  -d '{"html":"<a href=\\">/about\\"}>About</a>","sourceUrl":"https://example.com","format":"markdown"}'

# Bulk convert URLs
curl -X POST https://www.contentextractapi.com/api/bulk \
  -H "authorization: ce_your_key" \
  -H "content-type: application/json" \
  -d '{"urls":["https://example.com","https://www.paulgraham.com/greatwork.html"]}'

Storage

lib/store.ts persists API keys, credits, and jobs in Supabase Postgres (isolated contentextract schema), so balances survive serverless cold starts. Set SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY in your environment.