apyhub
Back
▣ OUTPUT KIT · MEDIA KIT

Convert HTML, MD & URL to Image API

What it does

The Convert HTML, MD & URL to Image API turns a web page, raw HTML or Markdown into a PNG or JPEG. Send one of url, html or markdown, and get back a screenshot rendered in Chromium.

Set the viewport with width and height (defaults 1280 by 720). Turn on full_page to capture the whole scrollable page. Pick png or jpeg with image_format, which defaults to png.

For live pages, wait_until and wait_for_selector hold the capture until content loads. custom_css and scripts can hide cookie banners or set the page up first. cookies, extra_headers and auth_type reach pages behind a login. response_mode returns the image as a file by default. It can also return base64, JSON with size and time, or a temporary download link.

Teams use this HTML to image API to make social cards and link previews from HTML templates. They also capture website screenshots for archives, QA checks and reports. Markdown input turns release notes into shareable images. Because it takes raw markup, this HTML to image API needs no hosted page at all.

After capture, the Convert PNG to WebP API makes the image lighter for the web. The Compress Images API shrinks it further.

AI agents can call it through ApyHub MCP.

POST
Capture a screenshot image from HTML or URL
https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-image

QUICKSTART

GUIDE

Quickstart

Capture a screenshot from a URL with the default viewport and return it as JSON.

curl -X POST "https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-image" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "response_mode": "json"
  }'

What you'll get back

Returns a JSON object. Depending on response_mode, the object contains either filename and image_base64, or filename, size, created_at, and image_base64, or file_url, expires_at, and expires_in_seconds.

{
  "filename": "screenshot.png",
  "size": 4893,
  "created_at": "2026-01-15T10:30:00Z",
  "image_base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg=="
}
TRY ITLIVE · 8 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
body*

About this endpoint

What it does

Renders a web page, raw HTML or Markdown in Chromium and returns a PNG or JPEG screenshot. Set the viewport, wait for content, and pick how the image comes back.

Request Body

ParameterTypeDescription
urlStringRequired if html and markdown are not set. Public web page to capture. Must be http or https. Max length 2083 characters. Provide exactly one of url, html or markdown.
htmlStringRequired if url and markdown are not set. Raw HTML to render and capture. Max length 500000 characters.
markdownStringRequired if url and html are not set. Markdown to convert to HTML, render and capture. Max length 500000 characters.
image_formatStringImage format. Allowed values: png, jpeg. Default: png.
response_modeStringHow the image is returned. Allowed values: binary, base64, json, url. Default: binary.
filenameStringName of the image file. Default: screenshot.png. Max length 255 characters.
widthIntegerViewport width in pixels. Range: 100 to 10000. Default: 1280.
heightIntegerViewport height in pixels. Range: 100 to 10000. Default: 720.
full_pageBooleanCapture the full scrollable page, not only the viewport. Default: false.
custom_cssStringCSS injected into the page before capture. Max length 200000 characters.
style_urlStringPublic URL of a CSS file to load before capture. Max length 2048 characters.
script_urlStringPublic URL of a JavaScript file to load before capture. Max length 2048 characters.
scriptsString ArrayInline scripts or script URLs to run before capture.
execute_javascriptBooleanRun the page's JavaScript before capture. Default: true.
wait_untilENUMWhen the page counts as loaded. Allowed values: load, domcontentloaded, networkidle, networkidle0, networkidle2. Default: networkidle.
wait_for_selectorStringCSS selector to wait for before capture. Max length 256 characters.
wait_for_functionStringJavaScript expression to wait for until it is true. Max length 200000 characters.
wait_for_timeoutIntegerHow long to wait for the selector or function, in milliseconds. Range: 0 to 300000.
timeoutIntegerLoad and capture timeout in milliseconds. Range: 1000 to 180000. Default: 30000.
auth_typeENUMLogin used when loading url. Allowed values: none, basic, bearer. Default: none.
auth_credentialsStringLogin value for auth_type: username:password for basic, the token for bearer. Max length 2048 characters.
extra_headersObjectExtra HTTP headers sent when loading url.
cookiesObject ArrayCookies set in the browser before loading the page.

Response

Returns the image in the shape set by response_mode. In json mode, returns a JSON object with the image and its metadata.

ParameterTypeDescription
filenameStringName of the image file.
sizeIntegerSize of the image in bytes.
created_atStringUTC timestamp when the image was created.
image_base64StringBase64-encoded image.

Notes

  • Provide exactly one of url, html or markdown.
  • binary returns the image file itself, not JSON. base64 returns only filename and image_base64. url returns file_url, expires_at and expires_in_seconds. The link needs no authentication and stops working after it expires.
  • The request body must be under 5 MB. Larger bodies return 413.
  • A capture that runs past timeout returns 504.
  • url, style_url, script_url and scripts must be public addresses.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.