Skip to content
POST AI agent ready /v1/screenshot/capture

Screenshot API - Prepare HTML for Headless Chromium Capture

Takes HTML plus target width, height, and format (png or jpeg). Returns an HTML document with the viewport and body sized exactly to your target dimensions, ready to load in Puppeteer, Playwright, or any headless Chromium. Actual rasterization runs in your own browser runtime.

Parameters

stringrequired

HTML content to capture.

number

Viewport width (100-4096).

number

Viewport height (100-4096).

string

Image format.

Code examples

curl -X POST https://api.botoi.com/v1/screenshot/capture \
  -H "Content-Type: application/json" \
  -d '{"html":"<div style=\"padding:40px;font-family:system-ui\"><h1>Hello world</h1><p>Rendered at 1200×630.</p></div>","width":1200,"height":630,"format":"png"}'

When to use this API

Dynamic social share cards

Build OG images on demand by rendering a template with user data and capturing with Puppeteer. The 1200×630 dimensions match Twitter/Open Graph recommendations.

Code snippet screenshots

Combine with /v1/code/highlight. Highlight code to HTML, wrap with this endpoint, and capture for sharing in blog posts or marketing assets.

Automated visual regression tests

Feed this endpoint's HTML output into Playwright's toHaveScreenshot. Captures identical pixels across runs for snapshot comparison.

Frequently asked questions

Why doesn't this return the image directly?
Headless browser rendering needs a native Chromium process, which isn't available in edge Workers. Run this endpoint's output through Puppeteer or Playwright on a regular Node server.
What dimensions are supported?
100 to 4096 pixels per side. Default 1280×720. Common social-image sizes: 1200×630 (OG/Twitter), 1080×1080 (Instagram square), 1080×1920 (Instagram story).
PNG or JPEG?
PNG for images with text, transparency, or sharp edges. JPEG for photographic content where file size matters more than pixel-perfect edges. Default is PNG.
How do I capture with Puppeteer?
`await page.setContent(wrappedHtml); await page.setViewport({width: 1200, height: 630}); const buf = await page.screenshot({type: "png"});`
Can I include web fonts?
Yes. Include @font-face rules or Google Fonts link tags in your HTML. Wait for fonts to load before capturing (Puppeteer: `await page.evaluate(() => document.fonts.ready)`).

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.