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.pngRequest body fields
| code (required) | Source code to render. |
| language (required) | Language id, e.g. ts, python, go. |
| format | png (default) or svg. |
| scale | PNG scale: 1, 2 (default), or 3. |
| theme, background | Built-in theme/background names from the web tool. |
| fontSize, padding, showChrome, title, showLineNumbers | Layout options matching the web tool. |
| highlightLines, lineRange | Code options, e.g. highlightLines: [3,7], lineRange: [5,12]. |
| diffOriginal, diffView | Render 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.