# QR code image API (Developers)

URL: https://qrdx.dev/docs/developers/image-api
Source: https://github.com/qrdxinc/qrdx/blob/main/apps/docs/content/docs/developers/image-api.mdx

Turn any URL or text into a QR code image with one GET request and no API key, as SVG, PNG, WebP, GIF, BMP, ICO, TIFF or EPS, in the editor's styles, for web and print.

By the end of this page you will have a QR code image URL you can paste into a README, an `<img>` tag or an email template, styled the way you want, and you will know what the API refuses and why.

`GET https://api.qrdx.dev/v1/qr` returns a QR code as an SVG, PNG, WebP, GIF, BMP, ICO or TIFF image, or as a vector EPS file for print and design tools. Everything is in the query string, so the URL itself is the image. It takes the editor's styles too: gradients, frames (custom frames included), borders, eye and dot colors and logo icons. No account or API key is required, apart from a logo you uploaded to QRdx (see [Logos](#logos)). The [free QR code API](https://qrdx.dev/qr-code-api) page has the short overview.

```md title="README.md"
![QR code](https://api.qrdx.dev/v1/qr?data=https://github.com/you/repo)
```

[Try it in the playground](https://qrdx.dev/playground?open=code&lang=image): style a code there, then copy its image URL. Or send requests from the [Render a QR code image](https://qrdx.dev/docs/developers/api/get-qr-image) reference page.

## 1. Request an image [#1-request-an-image]

**curl**

```bash title="Terminal"
curl -o qr.png "https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&format=png&size=1024"
```

**JavaScript**

```js title="qr.mjs"
import { writeFile } from "node:fs/promises";

const url = new URL("https://api.qrdx.dev/v1/qr");
url.searchParams.set("data", "https://qrdx.dev");
url.searchParams.set("format", "png");
url.searchParams.set("size", "1024");

const response = await fetch(url);
await writeFile("qr.png", Buffer.from(await response.arrayBuffer()));
```

**Python**

```python title="qr.py"
import requests

response = requests.get(
    "https://api.qrdx.dev/v1/qr",
    params={"data": "https://qrdx.dev", "format": "png", "size": 1024},
)
response.raise_for_status()
open("qr.png", "wb").write(response.content)
```

```txt title="Output"
qr.png: PNG image data, 1024 x 1024, 8-bit/color RGBA, non-interlaced
```

Quote the URL in a shell so it keeps the `&`. In an HTML page, the URL goes straight into `src`:

```html title="index.html"
<img
  src="https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&size=256&fg=155dfc"
  width="256"
  height="256"
  alt="QR code for qrdx.dev"
/>
```

## 2. Pick a format [#2-pick-a-format]

| `format` | Returns | When |
| --- | --- | --- |
| `svg` (default) | `image/svg+xml` | Web pages and anything that scales |
| `png` | `image/png` | Email, chat apps, documents |
| `webp` | `image/webp`, lossless, transparency kept | Websites: the PNG's pixels in a smaller file |
| `gif` | `image/gif`, at most 256 colors and one transparent color | Older tools and email builders that only take GIF. A design with gradients, an image fill or a photo logo is reduced to a palette; if that would stop it scanning, the request fails with a `400` on `format` (use PNG for that design) |
| `bmp` | `image/bmp`, 24-bit and uncompressed; a transparent background comes out white | Legacy systems and embedded tools that only take BMP |
| `ico` | `image/vnd.microsoft.icon`: a favicon with the code at 16, 32, 48 and 256 px, transparency kept | Favicons. `size` and frames don't apply, and the small sizes are for icons, not for scanning |
| `tiff` | `image/tiff`, 300 dpi, the PNG's pixels with their transparency | Print shops that ask for TIFF |
| `tiff-cmyk` | `image/tiff` in CMYK: black as black ink only, white as no ink, a transparent background white, no ICC profile | Print shops that want CMYK. For exact brand colors, ask your printer for a color-managed conversion |
| `eps` | `application/postscript`, sent as a `qr-code.eps` download | Illustrator, InDesign, print shops. `size` is then the width in points, 72 per inch, so `144` is 2 inches |

```bash title="Terminal"
curl -o qr.webp "https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&format=webp&size=1024"
curl -o qr.eps "https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&format=eps&size=144"
head -2 qr.eps
# %!PS-Adobe-3.0 EPSF-3.0
# %%BoundingBox: 0 0 144 144
```

## 3. Style it [#3-style-it]

Flat parameters cover colors, shapes, a frame and a logo:

```txt title="Rounded modules with an arrow pointing at the code"
https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&body=rounded&eye=rounded&dot=rounded&frame=arrow
```

```txt title="A built-in frame with its label, an official frame with its version, and a community frame"
https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&frame=banner-bottom&frameText=Scan%20the%20menu
https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&frame=autumn-maple.v1&frameText=Hello%20autumn
https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&item=frame:wifi-card
```

For gradients, custom frames and per-eye colors, send the whole design as JSON in `style`:

```js title="styled.mjs"
const style = {
  fgColor: {
    type: "linear",
    angle: 45,
    stops: [
      { color: "#1d4ed8", offset: 0 },
      { color: "#7c3aed", offset: 100 },
    ],
  },
  eyeColor: "#b91c1c",
  frame: { style: "banner-bottom", text: "Scan the menu" },
};
const src = `https://api.qrdx.dev/v1/qr?data=${encodeURIComponent(link)}&style=${encodeURIComponent(JSON.stringify(style))}`;
// 200 image/svg+xml, 634.88 × 727.04: the frame adds to the 512 px code
```

Encode the `data` value when it contains `&`, `#`, `+` or spaces, for example with `encodeURIComponent` in JavaScript. Otherwise the URL is split at those characters. Encode `style` the same way, and write colors without the `#` (or as `%23`): a bare `#` starts the URL fragment and is never sent.

## Parameters [#parameters]

| Parameter | Default | Description |
| --- | --- | --- |
| `data` | required | Text or URL to encode, up to 2048 characters |
| `format` | `svg` | `svg`, `png`, `webp`, `gif`, `bmp`, `ico`, `tiff`, `tiff-cmyk` or `eps` |
| `size` | `512` | Width and height in pixels, `64` to `2048` (points for EPS) |
| `fg` | `000000` | Module color as hex (`155dfc`, `fff`, or 8 digits with alpha) |
| `bg` | `ffffff` | Background color as hex. `00000000` gives a transparent background |
| `eyeColor` | `fg` | Color of the three corner eyes |
| `dotColor` | `fg` | Color of the dot inside each corner eye |
| `body` | `square` | Shape of the data modules; see [Pattern values](#pattern-values) |
| `eye` | `square` | Shape of the corner eye frames |
| `dot` | `square` | Shape of the dot inside each corner eye |
| `level` | `Q` | Error correction: `L` (about 7%), `M` (15%), `Q` (25%) or `H` (30%) |
| `margin` | `4` | Quiet zone around the code in modules, `0` to `16` |
| `frame` | none | A call-to-action [frame](https://qrdx.dev/docs/features/frames): any of the 25 built-in frames, such as `banner-bottom`, `speech-bubble`, `circle` or `dot-ring`, or one of the 1114 [official frames](https://qrdx.dev/docs/features/frames#official-frames) by id (the last part of its [community](https://qrdx.dev/community/frames) page's address) with its version, such as `autumn-maple.v1`. Without a version it's version 1, and `.latest` follows the frame's redesigns; see [Official frames](#official-frames) |
| `frameText` | `Scan me` | The frame's label, up to 24 characters. Also relabels the frame of a `style` or `item` |
| `style` | none | The editor's whole design as JSON; see [Styles](#style) |
| `item` | none | A community frame or theme by id, such as `frame:wifi-card`; see [Community items](#community-items) |
| `logoIcon` | none | A quick icon or a brand logo in the center; see [Logos](#logos) |
| `logoFileId` | none | A logo you uploaded, by file id; needs an API key; see [Logos](#logos) |

Enum values (`level`, `format`, `frame`) are case-insensitive. With a frame, `size` is the width of the code itself and the frame adds to the image, in every format. Flat parameters win over `style`, and `style` wins over `item`.

## Styles [#style]

`style` takes the design as JSON with the same fields as a saved theme, so a theme from [`GET /v1/themes`](https://qrdx.dev/docs/developers/api/list-themes) or the `qrdxStyle` that the [MCP server](https://qrdx.dev/docs/developers/mcp)'s `design_qr` returns can be passed as it is (minus an uploaded logo, see below):

| Field | Takes |
| --- | --- |
| `bgColor`, `fgColor`, `eyeColor`, `dotColor` | A color (hex such as `#155dfc`, `rgb()`, `hsl()` or a color name), or a gradient: `{ "type": "linear", "angle": 45, "stops": [...] }` or `{ "type": "radial", "stops": [...] }`, with 2 to 8 stops of `{ "color", "offset" }` (offset 0 to 100) |
| `bodyPattern`, `cornerEyePattern`, `cornerEyeDotPattern` | The [pattern values](#pattern-values) |
| `level`, `margin` | As the parameters above (`margin` 0 to 16) |
| `frame` | A built-in frame, `{ "style": "banner-bottom", "text": "Scan me", "color": "#155dfc", "textColor": "#ffffff" }`; an official frame by id (with a version or not, as in `frame`), with your labels and colors, `{ "style": "autumn-maple.v1", "text": "Hello autumn", "secondaryText": "", "color": "#4c1d95" }` (`secondaryColor` is its accent, `fontScale` sizes its labels, and an empty label hides it); or a custom one, `{ "style": "custom", "spec": { … } }`, with a frame spec from the [community](#community-items) or a custom frame made in the playground's Frame section. Specs are checked against the engine's frame-spec rules (no markup, links or images; at most 32 KB) |
| `eyeColors` | Colors per eye, over `eyeColor` and `dotColor`: `{ "topLeft": { "outer": "#b91c1c", "inner": "#1d4ed8" }, "topRight": …, "bottomLeft": … }`, each a color or a gradient |
| `moduleScale` | Size of each dot, `0.5` to `1` (default `1`) |
| `shape` | `square` (default) or `circle`: the code in a disc of decorative dots |
| `eyeShapes` | Shapes per eye, over `cornerEyePattern` and `cornerEyeDotPattern`: `{ "topLeft": { "outer": "leaf", "inner": "leaf" }, "topRight": …, "bottomLeft": … }` |
| `eyeGradient` | `corner` (default: each eye sweeps its own gradient) or `code` (the eyes continue the dots' gradient across the code) |
| `bgRadius` | Corner radius of the background, `0` to `0.5` of the code's width; needs a `margin` (the engine caps it at twice the margin, in modules) |
| `backdrop` | A color outside the rounded corners (see-through without it) |
| `halo` | A light rim around the dots and eyes: `{ "color": "#fde68a", "width": 0.25 }`, `width` in modules from `0.1` to `0.5`, `color` default `#e5e7eb`. The rim is drawn opaque (a color's alpha is dropped). It is drawn only on an opaque `bgColor` (no picture) at least as light as `#d1d5db`; otherwise the code is drawn without it and the scan score's `halo` check says why. Any `color` is taken and adjusted to stay scannable, not refused: one darker than `#d1d5db` or lighter than the background is drawn in the closest color inside that range, its hue kept and its lightness moved, and the scan score's `halo` check names the color drawn |
| `shadow` | A see-through copy of the dots and eyes under them: `{ "color": "#000000", "opacity": 0.3, "dx": 0.2, "dy": 0.2 }`, shifts from `-0.3` to `0.3` modules, opacity `0.1` to `0.4` |
| `autoLevel` | Raise error correction to `H` when the logo covers more than 7% of the code (always on here when there's a logo) |
| `logoOptions` | The logo's layout: `size` (`0.1` to `0.3` of the code's width; QRdx shrinks it when the code can't spare the modules), `padding` (`0` to `2` modules), `x` and `y` (`0` to `1`), `shape` (`square`, `rounded` or `circle` crop) and `plate` (a color behind it) |
| `showLogo`, `logoIcon`, `logoFileId` | See [Logos](#logos) |

`style` also takes the `style` value of a playground link (it starts with `1.`), so a design shared from the [playground](https://qrdx.dev/playground) renders as it looks there, without its logo. Unknown fields, logo addresses (`customLogo`) and Logo QR or Image QR art (`art`) are refused with a `400` that says why:

```json title="400 Bad Request"
{"code":"VALIDATION_ERROR","message":"Invalid query parameters","data":{"details":[{"param":"style.customLogo","message":"Logo images by address aren't accepted: upload the image to QRdx and pass its file id as logoFileId, or pick a logoIcon."}]},"status":400}
```

## Community items [#community-items]

`item` renders a published [community](https://qrdx.dev/community) frame or theme, free under CC0. Find ids with [`GET /v1/community/items`](https://qrdx.dev/docs/developers/api/list-community-items), or open an item page and use its type and slug: `/community/frames/wifi-card` is `frame:wifi-card`. A frame item sits on a plain black-on-white code; add `style` or flat parameters to change the code under it. Renders with `item` are cached for 5 minutes (10 at the CDN), since an item can get a new version or be taken down.

### Official frames [#official-frames]

QRdx's own frames, published by @qrdx, can also go by id in `frame` or as a frame's `style` in `style`. They're drawn from the frames QRdx ships, not looked up in the community, so the frame's spec stays out of the URL. QRdx sometimes fixes or redesigns one of its frames, and keeps every version it has published, so an image you embed doesn't change:

- **With a version**, `frame=autumn-maple.v1`: always draws that version of the frame. The playground's Get code dialog copies image URLs this way, with the version you see.
- **Without a version**, `frame=autumn-maple`: version 1, the frame as it was first published. It never changes either.
- **`.latest`**, `frame=autumn-maple.latest`: the frame's newest design, so the image changes when QRdx changes the frame. Use it only if that's what you want. These renders are cached for 5 minutes (10 at the CDN); the others are cached for a year like other renders.

A version the frame doesn't have is a `400` that lists the versions it has. A playground link's `style` value names its official frame the same way.

## Logos [#logos]

- **Quick icons.** `logoIcon` puts one of the editor's icons on a white tile in the center: `wifi`, `location`, `phone`, `email`, `link`, `file`, `calendar`, `whatsapp` or `instagram`. QRdx draws them itself, and they need no key.
- **Brand logos.** `logoIcon` also takes any of the 3,467 brands from [Simple Icons](https://simpleicons.org) by slug: `spotify`, `paypal`, `googlemaps`, `appstore`. The mark is drawn bare in its brand color; add `:black` or `:white` for those colors (`whatsapp:white`), and `logoOptions.plate` in `style` for a plate behind it. [`GET /api/brand-logos`](https://qrdx.dev/api/brand-logos) lists every slug. A slug QRdx doesn't have gets a `400` that suggests the right form.
- **The QRdx mark** that the editor shows by default isn't drawn here: `showLogo: true` alone adds no logo.
- **Error correction rises for a logo.** When a logo covers more than 7% of the code, the code is drawn at level `H`, whatever `level` says, so it still scans.
- **A Swiss QR-bill keeps its level.** For `data` that is a Swiss QR-bill payload (it starts with `SPC` and version `0200`), the code is encoded at exactly `level`, which the guidelines want at `M`: pass `level=M`.

```bash title="Terminal"
curl -o spotify.png "https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&format=png&logoIcon=spotify"
```

**Your own logo.** `logoFileId` draws a PNG or JPEG of up to 1 MB that you uploaded in [Dashboard → Files](https://qrdx.dev/docs/files). The id is the last part of the file's link, `https://qrdx.dev/api/files/<id>`. Send an [API key](https://qrdx.dev/docs/developers/api-keys) of the workspace that owns the file:

```bash title="Terminal"
curl -o qr.png -H "Authorization: Bearer $QRDX_API_KEY" \
  "https://api.qrdx.dev/v1/qr?data=https://qrdx.dev&format=png&logoFileId=<id>"
```

The response is private (`Cache-Control: private, no-store`) and counts toward the workspace's daily API quota. A file from another workspace gets `404`, and a request without a key gets `401`. QRdx reads the image from its own storage and checks that it really is a PNG or JPEG; it never fetches a logo from a web address you send.

`logoOptions` sizes, places, crops and backs any of these logos. Removing an uploaded logo's own background is done in the playground; the image API draws the uploaded file as it is. Logo QR and Image QR art aren't available here: the playground builds them from your picture in the browser. Design art codes in the [playground](https://qrdx.dev/playground?tab=art), or paint a code into AI artwork with the [AI art API](https://qrdx.dev/docs/developers/ai-art-api).

### Pattern values [#pattern-values]

- `body`: `circle`, `circle-large`, `square`, `diamond`, `circle-mixed`, `pacman`, `rounded`, `small-square`, `vertical-line`, `horizontal-line`, `liquid`, `liquid-horizontal`, `liquid-vertical`, `classy`, `classy-rounded`, `leaf`, `plus`, `hexagon`, `star`, `heart`, `random-dots`, `mosaic`, `octagon`
- `eye`: `square`, `rounded`, `gear`, `circle`, `diya`, `extra-rounded`, `message`, `pointy`, `leaf`, `drop`, `octagon`, `bevel`, `squircle`, `cushion`, `shield`, `petal`, `leaf-reverse`, `porthole`, `notch`, `plus`, `bud`, `bowl`
- `dot`: `square`, `rounded`, `circle`, `message`, `message-reverse`, `diya`, `diya-reverse`, `rounded-triangle`, `leaf`, `drop`, `plus`, `cross-rounded`, `hexagon`, `octagon`, `flower`, `heart`, `squircle`, `dots`, `extra-rounded`, `leaf-reverse`, `drop-reverse`, `cushion`

These are the same styles as the [`qrdx` React library](https://qrdx.dev/docs/features/patterns). The [MCP server](https://qrdx.dev/docs/developers/mcp) can also list them with short descriptions.

## Responses [#responses]

A successful request returns the image with:

- `Content-Type: image/svg+xml`, `image/png`, `image/webp`, `image/gif`, `image/bmp`, `image/vnd.microsoft.icon`, `image/tiff` or `application/postscript` (EPS is sent as a `qr-code.eps` download, and TIFF as `qr-code.tif` or `qr-code-cmyk.tif`: browsers other than Safari can't show TIFF in an `<img>`)
- `Cache-Control: public, max-age=31536000, immutable`, except for renders with `item` or an official frame's `.latest` (5 minutes, 10 at the CDN) and with `logoFileId` (`private, no-store`)
- `Access-Control-Allow-Origin: *`, so you can `fetch` it from any website

Rendering is deterministic: the same query string returns the same bytes, which is why responses can be cached for a year. The exceptions are `item` and an official frame's `.latest`, which follow what they name. URLs that use only the original parameters render exactly as they always have.

## If something goes wrong [#if-something-goes-wrong]

### `400` with `"param": "size"` [#400-with-param-size]

`size` is under 64 or over 2048. The body names the limit:

```json title="400 Bad Request"
{"code":"VALIDATION_ERROR","message":"Invalid query parameters","data":{"details":[{"param":"size","message":"Too small: expected number to be >=64"}]},"status":400}
```

### `400` with `"param": "data"` [#400-with-param-data]

The data doesn't fit in a QR code at the chosen error correction level. Use a lower `level` (`L` holds the most) or shorter data; a dynamic code's short link is the usual fix for long URLs.

```json title="400 Bad Request"
{"code":"VALIDATION_ERROR","message":"Invalid query parameters","data":{"details":[{"param":"data","message":"Data is too long for a QR code at error correction level H. Shorten it or use a lower level (L holds the most)."}]},"status":400}
```

### `400` with `"param": "logoIcon"` [#400-with-param-logoicon]

The slug isn't a brand QRdx has or a quick icon. The message suggests the forms that work (`spotify`, `paypal`, `googlemaps`, or `wifi`, `phone`, `email`).

### The image looks wrong or is split [#the-image-looks-wrong-or-is-split]

A `&`, `#` or `+` in `data` or `style` wasn't encoded, so the URL was cut at that character. Encode both values, and write colors without the `#`.

### `429 RATE_LIMITED` [#429-rate_limited]

Over 300 requests a minute from one IP address. Wait the seconds in `Retry-After`. The same URL always returns the same image, so cache it or save the file instead of loading it live.

## Limits [#limits]

- **Rate limit:** 300 requests a minute per IP address. Images don't use the REST API's daily quota.
- **No scan check.** The image API draws what you ask for. To check and repair a design's scan score first, use `design_qr` on the [MCP server](https://qrdx.dev/docs/developers/mcp), or the scan score in the [playground](https://qrdx.dev/playground?tab=design).
- **`style` is up to 8,192 characters** in the URL, and its JSON up to 40 KB.
- **The data is part of the URL.** Like any URL, it can end up in server logs, browser history and caches. Don't put passwords or other secrets in it.

## Scanning tips [#scanning-tips]

- Keep `margin` at `2` or more when the image sits on a dark or busy background, such as a README in GitHub's dark mode.
- Keep good contrast between `fg` and `bg`. Dark modules on a light background scan most reliably.
- The defaults (square modules, 4-module margin) scan on every reader. Stylized shapes such as `circle` dots look softer, and some older scanners read them less reliably: check with the [scan checker](https://qrdx.dev/tools/scan-checker).
- Test the code with a few phones before printing it.

## Self-hosting [#self-hosting]

The endpoint is part of the QRdx web app, so a [self-hosted](https://qrdx.dev/docs/self-hosting) instance serves it at `/api/v1/qr` on your own domain (for example `https://qr.example.com/api/v1/qr?data=…`). The short `/v1/qr` path only works on `api.qrdx.dev`. Rate limiting uses Upstash Redis when it is configured and is off otherwise.

## Related [#related]

- [Render a QR code image](https://qrdx.dev/docs/developers/api/get-qr-image): the reference page with every parameter and a Try it panel
- [Replace the Google Chart QR code API](https://qrdx.dev/docs/developers/google-chart-api): map `chl`, `chs` and `chld` to these parameters
- [Barcode API](https://qrdx.dev/docs/developers/barcode-api): the same idea for EAN, UPC, Code 128 and more
- [Quickstart](https://qrdx.dev/docs/developers/quickstart): from an image URL to a dynamic code you can point elsewhere
