API Documentation
URL-based configuration and OG Image API for generating code screenshots programmatically.
URL Parameters
You can configure CodeTarz via URL parameters to create shareable links.
GET
/editor?code={base64}&lang={language}&theme={theme}Open editor with pre-configured code and settings.
| Param | Type | Description |
|---|---|---|
| code | string | Base64 encoded code string (btoa(encodeURIComponent(code))) |
| lang | string | Language identifier (e.g., typescript, python, rust). Default: typescript |
| title | string | File title (e.g., app.tsx). Default: untitled.ts |
| theme | string | Theme ID (e.g., one-dark, dracula, github-light). Default: one-dark |
| bg | number | Background index (0-21). Default: 0 |
| font | number | Font index (0-5). Default: 0 (JetBrains Mono) |
| fontSize | number | Font size in pixels (10-24). Default: 14 |
| padding | number | Padding in pixels (16-80). Default: 40 |
| radius | number | Border radius in pixels (0-32). Default: 12 |
| opacity | number | Code card opacity (80-100). Default: 100 |
| window | string | Window style: macos, windows, none. Default: macos |
| lines | string | Show line numbers. Set to "0" to hide. Default: shown |
| watermark | string | Show watermark. Set to "1" to enable. Default: hidden |
| noise | string | Enable noise texture. Set to "1" to enable. Default: off |
| badge | string | Show "Made with CodeTarz" badge. Set to "1" to enable. Default: hidden |
| badgePos | string | Badge position: bottom-left, bottom-right. Default: bottom-left |
| gc1 | string | Custom gradient color 1 (hex, e.g., #ff0000) |
| gc2 | string | Custom gradient color 2 (hex, e.g., #0000ff) |
| ga | number | Custom gradient angle in degrees. Default: 135 |
URL
/editor?code=Y29uc3QgeCA9IDU7&lang=typescript&theme=dracula&bg=0&padding=40OG Image API
Generate Open Graph images dynamically for social media previews.
GET
/api/og?code={base64}&theme={theme}&title={title}Returns a PNG image (1200x630) suitable for og:image meta tag.
| Param | Type | Description |
|---|---|---|
| code | string | Base64 encoded code string |
| d | string | Full share data (base64 JSON). Alternative to code param |
| theme | string | Theme ID (default: one-dark) |
| title | string | Title text on the image |
URL
/api/og?code=Y29uc3QgeCA9IDU7&theme=dracula&title=My%20CodeAvailable Themes
All supported code themes with their IDs.
One Dark Proone-dark
Draculadracula
Night Owlnight-owl
GitHub Darkgithub-dark
Solarized Darksolarized-dark
Catppuccin Mochacatppuccin
Monokaimonokai
Tokyo Nighttokyo-night
GitHub Lightgithub-light
Catppuccin Lattecatppuccin-latte
Solarized Lightsolarized-light
Min Lightmin-light
Supported Languages
18 programming languages with full syntax highlighting.
JavaScriptTypeScriptPythonRustGoJavaC++HTMLCSSSQLBashJSONYAMLMarkdownPHPRubySwiftKotlin
Preset Templates
Available preset configurations for social media optimization.
Twitter Post1200x675 optimized, padding 48, watermark enabled
twitterLinkedIn Card1200x627 optimized, padding 56, watermark enabled
linkedinBlog HeroWide format, font size 15, padding 64
blog-heroInstagram1080x1080 square, no window controls, watermark enabled
instagramPresentation16:9 slide format, font size 16, padding 56
presentationMinimalNo window controls, no line numbers, padding 24
minimalDocumentationNo window controls, compact, font size 13
documentationUsage Examples
Common usage patterns.
Share via URL parameters
JavaScript
const code = btoa(encodeURIComponent(`const x = 5;
const y = 10;
console.log(x + y);`));
const url = `https://codetarz.dev/editor?code=${code}&lang=javascript&theme=dracula`;
console.log(url);Share via encoded link (with OG preview)
JavaScript
const data = JSON.stringify({
code: 'const x = 5;',
language: 'typescript',
title: 'example.ts',
theme: 'dracula',
bg: 0, font: 0, fontSize: 14, padding: 40,
borderRadius: 12, windowStyle: 'macos', showLineNumbers: true,
headerText: '', footerText: ''
});
const encoded = btoa(encodeURIComponent(data));
const url = `https://codetarz.dev/s?d=${encoded}`;Embed OG Image in HTML
HTML
<meta property="og:image" content="https://codetarz.dev/api/og?code=Y29uc3QgeCA9IDU7&theme=one-dark&title=My%20Project" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />Use in Markdown
Markdown
