Docs / Developer tools

Generated images API

Share images, code screenshots, avatars, placeholders and charts from a URL.

Pictures made from text, with no browser involved: link-preview (Open Graph) cards and syntax-coloured code images. Latin, Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada and Malayalam are shaped properly (conjuncts, vowel signs) and can be mixed in one line; other scripts come out as empty boxes. PNG by default; format=svg gives the same picture as an SVG whose text is drawn as outlines, so it needs no fonts where it is shown. Text and colours only: no images are fetched from anywhere. Each request counts as 10 against the rate limit.

Base URL https://api.dharun.devNo key needed for most600 units a minute, 3000 with a free keyThis page as Markdown

Social preview image

GET/v1/og-image

A 1200 by 630 card for og:image and twitter:image: a title (set as large as fits in three lines, cut with an ellipsis beyond that), an optional subtitle of up to two lines, and a site name and tag along the bottom. The same URL always gives the same picture, so it can be used directly in a meta tag.

The answer returns the image itself; errors are JSON as everywhere else.

ParameterDescription
titlequery, requiredUp to 200 characters, in any script.
subtitlequeryUp to 300 characters; two lines are shown.
sitequerySite name, bottom left.
tagqueryShort label, bottom right.
themequeryDefault dark. One of: dark, light.
bgqueryBackground colour, hex.
fgqueryTitle colour, hex.
accentqueryAccent colour, hex.
formatqueryDefault png. One of: png, svg.

curl

curl -o picture.png "https://api.dharun.dev/v1/og-image?title=Free%20APIs%20for%20Indian%20developers&subtitle=Pincodes%2C%20IFSC%2C%20holidays%20and%20more&site=api.dharun.dev&utm_medium=docs"

HTML

<img src="https://api.dharun.dev/v1/og-image?title=Free%20APIs%20for%20Indian%20developers&amp;subtitle=Pincodes%2C%20IFSC%2C%20holidays%20and%20more&amp;site=api.dharun.dev&amp;utm_medium=docs" alt="Social preview image">
Try it here

Change the values and send the request from your browser. Needs JavaScript.

Result

Example: Social preview image

Code as an image

GET/v1/code-imagePOST

A code snippet as a window with syntax colouring. Up to 150 lines of 140 characters. PNGs are drawn at twice the pixel density for sharp text (very large ones at single). The language is guessed from the title's file extension or the code when not given, and reported in the X-Code-Language header.

Also takes POST: The code. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.

The answer returns the image itself; errors are JSON as everywhere else.

What you send here is never written to the log, and the answer is not cached.

ParameterDescription
codequeryThe code (or POST it).
languagequeryLanguage name or file extension, such as go, python, js, sql.
titlequeryFile name shown in the title bar.
themequeryDefault dark. One of: dark, light.
lineNumbersqueryShow line numbers. One of: true.
formatqueryDefault png. One of: png, svg.

curl

curl -o picture.png "https://api.dharun.dev/v1/code-image?language=go&title=main.go&code=package+main%0A%0Aimport+%22fmt%22%0A%0Afunc+main%28%29+%7B%0A%09fmt.Println%28%22%E0%AE%B5%E0%AE%A3%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%AE%E0%AF%8D%22%29%0A%7D&utm_medium=docs"

HTML

<img src="https://api.dharun.dev/v1/code-image?language=go&amp;title=main.go&amp;code=package+main%0A%0Aimport+%22fmt%22%0A%0Afunc+main%28%29+%7B%0A%09fmt.Println%28%22%E0%AE%B5%E0%AE%A3%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%AE%E0%AF%8D%22%29%0A%7D&amp;utm_medium=docs" alt="Code as an image">
Try it here

Change the values and send the request from your browser. Needs JavaScript.

Result

Example: Code as an image

Avatar with initials

GET/v1/avatar/{name}

A round (or square) tile with a person's initials, its colour fixed by the name, for user lists and comments. Initials in Indian scripts keep their vowel signs and conjuncts. SVG by default; a .png suffix or format=png gives PNG.

The answer returns the image itself; errors are JSON as everywhere else.

ParameterDescription
namepath, requiredThe name, in any script. The first letters of its first and last words are drawn.
sizequeryWidth and height in pixels, 16 to 1024. Default 128.
shapequeryDefault circle. One of: circle, square, rounded.
bgqueryBackground colour as hex, such as 2563eb. Default: picked from the name.
fgqueryLetter colour as hex. Default white.
initialsqueryDraw these letters instead (up to 4).
formatquerysvg (default) or png. One of: svg, png.

curl

curl -o picture.svg "https://api.dharun.dev/v1/avatar/Priya%20Raman?utm_medium=docs"

HTML

<img src="https://api.dharun.dev/v1/avatar/Priya%20Raman?utm_medium=docs" alt="Avatar with initials">
Try it here

Change the values and send the request from your browser. Needs JavaScript.

Result

Example: Avatar with initials

Placeholder image

GET/v1/placeholder/{size}

A plain box with its size (or your text) in the middle, for mock-ups and layouts.

The answer returns the image itself; errors are JSON as everywhere else.

ParameterDescription
sizepath, requiredWIDTHxHEIGHT, or one number for a square; each 8 to 4000. A .png suffix gives PNG.
textqueryText to show instead of the size, up to 80 characters.
bgqueryBackground colour as hex. Default dde3ea.
fgqueryText colour as hex. Default 556070.
formatquerysvg (default) or png. One of: svg, png.

curl

curl -o picture.svg "https://api.dharun.dev/v1/placeholder/600x400?utm_medium=docs"

HTML

<img src="https://api.dharun.dev/v1/placeholder/600x400?utm_medium=docs" alt="Placeholder image">
Try it here

Change the values and send the request from your browser. Needs JavaScript.

Result

Example: Placeholder image

Chart image from numbers

GET/v1/chartPOST

A bar, line, pie or sparkline chart as SVG or PNG, for emails, chat bots, READMEs and anywhere JavaScript charts cannot run. Axis values are written the Indian way (K, L, Cr). In the query: values=3,5,2 (repeat values for more series, with names to name them) and labels=Jan,Feb,Mar. Counts as 10 against the rate limit.

Also takes POST: A chart as JSON: {"type": "bar", "title": "...", "labels": [...], "series": [{"name": "...", "values": [...], "color": "2563eb"}], "width": 800, "height": 450}. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.

The answer returns the image itself; errors are JSON as everywhere else.

ParameterDescription
typequeryDefault bar. One of: bar, line, pie, sparkline.
valuesqueryNumbers separated by commas. Repeat the parameter for more series.
labelsqueryLabels for the values, separated by commas.
namesqueryA name for each series: repeated like values, or separated by commas.
titlequeryTitle above the chart.
widthqueryPixels, 40 to 3000. Default 800 (160 for a sparkline).
heightqueryPixels, 20 to 3000. Default 450 (40 for a sparkline).
themequeryDefault light. One of: light, dark.
formatquerysvg (default) or png. One of: svg, png.

curl

curl -o picture.svg "https://api.dharun.dev/v1/chart?type=bar&title=Sales%20by%20quarter&labels=Q1,Q2,Q3,Q4&values=12,19,9,15&utm_medium=docs"

HTML

<img src="https://api.dharun.dev/v1/chart?type=bar&amp;title=Sales%20by%20quarter&amp;labels=Q1,Q2,Q3,Q4&amp;values=12,19,9,15&amp;utm_medium=docs" alt="Chart image from numbers">
Try it here

Change the values and send the request from your browser. Needs JavaScript.

Result

Example: Chart image from numbers

Using an AI assistant? Connect the MCP server and it can call this API by itself. Want every endpoint on one bench? Open the playground.