Rendering

HTML → a fixed-size image (query form)

The signed-URL form of the card renderer: pass URL-encoded html (or template + data) in the query string.

get/api/render/image

Request

  • Base URL: https://snaplab.dev
  • URL: https://snaplab.dev/api/render/image
  • Auth: one of:
    • HTTP bearer
    • API key in query parameter keyId and API key in query parameter sig

Query parameters

htmlstring

URL-encoded HTML. Provide this or template.

templatestring

URL-encoded {{ template }} HTML.

datastring

JSON object (URL-encoded) with values for the template.

cssstring

URL-encoded stylesheet.

googleFontsstring

Comma-separated font families.

widthinteger

Canvas width (default 1200).

heightinteger

Canvas height (default 630).

deviceScaleFactornumber

Pixel ratio (default 2).

format'png' | 'jpeg' | 'webp'

Image format.

qualityinteger

1–100, jpeg/webp only.

darkMode'true' | 'false' | '1' | '0' | 'prefers' | 'force'

true/force emulate prefers-color-scheme: dark AND turn on Chromium's auto dark mode, so a site with no dark theme still comes back dark (a site that has one is left alone). prefers is the media query only.

delayMsinteger

Extra settle time.

cache'true' | 'false' | '1' | '0'

Set false to force a fresh render.

responseType'binary' | 'json'

json answers with a hosted URL.

keyIdstring

API key id, for a signed URL. Send with sig.

sigstring

hex(HMAC_SHA256(signingSecret, canonicalQuery)) over every pair except sig, sorted by name then value.

expiresinteger

Optional Unix-seconds expiry, included in the signed canonical string.

Response

The rendered card.

urlstring uri required
idstring required
formatstring required
widthinteger
heightinteger
bytesinteger required
cacheHitboolean
durationMsinteger

Example response

{
  "url": "https://snaplab.dev/i/c/V1StGXR8_Z5j",
  "id": "V1StGXR8_Z5j",
  "format": "png"
}

Changes

No recorded changes to this operation across all 1 revision of this API.