API
One endpoint. GET it. Drop the URL into an <img> tag.
GET /api/img
Returns image/png (or image/svg+xml with fmt=svg).
| param | default | notes |
|---|---|---|
| code | — | URL-encoded source. Up to 1500 chars. Use ?id= for longer. |
| id | — | Snippet ID returned by POST /api/snippets. |
| lang | ts | One of: ts, tsx, js, jsx, json, py, go, rs, rb, sh, bash, css, html, sql, md, yaml, toml, java, c, cpp, swift, kotlin, php, text |
| theme | github-dark | One of: github-dark, github-light, dracula, monokai, solarized-dark, solarized-light |
| window | mac | mac (traffic lights) or none |
| lines | 0 | 1 to show line numbers |
| pad | 32 | Outer padding in px (16–128) |
| width | 1200 | Canvas width in px (320–2400) |
| og | 0 | 1 fits content into 1200×630 OG card |
| bg | — | Hex override for theme background (#rrggbb) |
| fmt | png | png or svg |
Examples
Inline in HTML / Markdown
<img src="https://code-shot.labs.basenull.com/api/img?code=const%20x%20%3D%201&theme=dracula&lang=ts">
OG image / Twitter card
<meta property="og:image" content="https://code-shot.labs.basenull.com/api/img?code=...&og=1"> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:image" content="https://code-shot.labs.basenull.com/api/img?code=...&og=1">
curl
curl 'https://code-shot.labs.basenull.com/api/img?code=const%20x%20%3D%201&theme=monokai' -o out.png
POST /api/snippets
Creates a permanent ?id= snippet for code over 1500 chars (or whenever you want a stable URL).
curl
curl -X POST https://code-shot.labs.basenull.com/api/snippets \
-H 'content-type: application/json' \
-d '{
"code": "...",
"lang": "ts",
"theme": "dracula",
"email": "you@example.com"
}'
# Response:
# { "id": "...", "url": ".../i/abc123", "image_url": ".../api/img?id=abc123", "claim_token": "..." }Rate limits
Anonymous snippets re-render up to 200 times across our cache layer before returning a rate-limit image. Pro removes the cap entirely.
CLI
code-shot — pipe code from stdin and print a permanent URL. Pairs to your account via a one-time browser flow; subsequent renders attribute snippets to you (no watermark if you're on Pro). Requires Node.js 18.17+.
Install
The CLI is a single auditable Node.js file (~12 KB). Download it from https://code-shot.labs.basenull.com/code-shot and put it on your PATH:
macOS / Linux
# Download curl -o code-shot https://code-shot.labs.basenull.com/code-shot # Make it executable (the file ships with #!/usr/bin/env node) chmod +x code-shot # Move it onto your PATH mv code-shot ~/.local/bin/ # Test code-shot --version
Windows (PowerShell)
Invoke-WebRequest https://code-shot.labs.basenull.com/code-shot -OutFile code-shot # Run with: node code-shot
Convenience installer
Same outcome as the manual steps. Audit first: /install.sh.
One-line install
curl -fsSL https://code-shot.labs.basenull.com/install.sh | sh
Use it
Render anonymously
echo "const x = 1" | code-shot --theme dracula --lang ts
Pair with your account
code-shot login # → opens a URL; click "Authorize" in your browser # → token saved to ~/.config/code-shot/token
Render attributed to your account
echo "const x = 1" | code-shot # → snippet is owned by you, unbranded if you're on Pro