snapcode

Render API

Render API (Pro)

Pro API keys can render server-side via POST /api/v1/render. Authenticate with an Authorization: Bearer header; the response is the image itself (image/png or image/svg+xml). Rate limit: 60 requests per minute per key.

Example

curl -X POST https://getsnapcode.dev/api/v1/render \
  -H "Authorization: Bearer sk_snapcode_..." \
  -H "Content-Type: application/json" \
  -d '{"code": "const x = 1;", "language": "ts", "theme": "dracula"}' \
  --output card.png

Request body fields

code (required)Source code to render.
language (required)Language id, e.g. ts, python, go.
formatpng (default) or svg.
scalePNG scale: 1, 2 (default), or 3.
theme, backgroundBuilt-in theme/background names from the web tool.
fontSize, padding, showChrome, title, showLineNumbersLayout options matching the web tool.
highlightLines, lineRangeCode options, e.g. highlightLines: [3,7], lineRange: [5,12].
diffOriginal, diffViewRender a computed diff against original code, unified or split.

Errors are JSON: 401 invalid key, 403 free plan, 429 rate-limited, 400 with a validation error code.